-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Description
Issue Description
Sentinel/sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/EagleEyeCoreUtils.java
Lines 142 to 148 in a524ab3
| private static final ThreadLocal<FastDateFormat> dateFmt = new ThreadLocal<FastDateFormat>() { | |
| @Override | |
| protected FastDateFormat initialValue() { | |
| return new FastDateFormat(); | |
| } | |
| }; | |
Sentinel/sentinel-core/src/main/java/com/alibaba/csp/sentinel/log/jul/CspFormatter.java
Lines 28 to 34 in a524ab3
| private final ThreadLocal<SimpleDateFormat> dateFormatThreadLocal = new ThreadLocal<SimpleDateFormat>() { | |
| @Override | |
| public SimpleDateFormat initialValue() { | |
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | |
| } | |
| }; | |
Sentinel/sentinel-core/src/main/java/com/alibaba/csp/sentinel/log/jul/DateFileLogHandler.java
Lines 36 to 42 in a524ab3
| private final ThreadLocal<SimpleDateFormat> dateFormatThreadLocal = new ThreadLocal<SimpleDateFormat>() { | |
| @Override | |
| public SimpleDateFormat initialValue() { | |
| return new SimpleDateFormat("yyyy-MM-dd"); | |
| } | |
| }; | |
代码中的ThreadLocal对Java21中的 virtual thread 并不友好。
而且从Java8开始已经推荐使用 java.time.format.DateTimeFormatter,这是一个 "This class is immutable and thread-safe." 的实现。
Describe your initial design
是否可以将这些地方换成 java.time.format.DateTimeFormatter?
如果可以的话,我愿意提PR
Metadata
Metadata
Assignees
Labels
No labels