danny0405 commented on code in PR #18967:
URL: https://github.com/apache/hudi/pull/18967#discussion_r3392755692
##########
hudi-common/src/main/java/org/apache/hudi/common/schema/HoodieSchema.java:
##########
@@ -1152,10 +1154,17 @@ public List<HoodieSchemaField> getFields() {
if (!hasFields()) {
throw new IllegalStateException("Cannot get fields from schema type: " +
type);
}
- if (fields == null) {
- fields =
Collections.unmodifiableList(avroSchema.getFields().stream().map(HoodieSchemaField::new).collect(Collectors.toList()));
+ List<HoodieSchemaField> localFields = fields;
+ if (localFields == null) {
+ synchronized (this) {
+ localFields = fields;
+ if (localFields == null) {
+ localFields =
Collections.unmodifiableList(avroSchema.getFields().stream().map(HoodieSchemaField::new).collect(Collectors.toList()));
Review Comment:
can we get rid of the local variables here? since it is unmodifiable, they
are safe to expose to callers.
--
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]