Repository: logging-log4j2 Updated Branches: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure d3d4d7dd9 -> b842432cd
LOG4J2-1527 Prevent NPE in RingBufferLogEvent.getFormattedMessage() when used in web applications. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/b842432c Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/b842432c Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/b842432c Branch: refs/heads/LOG4J2-1010&LOG4J2-1447-injectable-contextdata&better-datastructure Commit: b842432cd8ef81d62d047afdbc0212763432be30 Parents: d3d4d7d Author: rpopma <[email protected]> Authored: Sat Aug 20 11:01:04 2016 +0900 Committer: rpopma <[email protected]> Committed: Sat Aug 20 11:01:04 2016 +0900 ---------------------------------------------------------------------- .../logging/log4j/core/async/RingBufferLogEventTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/b842432c/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java index 12235d1..38370d1 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java @@ -170,4 +170,14 @@ public class RingBufferLogEventTest { assertEquals(evt.getSource(), actual.getSource()); assertEquals(evt.getThrownProxy(), actual.getThrownProxy()); } + + @Test + public void testMessageTextNeverThrowsNpe() { + final RingBufferLogEvent evt = new RingBufferLogEvent(); + try { + evt.getFormattedMessage(); + } catch (NullPointerException e) { + fail("the messageText field was not set"); + } + } }
