This is an automated email from the ASF dual-hosted git repository.
ChristopherSchultz pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 3cb36be3e9 Correct padding, protect against (unlikely) null
3cb36be3e9 is described below
commit 3cb36be3e928ca458f8f40c4589675ad6a3d8aa5
Author: Christopher Schultz <[email protected]>
AuthorDate: Wed May 20 16:49:52 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 222cd908fb..c7dda5b772 100644
--- a/java/org/apache/juli/JdkLoggerFormatter.java
+++ b/java/org/apache/juli/JdkLoggerFormatter.java
@@ -73,18 +73,20 @@ public class JdkLoggerFormatter extends Formatter {
long time = record.getMillis();
String message = formatMessage(record);
-
+ if (null == name) {
+ 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
- for (int i = 0; i < 8 - buf.length(); i++) {
+ for (int i = 0; i < 8 - timeStr.length(); i++) {
buf.append(' ');
}
@@ -116,7 +118,7 @@ public class JdkLoggerFormatter extends Formatter {
buf.append(' ');
// pad to 20 chars
- for (int i = 0; i < 8 - buf.length(); i++) {
+ for (int i = 0; i < 20 - (name.length() + 1); i++) {
buf.append(' ');
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]