Skip to content
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

NullPointerException in PatternLayoutBase#caterForLegacyConverterMaps #929

Open
hisener opened this issue Mar 21, 2025 · 0 comments
Open

Comments

@hisener
Copy link

hisener commented Mar 21, 2025

With Logback 1.5.14+, we started getting NullPointerException in PatternLayoutBase. I don't have a reproducer right now, and we might be holding it wrong, but it looks like it is accessing a nullable field, so I thought I would report it.

java.lang.NullPointerException: 
	at ch.qos.logback.core.pattern.PatternLayoutBase.caterForLegacyConverterMaps(PatternLayoutBase.java:109)
	at ch.qos.logback.core.pattern.PatternLayoutBase.getEffectiveConverterMap(PatternLayoutBase.java:84)
	at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:143)

This is related to d4804f9. PatternLayoutBase#caterForLegacyConverterMaps calls this.context.getObject.

private void caterForLegacyConverterMaps(Map<String, Supplier<DynamicConverter>> effectiveMap) {
Map<String, String> mapFromContext = (Map<String, String>) this.context
.getObject(CoreConstants.PATTERN_RULE_REGISTRY);

However, this.context is nullable. See also the null check after that #caterForLegacyConverterMaps method call

caterForLegacyConverterMaps(effectiveMap);
// contextMap is more specific than the default map
Context context = getContext();
if (context != null) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant