jrmccluskey commented on code in PR #35752:
URL: https://github.com/apache/beam/pull/35752#discussion_r2246072603


##########
sdks/java/core/src/main/java/org/apache/beam/sdk/schemas/FromRowUsingCreator.java:
##########
@@ -102,11 +102,17 @@ public T apply(Row row) {
     return (T) creator.create(params);
   }
 
-  private synchronized void initFieldConverters(Schema schema) {
+   private synchronized void initFieldConverters(Schema schema) {
+    Function[] value = fieldConverters;
     if (fieldConverters == null) {
-      CachingFactory<List<FieldValueTypeInformation>> typeFactory =
-          new CachingFactory<>(schemaProvider::fieldValueTypeInformations);
-      fieldConverters = fieldConverters(typeDescriptor, schema, typeFactory);
+      synchronized (this) {
+        value = fieldConverters;
+        if (fieldConverters == null) {
+          CachingFactory<List<FieldValueTypeInformation>> typeFactory =
+              new CachingFactory<>(schemaProvider::fieldValueTypeInformations);
+          fieldConverters = value = fieldConverters(typeDescriptor, schema, 
typeFactory);
+        }
+      }
     }
   }

Review Comment:
   weirdly getting data race errors in this function despite being marked as 
synchronized in its signature (which was resolved by the nested synchronized() 
call), will mess with it more to see if I can figure out why



-- 
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: github-unsubscr...@beam.apache.org

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

Reply via email to