소스 검색

Using non-final variables to lock can cause thread-safety problems.According to my understanding, it is appropriate to add the final keyword here

paopaofish 5 년 전
부모
커밋
ec0ff8da86
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      xxl-job-core/src/main/java/com/xxl/job/core/util/DateUtil.java

+ 1 - 1
xxl-job-core/src/main/java/com/xxl/job/core/util/DateUtil.java

@@ -24,7 +24,7 @@ public class DateUtil {
     private static final String DATE_FORMAT = "yyyy-MM-dd";
     private static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
 
-    private static ThreadLocal<Map<String, DateFormat>> dateFormatThreadLocal = new ThreadLocal<Map<String, DateFormat>>();
+    private static final ThreadLocal<Map<String, DateFormat>> dateFormatThreadLocal = new ThreadLocal<Map<String, DateFormat>>();
     private static DateFormat getDateFormat(String pattern) {
         if (pattern==null || pattern.trim().length()==0) {
             throw new IllegalArgumentException("pattern cannot be empty.");