You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/05/11 02:08:24 UTC

[GitHub] [hudi] vinothchandar commented on a change in pull request #2819: [HUDI-1794] Moved static COMMIT_FORMATTER to thread local variable as SimpleDateFormat is not thread safe.

vinothchandar commented on a change in pull request #2819:
URL: https://github.com/apache/hudi/pull/2819#discussion_r629798021



##########
File path: hudi-common/src/main/java/org/apache/hudi/common/table/timeline/HoodieActiveTimeline.java
##########
@@ -73,6 +71,16 @@
   private static final Logger LOG = LogManager.getLogger(HoodieActiveTimeline.class);
   protected HoodieTableMetaClient metaClient;
   private static AtomicReference<String> lastInstantTime = new AtomicReference<>(String.valueOf(Integer.MIN_VALUE));
+  private static ThreadLocal<SimpleDateFormat> commitFormatHolder = new ThreadLocal<SimpleDateFormat>() {

Review comment:
       yes. we can make a `LocalDate` from `Date` easily. (https://www.baeldung.com/java-date-to-localdate-and-localdatetime) 
   
   +1 on the new static method. In fact, we can even have a separate class `HoodieInstantTimeGenerator` and keep an singleton instance in HoodieActiveTimeline. We can then add methods to `HoodieInstantTimeGenerator` as needed. 
   
   




-- 
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