rdblue 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_r294026110
########## 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: You're right. It's still safe, but two threads may initialize the variable. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org