github-advanced-security[bot] commented on code in PR #3425:
URL: https://github.com/apache/avro/pull/3425#discussion_r2215831873


##########
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java:
##########
@@ -1042,4 +1045,36 @@
     }
     return super.newRecord(old, schema);
   }
+
+  public CustomEncoding getCustomEncoding(Schema schema) {
+
+    return this.encoderCache.computeIfAbsent(schema, 
this::populateEncoderCache).get();
+  }
+
+  private CustomEncodingWrapper populateEncoderCache(Schema schema) {
+    var enc = ReflectionUtil.getAvroEncode(getClass(schema));
+    if (enc != null) {
+      try {
+        return new 
CustomEncodingWrapper(enc.using().getDeclaredConstructor().newInstance());
+      } catch (Exception e) {
+        throw new AvroRuntimeException("Could not instantiate custom 
Encoding");
+      }
+    }
+    return new CustomEncodingWrapper(null);
+  }
+
+  private class CustomEncodingWrapper {

Review Comment:
   ## Inner class could be static
   
   CustomEncodingWrapper should be made static, since the enclosing instance is 
not used.
   
   [Show more 
details](https://github.com/apache/avro/security/code-scanning/3339)



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