PIT-Lücken in bootstrap gezielt geschlossen
This commit is contained in:
+3
-8
@@ -83,14 +83,9 @@ public class Log4jProcessingLogger implements ProcessingLogger {
|
||||
|
||||
@Override
|
||||
public void error(String message, Object... args) {
|
||||
// If the last argument is a Throwable, extract it and pass separately
|
||||
if (args.length > 0 && args[args.length - 1] instanceof Throwable throwable) {
|
||||
Object[] messageArgs = new Object[args.length - 1];
|
||||
System.arraycopy(args, 0, messageArgs, 0, args.length - 1);
|
||||
log4jLogger.error(message, throwable, messageArgs);
|
||||
} else {
|
||||
log4jLogger.error(message, args);
|
||||
}
|
||||
// Log4j2 detects a trailing Throwable in the params array automatically:
|
||||
// it uses it as the log cause and formats only the preceding arguments.
|
||||
log4jLogger.error(message, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user