activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1489997 - /activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
Date Wed, 05 Jun 2013 18:41:58 GMT
Author: tabish
Date: Wed Jun  5 18:41:58 2013
New Revision: 1489997

URL: http://svn.apache.org/r1489997
Log:
Test fix, don't produce a StackOverflowException

Modified:
    activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java

Modified: activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java?rev=1489997&r1=1489996&r2=1489997&view=diff
==============================================================================
--- activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
(original)
+++ activemq/trunk/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ2902Test.java
Wed Jun  5 18:41:58 2013
@@ -17,10 +17,13 @@
 package org.apache.activemq.bugs;
 
 import java.util.concurrent.atomic.AtomicBoolean;
+
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.JMSException;
+
 import junit.framework.TestCase;
+
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.TransportConnection;
 import org.apache.activemq.transport.TransportDisposedIOException;
@@ -36,12 +39,18 @@ public class AMQ2902Test extends TestCas
 
     final AtomicBoolean gotExceptionInLog = new AtomicBoolean(Boolean.FALSE);
     final AtomicBoolean failedToFindMDC = new AtomicBoolean(Boolean.FALSE);
-    
+
     Appender appender = new DefaultTestAppender() {
         @Override
         public void doAppend(LoggingEvent event) {
             if (event.getThrowableInformation() != null
                     && event.getThrowableInformation().getThrowable() instanceof
TransportDisposedIOException) {
+
+                // Prevent StackOverflowException so we can see a sane stack trace.
+                if (gotExceptionInLog.get()) {
+                    return;
+                }
+
                 LOG.error("got event: " + event + ", ex:" + event.getThrowableInformation().getThrowable(),
event.getThrowableInformation().getThrowable());
                 gotExceptionInLog.set(Boolean.TRUE);
             }
@@ -70,6 +79,7 @@ public class AMQ2902Test extends TestCas
         connection.close();
     }
 
+    @Override
     public void setUp() throws Exception {
         gotExceptionInLog.set(Boolean.FALSE);
         failedToFindMDC.set(Boolean.FALSE);
@@ -78,6 +88,7 @@ public class AMQ2902Test extends TestCas
         Logger.getLogger(TransportConnection.class.getName()).setLevel(Level.DEBUG);
     }
 
+    @Override
     public void tearDown() throws Exception {
         Logger.getRootLogger().removeAppender(appender);
         assertFalse("got unexpected ex in log on graceful close", gotExceptionInLog.get());



Mime
View raw message