Skip to content

Conversation

@SiegfriedTobias1
Copy link
Contributor

PR for https://issues.apache.org/jira/browse/LOG4J2-2939
Accomodate for the fact that MDC.getCopyOfContextMap() may return null.

Accomodate for the fact that MDC.getCopyOfContextMap() may return null
Copy link
Contributor

@carterkozak carterkozak left a comment

Choose a reason for hiding this comment

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

Thanks, the change looks good. Would you mind adding a test that fails without the fix to prevent regressions?

@carterkozak
Copy link
Contributor

Thanks! I'll handle the merge and cherry-pick to relevant release branches.

@SiegfriedTobias1
Copy link
Contributor Author

SiegfriedTobias1 commented Oct 5, 2020

Thank you very much!

assertNull("Setup wrong", MDC.getCopyOfContextMap());
assertTrue(ThreadContext.isEmpty());
assertFalse(ThreadContext.containsKey("something"));
}
Copy link
Member

Choose a reason for hiding this comment

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

I would separate these into two tests, one for each API.

Copy link
Member

Choose a reason for hiding this comment

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

An edge case worth testing IMO is getting a null key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the feedback! I split the tests and added some tests concerning null keys.

@carterkozak carterkozak merged commit 7aef4f0 into apache:master Oct 6, 2020
carterkozak pushed a commit that referenced this pull request Oct 6, 2020
Accomodate for the fact that MDC.getCopyOfContextMap() may return 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

Successfully merging this pull request may close these issues.

3 participants