ashley-taylor commented on code in PR #3445:
URL: https://github.com/apache/avro/pull/3445#discussion_r2508477264


##########
lang/java/avro/src/main/java/org/apache/avro/reflect/CustomEncoding.java:
##########
@@ -48,4 +48,16 @@ protected Schema getSchema() {
     return schema;
   }
 
+  /**
+   * Receives the schema, giving the concrete encoder implementation an
+   * opportunity to detect schema changes and behave accordingly. Useful for
+   * maintaining backwards compatibility.
+   *
+   * @param schema the schema detected during read.
+   * @return custom encoding to be used.
+   */
+  public CustomEncoding<T> withSchema(Schema schema) {

Review Comment:
   Currently, it is only called right after creation, so the libraries use is 
thread safe. 
   We could make it so that instead of a zero-argument constructor, it looks 
for a single-argument constructor and passes the schema in that way. It might 
be a little less discoverable as a feature, but safer.
   They would need two constructors, as the zero-argument constructor will be 
needed to identify the schema
   
   Alternativly perform an identity comparison after calling this method. Would 
mean default method would perform a reflection creation which I don't 
paticually like.
   



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