Skip to content

Add null guard before setting context map in Pumper thread#3269

Merged
olamy merged 1 commit into
apache:masterfrom
daniel-mohedano:daniel.mohedano/pumper-npe
Feb 24, 2026
Merged

Add null guard before setting context map in Pumper thread#3269
olamy merged 1 commit into
apache:masterfrom
daniel-mohedano:daniel.mohedano/pumper-npe

Conversation

@daniel-mohedano
Copy link
Copy Markdown
Contributor

@daniel-mohedano daniel-mohedano commented Feb 23, 2026

Details

Improvement to #3241 with null guard before setting the context map in ThreadedStreamConsumer$Pumper. In the original PR, introduced in 3.5.5, the Pumper constructor captures the parent thread's MDC context map via MDC.getCopyOfContextMap(), and Pumper.run() restores it via MDC.setContextMap(parentThreadsMdcContextMap)

MDC.getCopyOfContextMap() is documented as able to return null values, while MDC.setContextMap() only supports nulled arguments since SLF4J version 2.0.0

When using an adapter conforming to a previous version (for example, Logback <1.4.2), this can cause an NPE, killing the Pumper daemon thread.

Checklist

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean install to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean install).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@olamy olamy added the bug Something isn't working label Feb 23, 2026
@olamy olamy modified the milestones: 3.5.6, 3.6.0.M1 Feb 24, 2026
@olamy olamy merged commit a948c09 into apache:master Feb 24, 2026
14 checks passed
olamy pushed a commit to olamy/maven-surefire that referenced this pull request Feb 24, 2026
olamy added a commit that referenced this pull request Feb 24, 2026
Co-authored-by: Daniel Mohedano <daniel.mohedano@datadoghq.com>
@slawekjaranowski slawekjaranowski modified the milestones: 3.5.6, 3.6.0.M2, 3.6.0.M1 Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants