Sfoglia il codice sorgente

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 anni fa
parent
commit
ec0ff8da86

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

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