You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2019/06/15 00:00:17 UTC

[GitHub] [incubator-iceberg] rdsr commented on a change in pull request #219: Fix concurrent access to lazy PartitionSpec methods

rdsr commented on a change in pull request #219: Fix concurrent access to lazy PartitionSpec methods
URL: https://github.com/apache/incubator-iceberg/pull/219#discussion_r294024626
 
 

 ##########
 File path: api/src/main/java/org/apache/iceberg/PartitionSpec.java
 ##########
 @@ -118,12 +118,18 @@ public int specId() {
 
   public Class<?>[] javaClasses() {
     if (lazyJavaClasses == null) {
-      this.lazyJavaClasses = new Class<?>[fields.length];
-      for (int i = 0; i < fields.length; i += 1) {
-        PartitionField field = fields[i];
-        Type sourceType = schema.findType(field.sourceId());
-        Type result = field.transform().getResultType(sourceType);
-        lazyJavaClasses[i] = result.typeId().javaClass();
+      synchronized (this) {
+        if (lazyJavaClasses == null) {
 
 Review comment:
   I believe  for the double-check idiom to reliably work these fields need to be `volatile`
   http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org