Github user steveblackmon commented on a diff in the pull request:
https://github.com/apache/incubator-streams/pull/131#discussion_r20464050
--- Diff:
streams-components/streams-converters/src/main/java/org/apache/streams/converter/TypeConverterUtil.java
---
@@ -0,0 +1,51 @@
+package org.apache.streams.converter;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.apache.streams.jackson.StreamsJacksonMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ * TypeConverterUtil supports TypeConverterProcessor in converting between
String json and
+ * jackson-compatible POJO objects
+ */
+public class TypeConverterUtil {
+
+ private final static Logger LOGGER =
LoggerFactory.getLogger(TypeConverterUtil.class);
+
+ public static Object convert(Object object, Class outClass) {
+ return TypeConverterUtil.convert(object, outClass,
StreamsJacksonMapper.getInstance());
+ }
+
+ public static Object convert(Object object, Class outClass,
ObjectMapper mapper) {
+ ObjectNode node = null;
+ Object outDoc = null;
+ if( object instanceof String ) {
+ try {
+ node = mapper.readValue((String)object, ObjectNode.class);
--- End diff --
Those issues only occur when document is not a String. This line will only
execute if document instanceof String evaluated true, so this cast should be
sufficient and more efficient than involving mapper.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---