dan-s1 commented on code in PR #7665:
URL: https://github.com/apache/nifi/pull/7665#discussion_r1367185418


##########
nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-json-record-utils/src/main/java/org/apache/nifi/json/JsonParserFactory.java:
##########
@@ -23,27 +23,20 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Objects;
 
-public class JsonParserFactory implements TokenParserFactory{
-    private static final JsonFactory JSON_FACTORY = new JsonFactory();
-    private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
-
+public class JsonParserFactory implements TokenParserFactory {
     @Override
-    public JsonParser getJsonParser(InputStream in) throws IOException {
-        JsonParser jsonParser = JSON_FACTORY.createParser(in);
-        jsonParser.setCodec(JSON_MAPPER);
-
-        return jsonParser;
-    }
+    public JsonParser getJsonParser(final InputStream in, final 
StreamReadConstraints streamReadConstraints, final boolean allowComments) 
throws IOException {
+        Objects.requireNonNull(in, "Input Stream required");
+        Objects.requireNonNull(streamReadConstraints, "Stream Read Constraints 
required");
 
-    @Override
-    public ObjectMapper createCodec(boolean allowComments, 
StreamReadConstraints streamReadConstraints) {
-        ObjectMapper codec = new ObjectMapper();
-        if(allowComments) {
-            codec.enable(JsonParser.Feature.ALLOW_COMMENTS);
+        final ObjectMapper objectMapper = new ObjectMapper();
+        
objectMapper.getFactory().setStreamReadConstraints(streamReadConstraints);
+        if (allowComments) {
+            objectMapper.enable(JsonParser.Feature.ALLOW_COMMENTS);
         }
-        codec.getFactory().setStreamReadConstraints(streamReadConstraints);
-
-        return codec;
+        final JsonFactory jsonFactory = objectMapper.getFactory();
+        return jsonFactory.createParser(in);

Review Comment:
   In the previous code also the `JsonFactory` was coming from the 
`ObjectMapper`and yet `setCodec` was still called. See the previous line 145:
    `jsonParser = codec.getFactory().createParser(in);`
   
   



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to