tpalfy commented on code in PR #6034:
URL: https://github.com/apache/nifi/pull/6034#discussion_r912962378


##########
nifi-nar-bundles/nifi-snmp-bundle/nifi-snmp-processors/src/main/java/org/apache/nifi/snmp/utils/UsmJsonParser.java:
##########
@@ -26,12 +26,17 @@
 
 public class UsmJsonParser {
 
+    private UsmJsonParser() {
+        // Utility class, not to instantiate.
+    }
+
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+    private static final SimpleModule MODULE = new SimpleModule();
+
     static List<UsmUser> parse(final String json) throws 
JsonProcessingException {
-        ObjectMapper mapper = new ObjectMapper();
-        SimpleModule module = new SimpleModule();
-        module.addDeserializer(UsmUser.class, new UsmUserDeserializer());
-        mapper.registerModule(module);
-        return mapper.readValue(json, new TypeReference<List<UsmUser>>() {
+        MODULE.addDeserializer(UsmUser.class, new UsmUserDeserializer());
+        MAPPER.registerModule(MODULE);

Review Comment:
   Can't we move the `addDeserializer` and `registerModule` into a static 
initializer?



-- 
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