mosche commented on code in PR #26320:
URL: https://github.com/apache/beam/pull/26320#discussion_r1219741664


##########
sdks/java/extensions/avro/src/test/java/org/apache/beam/sdk/extensions/avro/coders/AvroCoderTest.java:
##########
@@ -323,35 +314,71 @@ public void testKryoSerialization() throws Exception {
   @Test
   public void testPojoEncoding() throws Exception {
     Pojo value = new Pojo("Hello", 42, DATETIME_A);
-    AvroCoder<Pojo> coder = AvroCoder.of(Pojo.class);
+    AvroCoder<Pojo> coder = AvroCoder.reflect(Pojo.class);
 
     CoderProperties.coderDecodeEncodeEqual(coder, value);
   }
 
   @Test
   public void testSpecificRecordEncoding() throws Exception {
-    if (isBrokenMapComparison()) {
-      // Don't compare the map values because of AVRO-2943
-      AVRO_SPECIFIC_RECORD.setMap(ImmutableMap.of());
-    }
-    AvroCoder<TestAvro> coder =
-        AvroCoder.of(TestAvro.class, AVRO_SPECIFIC_RECORD.getSchema(), false);
+    // Don't compare the map values because of AVRO-2943
+    AVRO_SPECIFIC_RECORD.setMap(ImmutableMap.of());
+
+    AvroCoder<TestAvro> coder = AvroCoder.specific(TestAvro.class);
+    AvroCoder<TestAvro> coderWithSchema =
+        AvroCoder.specific(TestAvro.class, AVRO_SPECIFIC_RECORD.getSchema());
 
     assertTrue(SpecificRecord.class.isAssignableFrom(coder.getType()));
+    
assertTrue(SpecificRecord.class.isAssignableFrom(coderWithSchema.getType()));
+
     CoderProperties.coderDecodeEncodeEqual(coder, AVRO_SPECIFIC_RECORD);
+    CoderProperties.coderDecodeEncodeEqual(coderWithSchema, 
AVRO_SPECIFIC_RECORD);
   }
 
-  private boolean isBrokenMapComparison() {
-    return VERSION_AVRO.equals("1.9.2")
-        || VERSION_AVRO.equals("1.10.2")
-        || VERSION_AVRO.equals("1.11.1");
+  // example to overcome AVRO-2943 limitation with custom datum factory
+  // force usage of String instead of Utf8 when avro type is set to 
CharSequence
+  static class CustomSpecificDatumFactory<T> extends 
AvroDatumFactory.SpecificDatumFactory<T> {

Review Comment:
   Thanks 💯 



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