activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject activemq git commit: AMQ-5892 - remove default stack trace from service warn to debug level on async error; makes it consistent with transport logging
Date Thu, 16 Jul 2015 14:19:00 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 0cfd22591 -> b1ea29ed1


AMQ-5892 - remove default stack trace from service warn to debug level on async error; makes
it consistent with transport logging


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

Branch: refs/heads/master
Commit: b1ea29ed1485f2cd134f332511fa3c857d0c773f
Parents: 0cfd225
Author: gtully <gary.tully@gmail.com>
Authored: Thu Jul 16 15:17:55 2015 +0100
Committer: gtully <gary.tully@gmail.com>
Committed: Thu Jul 16 15:18:23 2015 +0100

----------------------------------------------------------------------
 .../activemq/broker/TransportConnection.java    |  6 ++-
 .../org/apache/activemq/bugs/AMQ3625Test.java   | 14 +++---
 .../activemq/security/SecurityJMXTest.java      | 47 ++++++++++++++++++++
 3 files changed, 57 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/b1ea29ed/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
index 84d2101..6a3d8d9 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/TransportConnection.java
@@ -309,7 +309,11 @@ public class TransportConnection implements Connection, Task, CommandVisitor
{
         } else if (!stopping.get() && !inServiceException) {
             inServiceException = true;
             try {
-                SERVICELOG.warn("Async error occurred: ", e);
+                if (SERVICELOG.isDebugEnabled()) {
+                    SERVICELOG.debug("Async error occurred: " + e, e);
+                } else {
+                    SERVICELOG.warn("Async error occurred: " + e);
+                }
                 ConnectionError ce = new ConnectionError();
                 ce.setException(e);
                 if (pendingStop) {

http://git-wip-us.apache.org/repos/asf/activemq/blob/b1ea29ed/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
index a386202..90a8833 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/bugs/AMQ3625Test.java
@@ -26,7 +26,6 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.io.File;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import static org.junit.Assert.assertFalse;
@@ -84,14 +83,11 @@ public class AMQ3625Test {
         Appender appender = new DefaultTestAppender() {
             @Override
             public void doAppend(LoggingEvent event) {
-                if (event.getThrowableInformation() != null) {
-                    Throwable t = event.getThrowableInformation().getThrowable();
-                    if (t instanceof SecurityException) {
-                        authenticationFailed.set(true);
-                    }
-                    if (t instanceof NullPointerException) {
-                        gotNPE.set(true);
-                    }
+                if (event.getMessage().toString().contains("java.lang.SecurityException"))
{
+                    authenticationFailed.set(true);
+                }
+                if (event.getMessage().toString().contains("NullPointerException")) {
+                    gotNPE.set(true);
                 }
             }
         };

http://git-wip-us.apache.org/repos/asf/activemq/blob/b1ea29ed/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
index 1222b3b..058a2eb 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/security/SecurityJMXTest.java
@@ -20,6 +20,8 @@ package org.apache.activemq.security;
 import java.net.URI;
 import java.util.HashMap;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
 
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
@@ -37,8 +39,14 @@ import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnection;
+import org.apache.activemq.broker.TransportConnector;
 import org.apache.activemq.broker.jmx.QueueViewMBean;
 import org.apache.activemq.command.ActiveMQQueue;
+import org.apache.activemq.transport.stomp.StompConnection;
+import org.apache.activemq.util.DefaultTestAppender;
+import org.apache.log4j.Appender;
+import org.apache.log4j.spi.LoggingEvent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,6 +66,45 @@ public class SecurityJMXTest extends TestCase {
         broker.stop();
     }
 
+    public void testDeniedViaStompNoStackTrace() throws Exception {
+        final AtomicBoolean gotExpected = new AtomicBoolean(false);
+        final AtomicReference<Object> stackTrace = new AtomicReference<Object>();
+
+        final Appender appender = new DefaultTestAppender() {
+            public void doAppend(LoggingEvent event) {
+                String message =  event.getMessage().toString();
+                if (message.contains("Async error occurred")) {
+                    gotExpected.set(true);
+                    stackTrace.set(event.getThrowableInformation());
+                }
+            }
+        };
+
+        final org.apache.log4j.Logger toVerify = org.apache.log4j.Logger.getLogger(TransportConnection.class.getName()
+ ".Service");
+
+        toVerify.addAppender(appender);
+
+        try {
+
+            TransportConnector stomp = broker.addConnector("stomp://localhost:0");
+            broker.startTransportConnector(stomp);
+            StompConnection stompConnection = new StompConnection();
+            stompConnection.open(stomp.getConnectUri().getHost(), stomp.getConnectUri().getPort());
+            stompConnection.connect("guest", "password");
+            // async sub
+            stompConnection.subscribe("/queue/USERS.Q");
+            stompConnection.receive(1000);
+            stompConnection.close();
+
+        } finally {
+            toVerify.removeAppender(appender);
+        }
+
+        assertTrue("Got async error:", gotExpected.get());
+        assertNull("No stack trace", stackTrace.get());
+    }
+
+
     public void testMoveMessages() throws Exception {
         JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1199/jmxrmi");
         JMXConnector connector = JMXConnectorFactory.connect(url, null);


Mime
View raw message