You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by sc...@apache.org on 2025/09/29 17:42:52 UTC

(tomcat) branch 10.1.x updated (af6e918162 -> 589fd9c23a)

This is an automated email from the ASF dual-hosted git repository.

schultz pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


    from af6e918162 Explicitly clean up after failed multi-part upload
     new b7b34f5d87 Add changelog
     new 589fd9c23a refactor: formatter refactoring

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 java/org/apache/juli/JsonFormatter.java    |  9 +--------
 java/org/apache/juli/OneLineFormatter.java | 28 ++++++++++++++++------------
 webapps/docs/changelog.xml                 |  3 +++
 3 files changed, 20 insertions(+), 20 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


(tomcat) 01/02: Add changelog

Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

schultz pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b7b34f5d8737459bea370f8e7a90e60f8e4562ee
Author: Christopher Schultz <ch...@christopherschultz.net>
AuthorDate: Mon Sep 29 13:32:08 2025 -0400

    Add changelog
---
 webapps/docs/changelog.xml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e3b88a38a2..cf9a7bec30 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -196,6 +196,9 @@
       <add>
         Improvements to Japanese translations provided by tak7iji. (markt)
       </add>
+      <update>
+        Minor refactoring in JULI loggers. Patch provided by minjund. (schultz)
+      </update>
     </changelog>
   </subsection>
 </section>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


(tomcat) 02/02: refactor: formatter refactoring

Posted by sc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

schultz pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 589fd9c23af4bf1a613faa98bfadc0f20297ab35
Author: minjund <ma...@naver.com>
AuthorDate: Fri Sep 26 00:17:34 2025 +0900

    refactor: formatter refactoring
---
 java/org/apache/juli/JsonFormatter.java    |  9 +--------
 java/org/apache/juli/OneLineFormatter.java | 28 ++++++++++++++++------------
 2 files changed, 17 insertions(+), 20 deletions(-)

diff --git a/java/org/apache/juli/JsonFormatter.java b/java/org/apache/juli/JsonFormatter.java
index c2ad5382e1..7667193b1d 100644
--- a/java/org/apache/juli/JsonFormatter.java
+++ b/java/org/apache/juli/JsonFormatter.java
@@ -65,14 +65,7 @@ public class JsonFormatter extends OneLineFormatter {
 
         // Thread
         sb.append("\"thread\": \"");
-        final String threadName = Thread.currentThread().getName();
-        if (threadName != null && threadName.startsWith(AsyncFileHandler.THREAD_PREFIX)) {
-            // If using the async handler can't get the thread name from the
-            // current thread.
-            sb.append(getThreadName(record.getThreadID()));
-        } else {
-            sb.append(threadName);
-        }
+        sb.append(resolveThreadName(record));
         sb.append("\", ");
 
         // Source
diff --git a/java/org/apache/juli/OneLineFormatter.java b/java/org/apache/juli/OneLineFormatter.java
index a6fa4eba39..57062d0a4e 100644
--- a/java/org/apache/juli/OneLineFormatter.java
+++ b/java/org/apache/juli/OneLineFormatter.java
@@ -51,12 +51,12 @@ public class OneLineFormatter extends Formatter {
     /**
      * The size of our global date format cache
      */
-    private static final int globalCacheSize = 30;
+    private static final int GLOBAL_CACHE_SIZE = 30;
 
     /**
      * The size of our thread local date format cache
      */
-    private static final int localCacheSize = 5;
+    private static final int LOCAL_CACHE_SIZE = 5;
 
     /**
      * Thread local date format cache.
@@ -100,9 +100,9 @@ public class OneLineFormatter extends Formatter {
             cachedTimeFormat = timeFormat;
         }
 
-        final DateFormatCache globalDateCache = new DateFormatCache(globalCacheSize, cachedTimeFormat, null);
+        final DateFormatCache globalDateCache = new DateFormatCache(GLOBAL_CACHE_SIZE, cachedTimeFormat, null);
         localDateCache =
-                ThreadLocal.withInitial(() -> new DateFormatCache(localCacheSize, cachedTimeFormat, globalDateCache));
+                ThreadLocal.withInitial(() -> new DateFormatCache(LOCAL_CACHE_SIZE, cachedTimeFormat, globalDateCache));
     }
 
 
@@ -130,14 +130,7 @@ public class OneLineFormatter extends Formatter {
         // Thread
         sb.append(' ');
         sb.append('[');
-        final String threadName = Thread.currentThread().getName();
-        if (threadName != null && threadName.startsWith(AsyncFileHandler.THREAD_PREFIX)) {
-            // If using the async handler can't get the thread name from the
-            // current thread.
-            sb.append(getThreadName(record.getThreadID()));
-        } else {
-            sb.append(threadName);
-        }
+        sb.append(resolveThreadName(record));
         sb.append(']');
 
         // Source
@@ -165,6 +158,17 @@ public class OneLineFormatter extends Formatter {
         return sb.toString();
     }
 
+    protected String resolveThreadName(LogRecord record) {
+        final String threadName = Thread.currentThread().getName();
+        if (threadName != null && threadName.startsWith(AsyncFileHandler.THREAD_PREFIX)) {
+            // If using the async handler can't get the thread name from the
+            // current thread.
+            return getThreadName(record.getThreadID());
+        } else {
+            return threadName;
+        }
+    }
+
     protected void addTimestamp(StringBuilder buf, long timestamp) {
         String cachedTimeStamp = localDateCache.get().getFormat(timestamp);
         if (millisHandling == MillisHandling.NONE) {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org