activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r638886 - /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
Date Wed, 19 Mar 2008 15:48:44 GMT
Author: chirino
Date: Wed Mar 19 08:48:41 2008
New Revision: 638886

URL: http://svn.apache.org/viewvc?rev=638886&view=rev
Log:
Avoid generating additional exception after the first one reported.

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java?rev=638886&r1=638885&r2=638886&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/InactivityMonitor.java
Wed Mar 19 08:48:41 2008
@@ -50,7 +50,7 @@
 
     private final AtomicBoolean commandSent = new AtomicBoolean(false);
     private final AtomicBoolean inSend = new AtomicBoolean(false);
-    private final AtomicBoolean inactive = new AtomicBoolean(false);
+    private final AtomicBoolean failed = new AtomicBoolean(false);
 
     private final AtomicBoolean commandReceived = new AtomicBoolean(true);
     private final AtomicBoolean inReceive = new AtomicBoolean(false);
@@ -151,13 +151,13 @@
             return;
         }
         if (!commandReceived.get()) {
-            if( !inactive.getAndSet(true) ) {
+            if( !failed.getAndSet(true) ) {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("No message received since last read check for " + toString()
+ "! Throwing InactivityIOException.");
                 }
                 ASYNC_TASKS.execute(new Runnable() {  
                     public void run() {
-                        onException(new InactivityIOException("Channel was inactive for too
long: "+next.getRemoteAddress()));
+                    	handleException(new InactivityIOException("Channel was inactive for
too long: "+next.getRemoteAddress()));
                     };
                     
                 });
@@ -224,7 +224,7 @@
                         startMonitorThreads();
                     }
                 }
-                if( inactive.get() ) {
+                if( failed.get() ) {
                     throw new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress());
                 }
                 next.oneway(o);
@@ -236,11 +236,17 @@
     }
 
     public void onException(IOException error) {
-        if (monitorStarted.get()) {
-            stopMonitorThreads();
-        }
-        transportListener.onException(error);
+    	if( !failed.getAndSet(true) ) {
+	        handleException(error);
+    	}
     }
+
+	private void handleException(IOException error) {
+		if (monitorStarted.get()) {
+		    stopMonitorThreads();
+		}
+		transportListener.onException(error);
+	}
 
     private synchronized void startMonitorThreads() throws IOException {
         if (monitorStarted.get()) {



Mime
View raw message