diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f7b68a..42fabb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Backtrace Java Release Notes +## Version 0.9.1 - 14.04.2020 +- Filter out stack traces from 'org.apache.log4j' and 'org.apache.logging' + ## Version 0.9.0 - 23.03.2020 -- First release. \ No newline at end of file +- First release. diff --git a/README.md b/README.md index d6a365b..580d504 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ * Gradle ``` dependencies { - implementation 'com.github.backtrace-labs.backtrace-java:backtrace-java:0.9.0' + implementation 'com.github.backtrace-labs.backtrace-java:backtrace-java:0.9.1' } ``` @@ -25,11 +25,11 @@ dependencies { com.github.backtrace-labs.backtrace-java backtrace-java - 0.9.0 + 0.9.1 ``` -# Using Backtrace library +# Using Backtrace library ## Initialize a new BacktraceClient First create a `BacktraceConfig` instance with your `Backtrace endpoint URL`. This endpoint URL will either be through a central https://submit.backtrace.io server on standard port 80/443, or directly to your Backtrace instance through a listener on port 6097/6098 (e.g. https://xxx.sp.backtrace.io:6098). Either integration will require a submission token to be included in the endpoint diff --git a/build.gradle b/build.gradle index 13ec060..b92cac1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { apply from: 'publish.gradle' group = 'com.github.backtrace.io' -version = '0.9.0' +version = '0.9.1' repositories { jcenter() diff --git a/gradle.properties b/gradle.properties index 43c0ee5..3a6345b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.9.0 +VERSION_NAME=0.9.1 GROUP=com.github.backtrace-labs.backtrace-java diff --git a/src/main/java/backtrace/io/data/report/BacktraceStackTrace.java b/src/main/java/backtrace/io/data/report/BacktraceStackTrace.java index fc6ba97..6e09950 100644 --- a/src/main/java/backtrace/io/data/report/BacktraceStackTrace.java +++ b/src/main/java/backtrace/io/data/report/BacktraceStackTrace.java @@ -51,8 +51,18 @@ private ArrayList gatherStacktraceInformation() { ArrayList result = new ArrayList<>(); for (StackTraceElement frame : stackTraceElements) { - if ((frame == null) || (!frame.getClassName().isEmpty() && frame.getClassName().toLowerCase().startsWith(NAME)) || - (frame.getClassName().toLowerCase().equals("java.lang.thread") && frame.getMethodName().equals("getStackTrace"))) { + if ( + (frame == null) || + (!frame.getClassName().isEmpty() && ( + frame.getClassName().toLowerCase().startsWith(NAME) || + frame.getClassName().toLowerCase().startsWith("org.apache.log4j") || + frame.getClassName().toLowerCase().startsWith("org.apache.logging"))) + || + ( + frame.getClassName().toLowerCase().equals("java.lang.thread") && + frame.getMethodName().equals("getStackTrace") + ) + ) { continue; } result.add(new BacktraceStackFrame(frame)); diff --git a/src/test/java/backtrace/io/CustomEventsTest.java b/src/test/java/backtrace/io/CustomEventsTest.java index 3f7338f..4e1c90a 100644 --- a/src/test/java/backtrace/io/CustomEventsTest.java +++ b/src/test/java/backtrace/io/CustomEventsTest.java @@ -64,6 +64,7 @@ public BacktraceResult onRequest(BacktraceData data) { // THEN try { backtraceClient.await(1, TimeUnit.SECONDS); + backtraceClient.close(); } catch (Exception e) { Assert.fail(e.getMessage()); } @@ -99,6 +100,7 @@ public void onEvent(BacktraceResult backtraceResult) { // THEN try { waiter.await(1, TimeUnit.SECONDS); + backtraceClient.close(); } catch (Exception e) { Assert.fail(e.getMessage()); } @@ -196,6 +198,7 @@ public BacktraceResult onRequest(BacktraceData data) { // THEN try{ boolean result = backtraceClient.await(2, TimeUnit.SECONDS); + backtraceClient.close(); Assert.assertFalse(result); } catch (Exception e){ @@ -225,6 +228,7 @@ public BacktraceResult onRequest(BacktraceData data) { // THEN try { backtraceClient.await(); + backtraceClient.close(); } catch (Exception e) { Assert.fail(e.getMessage()); } @@ -259,6 +263,7 @@ public BacktraceResult onRequest(BacktraceData data) { // THEN try { backtraceClient.await(); + backtraceClient.close(); } catch (Exception e) { Assert.fail(e.getMessage()); } @@ -269,7 +274,7 @@ public BacktraceResult onRequest(BacktraceData data) { } @Test - public void sendRequestWithAppVersionAndName() { + public void sendRequestWithAppVersionAndName() throws InterruptedException { // GIVEN BacktraceReport report = new BacktraceReport(message); String appVersion = "release-1.0"; @@ -296,6 +301,7 @@ public BacktraceResult onRequest(BacktraceData data) { try { waiter.await(5, TimeUnit.SECONDS); + backtraceClient.close(); } catch (Exception exception) { waiter.fail(exception); } diff --git a/src/test/java/backtrace/io/StackTraceTest.java b/src/test/java/backtrace/io/StackTraceTest.java index f489460..172c44f 100644 --- a/src/test/java/backtrace/io/StackTraceTest.java +++ b/src/test/java/backtrace/io/StackTraceTest.java @@ -23,6 +23,40 @@ public void removeIncorrectPathsFromNull() { BacktraceStackTrace backtraceStackTrace = new BacktraceStackTrace(testException); // THEN - Assert.assertEquals(backtraceStackTrace.getStackFrames().size(), 1); + Assert.assertEquals(1, backtraceStackTrace.getStackFrames().size()); + } + + @Test + public void removeApacheLog4jLogs() { + // GIVEN + final String declaringClass = "Demo"; + Exception testException = new Exception(); + StackTraceElement[] stackTraceElements = new StackTraceElement[2]; + stackTraceElements[0] = new StackTraceElement("org.apache.log4j.AppenderSkeleton", "doAppend", "AppenderSkeleton.java", 1); + stackTraceElements[1] = new StackTraceElement("Demo", "test", "test", 1); + testException.setStackTrace(stackTraceElements); + + // WHEN + BacktraceStackTrace backtraceStackTrace = new BacktraceStackTrace(testException); + + // THEN + Assert.assertEquals(1, backtraceStackTrace.getStackFrames().size()); + } + + @Test + public void removeApacheLog4j2Logs() { + // GIVEN + final String declaringClass = "Demo"; + Exception testException = new Exception(); + StackTraceElement[] stackTraceElements = new StackTraceElement[2]; + stackTraceElements[0] = new StackTraceElement("org.apache.logging.log4j.core.config.AppenderControl", "tryCallAppender", "AppenderControl.java", 1); + stackTraceElements[1] = new StackTraceElement("Demo", "test", "test", 1); + testException.setStackTrace(stackTraceElements); + + // WHEN + BacktraceStackTrace backtraceStackTrace = new BacktraceStackTrace(testException); + + // THEN + Assert.assertEquals(1, backtraceStackTrace.getStackFrames().size()); } }