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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new a63c9333e9 Correct padding, protect against (unlikely) null
a63c9333e9 is described below

commit a63c9333e91eceeaed128d4636ab9e55fb169a80
Author: Christopher Schultz <[email protected]>
AuthorDate: Wed May 20 16:46:07 2026 -0400

    Correct padding, protect against (unlikely) null
---
 java/org/apache/juli/JdkLoggerFormatter.java | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/juli/JdkLoggerFormatter.java 
b/java/org/apache/juli/JdkLoggerFormatter.java
index 8f73c985f6..2c8c106532 100644
--- a/java/org/apache/juli/JdkLoggerFormatter.java
+++ b/java/org/apache/juli/JdkLoggerFormatter.java
@@ -73,18 +73,21 @@ public class JdkLoggerFormatter extends Formatter {
         long time = record.getMillis();
         String message = formatMessage(record);
 
-
+        if (name == null) {
+            name = "";
+        }
         if (name.indexOf('.') >= 0) {
             name = name.substring(name.lastIndexOf('.') + 1);
         }
 
         // Use a string buffer for better performance
+        String timeStr = String.valueOf(time);
         StringBuilder buf = new StringBuilder();
 
-        buf.append(time);
+        buf.append(timeStr);
 
         // pad to 8 to make it more readable
-        buf.append(" ".repeat(Math.max(0, 8 - buf.length())));
+        buf.append(" ".repeat(Math.max(0, 8 - timeStr.length())));
 
         // Append a readable representation of the log level.
         switch (level) {
@@ -108,13 +111,12 @@ public class JdkLoggerFormatter extends Formatter {
                 buf.append("   ");
         }
 
-
         // Append the name of the log instance if so configured
         buf.append(name);
         buf.append(' ');
 
         // pad to 20 chars
-        buf.append(" ".repeat(Math.max(0, 8 - buf.length())));
+        buf.append(" ".repeat(Math.max(0, 20 - (name.length() + 1))));
 
         // Append the message
         buf.append(LogUtil.escape(message));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to