exceptionfactory commented on code in PR #7665:
URL: https://github.com/apache/nifi/pull/7665#discussion_r1329347499


##########
nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-json-record-utils/src/main/java/org/apache/nifi/json/JsonRecordSource.java:
##########
@@ -31,29 +29,23 @@
 
 public class JsonRecordSource implements RecordSource<JsonNode> {
     private static final Logger logger = 
LoggerFactory.getLogger(JsonRecordSource.class);
-    private static final JsonFactory jsonFactory;
     private final JsonParser jsonParser;
     private final StartingFieldStrategy strategy;
-    private final String startingFieldName;
-
-    static {
-        jsonFactory = new JsonFactory();
-        jsonFactory.setCodec(new ObjectMapper());
-    }
 
     public JsonRecordSource(final InputStream in) throws IOException {
-        jsonParser = jsonFactory.createParser(in);
-        strategy = null;
-        startingFieldName = null;
+        this(in, null, null);
     }
 
     public JsonRecordSource(final InputStream in, final StartingFieldStrategy 
strategy, final String startingFieldName) throws IOException {
-        jsonParser = jsonFactory.createParser(in);
+        this(in , strategy, startingFieldName, new JsonParserFactory());
+    }
+
+    public JsonRecordSource(final InputStream in, final StartingFieldStrategy 
strategy, final String startingFieldName, TokenParserFactory 
tokenParserFactory) throws IOException {
+        jsonParser = tokenParserFactory.getJsonParser(in);
         this.strategy = strategy;
-        this.startingFieldName = startingFieldName;
 
-        if (strategy == StartingFieldStrategy.NESTED_FIELD) {
-            final SerializedString serializedNestedField = new 
SerializedString(this.startingFieldName);
+        if (StartingFieldStrategy.NESTED_FIELD.equals(strategy)) {

Review Comment:
   No problem, reversing the order avoided the NPE, so that was a good change, 
but it will also work with `==` as suggested.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to