Skip to content

Avoid using deprecated Log4j exception converter ctors #46372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vy
Copy link
Contributor

@vy vy commented Jul 9, 2025

Log4j 2.25.0 deprecated ThrowablePatternConverter ctors, where they are employed in Spring Boot's [Extended]WhitespaceThrowablePatternConverter – see apache/logging-log4j2#3809. This PR amends these classes to avoid using deprecated ctors.

@vy vy force-pushed the log4j2-converters-composition branch from 18f82d4 to b14948b Compare July 9, 2025 18:58
Copy link
Contributor

@ppkarwasz ppkarwasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, although the implementation could be further simplified.

@@ -34,24 +35,32 @@
*/
@Plugin(name = "ExtendedWhitespaceThrowablePatternConverter", category = PatternConverter.CATEGORY)
@ConverterKeys({ "xwEx", "xwThrowable", "xwException" })
public final class ExtendedWhitespaceThrowablePatternConverter extends ThrowablePatternConverter {
public final class ExtendedWhitespaceThrowablePatternConverter extends LogEventPatternConverter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit-pick: Since ExtendedWhitespaceThrowablePatternConverter and WhitespaceThrowablePatternConverter differ only in the specific LogEventPatternConverter they delegate to, the implementation can be simplified by:

  • Having one implemented in terms of the other, or
  • Taking advantage of the fact that pattern converters don’t need to directly implement LogEventPatternConverter, but only provide a public static LogEventPatternConverter newInstance() method, you could have both plugins return the same shared private implementation of LogEventPatternConverter, reducing duplication.

@vy
Copy link
Contributor Author

vy commented Jul 9, 2025

@snicoll, please let us know how you want to proceed with. I've tried to keep the changes minimal, though I can implement the improvements suggested by @ppkarwasz, if it is of your liking.

@snicoll snicoll added the for: team-attention An issue we'd like other members of the team to review label Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants