Repository: logging-log4j2 Updated Branches: refs/heads/master 958c78526 -> 0db4a578f
Adding a test for [LOG4J2-834] NoClassDefFoundError in ThrowableProxy. This is already fixed but we show with this test that the use case from the JIRA is handled. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0db4a578 Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0db4a578 Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0db4a578 Branch: refs/heads/master Commit: 0db4a578fc01253c42d7b965d2dda47a5c87edbc Parents: 958c785 Author: Gary Gregory <[email protected]> Authored: Sat Nov 29 12:34:13 2014 -0500 Committer: Gary Gregory <[email protected]> Committed: Sat Nov 29 12:34:13 2014 -0500 ---------------------------------------------------------------------- .../log4j/core/impl/ThrowableProxyTest.java | 21 +++++++++++++++++++ .../core/impl/ForceNoDefClassFoundError.class | Bin 0 -> 1309 bytes src/changes/changes.xml | 3 +++ 3 files changed, 24 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0db4a578/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java index 3956c62..fbcb87d 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/impl/ThrowableProxyTest.java @@ -168,4 +168,25 @@ public class ThrowableProxyTest { throwable.getStackTrace()); assertNotNull("No package data returned", callerPackageData); } + + /** + * Asserts that LOG4J2-834 is solved by constructing a ThrowableProxy over a RuntimeException object thrown at a + * unloaded known class (already compiled and available as a test resource: + * org.apache.logging.log4j.core.impl.ForceNoDefClassFoundError.class). + */ + @Test + public void testStackWithUnloadableClass() throws Exception { + final Stack<Class<?>> stack = new Stack<Class<?>>(); + final Map<String, ThrowableProxy.CacheEntry> map = new HashMap<String, ThrowableProxy.CacheEntry>(); + + final String runtimeExceptionThrownAtUnloadableClass_base64 = "rO0ABXNyABpqYXZhLmxhbmcuUnVudGltZUV4Y2VwdGlvbp5fBkcKNIPlAgAAeHIAE2phdmEubGFuZy5FeGNlcHRpb27Q/R8+GjscxAIAAHhyABNqYXZhLmxhbmcuVGhyb3dhYmxl1cY1Jzl3uMsDAANMAAVjYXVzZXQAFUxqYXZhL2xhbmcvVGhyb3dhYmxlO0wADWRldGFpbE1lc3NhZ2V0ABJMamF2YS9sYW5nL1N0cmluZztbAApzdGFja1RyYWNldAAeW0xqYXZhL2xhbmcvU3RhY2tUcmFjZUVsZW1lbnQ7eHBxAH4ABnB1cgAeW0xqYXZhLmxhbmcuU3RhY2tUcmFjZUVsZW1lbnQ7AkYqPDz9IjkCAAB4cAAAAAFzcgAbamF2YS5sYW5nLlN0YWNrVHJhY2VFbGVtZW50YQnFmiY23YUCAARJAApsaW5lTnVtYmVyTAAOZGVjbGFyaW5nQ2xhc3NxAH4ABEwACGZpbGVOYW1lcQB+AARMAAptZXRob2ROYW1lcQB+AAR4cAAAAAZ0ADxvcmcuYXBhY2hlLmxvZ2dpbmcubG9nNGouY29yZS5pbXBsLkZvcmNlTm9EZWZDbGFzc0ZvdW5kRXJyb3J0AB5Gb3JjZU5vRGVmQ2xhc3NGb3VuZEVycm9yLmphdmF0AARtYWlueA=="; + final byte[] binaryDecoded = DatatypeConverter + .parseBase64Binary(runtimeExceptionThrownAtUnloadableClass_base64); + final ByteArrayInputStream inArr = new ByteArrayInputStream(binaryDecoded); + final ObjectInputStream in = new ObjectInputStream(inArr); + final Throwable throwable = (Throwable) in.readObject(); + final ThrowableProxy subject = new ThrowableProxy(throwable); + + subject.toExtendedStackTrace(stack, map, null, throwable.getStackTrace()); + } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0db4a578/log4j-core/src/test/resources/org/apache/logging/log4j/core/impl/ForceNoDefClassFoundError.class ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/resources/org/apache/logging/log4j/core/impl/ForceNoDefClassFoundError.class b/log4j-core/src/test/resources/org/apache/logging/log4j/core/impl/ForceNoDefClassFoundError.class new file mode 100644 index 0000000..cb9b27a Binary files /dev/null and b/log4j-core/src/test/resources/org/apache/logging/log4j/core/impl/ForceNoDefClassFoundError.class differ http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0db4a578/src/changes/changes.xml ---------------------------------------------------------------------- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 54fa2ab..1f884b9 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -35,6 +35,9 @@ <action issue="LOG4J2-903" dev="ggregory" type="fix" due-to="Mauro Molinari"> ClassLoaderContextSelector uses ClassLoader.toString() as a key </action> + <action issue="LOG4J2-834" dev="ggregory" type="fix"> + NoClassDefFoundError in ThrowableProxy. + </action> <action issue="LOG4J2-893" dev="ggregory" type="fix"> NullPointerException on filter when mapping JUL to Log4j2. </action>
