camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [4/4] camel git commit: CAMEL-10409 Polish the BaseNettyTest to write some useful information of memory leak
Date Tue, 15 Nov 2016 09:09:50 GMT
CAMEL-10409 Polish the BaseNettyTest to write some useful information of memory leak


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f5dccb88
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f5dccb88
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f5dccb88

Branch: refs/heads/master
Commit: f5dccb88037dbfc0dcb167afde122538ad6c6e68
Parents: e56cc97
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Tue Nov 15 17:01:26 2016 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Tue Nov 15 17:06:46 2016 +0800

----------------------------------------------------------------------
 .../apache/camel/component/netty4/http/BaseNettyTest.java   | 9 +++++++++
 .../org/apache/camel/component/netty4/BaseNettyTest.java    | 9 +++++++++
 2 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f5dccb88/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/BaseNettyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/BaseNettyTest.java
b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/BaseNettyTest.java
index 75916e5..92788f9 100644
--- a/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/BaseNettyTest.java
+++ b/components/camel-netty4-http/src/test/java/org/apache/camel/component/netty4/http/BaseNettyTest.java
@@ -33,11 +33,15 @@ import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.logging.log4j.core.LogEvent;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  *
  */
 public class BaseNettyTest extends CamelTestSupport {
+    protected static final Logger LOG = LoggerFactory.getLogger(BaseNettyTest.class);
+
     private static volatile int port;
 
     @BeforeClass
@@ -73,6 +77,7 @@ public class BaseNettyTest extends CamelTestSupport {
     @BeforeClass
     public static void startLeakDetection() {
         System.setProperty("io.netty.leakDetection.maxRecords", "100");
+        System.setProperty("io.netty.leakDetection.acquireAndReleaseOnly", "true");
         ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
     }
 
@@ -85,6 +90,10 @@ public class BaseNettyTest extends CamelTestSupport {
         Collection<LogEvent> events = LogCaptureAppender.getEvents();
         if (!events.isEmpty()) {
             String message = "Leaks detected while running tests: " + events;
+            // Just write the message into log to help debug
+            for(LogEvent event: events) {
+                LOG.info(event.getMessage().getFormattedMessage());
+            }
             LogCaptureAppender.reset();
             throw new AssertionError(message);
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/f5dccb88/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/BaseNettyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/BaseNettyTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/BaseNettyTest.java
index aeb5378..3bd1431 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/BaseNettyTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/BaseNettyTest.java
@@ -30,6 +30,8 @@ import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.logging.log4j.core.LogEvent;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import io.netty.buffer.ByteBufAllocator;
 import io.netty.util.ResourceLeakDetector;
@@ -38,6 +40,8 @@ import io.netty.util.ResourceLeakDetector;
  *
  */
 public class BaseNettyTest extends CamelTestSupport {
+    protected static final Logger LOG = LoggerFactory.getLogger(BaseNettyTest.class);
+
     private static volatile int port;
 
     @BeforeClass
@@ -73,6 +77,7 @@ public class BaseNettyTest extends CamelTestSupport {
     @BeforeClass
     public static void startLeakDetection() {
         System.setProperty("io.netty.leakDetection.maxRecords", "100");
+        System.setProperty("io.netty.leakDetection.acquireAndReleaseOnly", "true");
         ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
     }
 
@@ -85,6 +90,10 @@ public class BaseNettyTest extends CamelTestSupport {
         Collection<LogEvent> events = LogCaptureAppender.getEvents();
         if (!events.isEmpty()) {
             String message = "Leaks detected while running tests: " + events;
+            // Just write the message into log to help debug
+            for(LogEvent event: events) {
+                LOG.info(event.getMessage().getFormattedMessage());
+            }
             LogCaptureAppender.reset();
             throw new AssertionError(message);
         }


Mime
View raw message