amogh-jahagirdar commented on code in PR #6857:
URL: https://github.com/apache/iceberg/pull/6857#discussion_r1112205845


##########
aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3ObjectMapper.java:
##########
@@ -42,26 +43,24 @@
 
 public class S3ObjectMapper {
 
-  private static final JsonFactory FACTORY = new JsonFactory();
-  private static final ObjectMapper MAPPER = new ObjectMapper(FACTORY);
-  private static volatile boolean isInitialized = false;
+  private static final AtomicReference<ObjectMapper> REFERENCE = new 
AtomicReference<>();
 
   private S3ObjectMapper() {}
 
   static ObjectMapper mapper() {
-    if (!isInitialized) {
-      synchronized (S3ObjectMapper.class) {
-        if (!isInitialized) {
-          MAPPER.setVisibility(PropertyAccessor.FIELD, 
JsonAutoDetect.Visibility.ANY);
-          MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
-          
MAPPER.setPropertyNamingStrategy(PropertyNamingStrategies.KebabCaseStrategy.INSTANCE);
-          MAPPER.registerModule(initModule());
-          isInitialized = true;
-        }
-      }
+    if (null == REFERENCE.get()) {

Review Comment:
   Yeah I'm not super opinionated on this , just a preference I had to avoid 
thinking about `volatile` and encapsulate double locking into atomic reference. 
@nastra we can continue on https://github.com/apache/iceberg/pull/6835 as is, 
we don't need to block on this! we can leave this open in case others have 
opinions on it as well. cc @rdblue @jackye1995 



##########
aws/src/main/java/org/apache/iceberg/aws/s3/signer/S3ObjectMapper.java:
##########
@@ -42,26 +43,24 @@
 
 public class S3ObjectMapper {
 
-  private static final JsonFactory FACTORY = new JsonFactory();
-  private static final ObjectMapper MAPPER = new ObjectMapper(FACTORY);
-  private static volatile boolean isInitialized = false;
+  private static final AtomicReference<ObjectMapper> REFERENCE = new 
AtomicReference<>();
 
   private S3ObjectMapper() {}
 
   static ObjectMapper mapper() {
-    if (!isInitialized) {
-      synchronized (S3ObjectMapper.class) {
-        if (!isInitialized) {
-          MAPPER.setVisibility(PropertyAccessor.FIELD, 
JsonAutoDetect.Visibility.ANY);
-          MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
-          
MAPPER.setPropertyNamingStrategy(PropertyNamingStrategies.KebabCaseStrategy.INSTANCE);
-          MAPPER.registerModule(initModule());
-          isInitialized = true;
-        }
-      }
+    if (null == REFERENCE.get()) {

Review Comment:
   Yeah I'm not super opinionated on this , just a preference I had to avoid 
thinking about `volatile` and encapsulate double check locking into atomic 
reference. @nastra we can continue on 
https://github.com/apache/iceberg/pull/6835 as is, we don't need to block on 
this! we can leave this open in case others have opinions on it as well. cc 
@rdblue @jackye1995 



-- 
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: issues-unsubscr...@iceberg.apache.org

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


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

Reply via email to