fix: Pattern Layout throwable use Throwable.toString()#4033
fix: Pattern Layout throwable use Throwable.toString()#4033JongminChung wants to merge 2 commits intoapache:2.xfrom
Conversation
log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/ThrowableStackTraceRenderer.java
Show resolved
Hide resolved
|
Hi, @vy Would love to get your eyes on this when you get a moment. |
vy
left a comment
There was a problem hiding this comment.
Could you add a changelog entry and make sure ./mvnw verify -pl :log4j-core,:log4j-core-test passes, please?
| return convert(pattern, EXCEPTION); | ||
| } | ||
|
|
||
| static String convert(final String pattern, final Throwable throwable) { |
There was a problem hiding this comment.
This can't be private since it's accessed from other classes within the same package.
(Link)
| } | ||
| } | ||
|
|
||
| private static final class CustomException extends Exception { |
There was a problem hiding this comment.
Could you implement the following changes, please?
- Rename this to
ToStringOverridingException - Use
super(EXCEPTION)in ctor, and receive no arguments - Create
ToStringOverridingException.INSTANCEfield and use it (similar toTestFriendlyException.INSTANCE) - Return a constant in
toString(), e.g.,return "foo"
There was a problem hiding this comment.
Thanks for the review, @vy! I've applied all your suggestions:
- Renamed to ToStringOverridingException
- Changed constructor to use super(EXCEPTION) with no arguments
- Added ToStringOverridingException.INSTANCE static field (following TestFriendlyException.INSTANCE pattern)
- toString() now returns a constant ("foo")
|
Could you replace the entire |
Signed-off-by: Jongmin Chung <chungjm0711@gmail.com>
Signed-off-by: Jongmin Chung <chungjm0711@gmail.com>
a5a2c82 to
16eb60b
Compare
As this is my first PR, I wanted to provide more background context. I've shortened it now. |
Align renderThrowableMessage(...) to use Throwable.toString(), restoring the default printStackTrace() behavior documented for the %ex converter.
%expattern andexceptionJTL resolver #3623.Checklist
2.xbranch if you are targeting Log4j 2; usemainotherwise./mvnw verifysucceeds (the build instructions)src/changelog/.2.x.xdirectory