Fix for inactivity exceptions not getting generated due to previous change.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@638942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2008-03-19 17:19:32 +00:00
parent 5269519536
commit 2f1822bf2c
1 changed files with 13 additions and 26 deletions

View File

@ -52,7 +52,6 @@ public class InactivityMonitor extends TransportFilter {
private final AtomicBoolean commandSent = new AtomicBoolean(false); private final AtomicBoolean commandSent = new AtomicBoolean(false);
private final AtomicBoolean inSend = new AtomicBoolean(false); private final AtomicBoolean inSend = new AtomicBoolean(false);
private final AtomicBoolean failed = new AtomicBoolean(false); private final AtomicBoolean failed = new AtomicBoolean(false);
private final AtomicBoolean stopped = new AtomicBoolean(false);
private final AtomicBoolean commandReceived = new AtomicBoolean(true); private final AtomicBoolean commandReceived = new AtomicBoolean(true);
private final AtomicBoolean inReceive = new AtomicBoolean(false); private final AtomicBoolean inReceive = new AtomicBoolean(false);
@ -110,7 +109,7 @@ public class InactivityMonitor extends TransportFilter {
} }
public void stop() throws Exception { public void stop() throws Exception {
closeDown(); stopMonitorThreads();
next.stop(); next.stop();
} }
@ -128,7 +127,7 @@ public class InactivityMonitor extends TransportFilter {
} }
ASYNC_TASKS.execute(new Runnable() { ASYNC_TASKS.execute(new Runnable() {
public void run() { public void run() {
if (stopped.get() == false) { if (monitorStarted.get()) {
try { try {
KeepAliveInfo info = new KeepAliveInfo(); KeepAliveInfo info = new KeepAliveInfo();
@ -157,19 +156,15 @@ public class InactivityMonitor extends TransportFilter {
return; return;
} }
if (!commandReceived.get()) { if (!commandReceived.get()) {
if( !failed.getAndSet(true) ) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("No message received since last read check for " + toString() + "! Throwing InactivityIOException."); LOG.debug("No message received since last read check for " + toString() + "! Throwing InactivityIOException.");
} }
closeDown();
ASYNC_TASKS.execute(new Runnable() { ASYNC_TASKS.execute(new Runnable() {
public void run() { public void run() {
onException(new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress())); onException(new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress()));
}; };
}); });
}
} else { } else {
if (LOG.isTraceEnabled()) { if (LOG.isTraceEnabled()) {
LOG.trace("Message received since last read check, resetting flag: "); LOG.trace("Message received since last read check, resetting flag: ");
@ -227,7 +222,6 @@ public class InactivityMonitor extends TransportFilter {
try { try {
if( failed.get() ) { if( failed.get() ) {
closeDown();
throw new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress()); throw new InactivityIOException("Channel was inactive for too long: "+next.getRemoteAddress());
} }
if (o.getClass() == WireFormatInfo.class) { if (o.getClass() == WireFormatInfo.class) {
@ -245,16 +239,9 @@ public class InactivityMonitor extends TransportFilter {
} }
public void onException(IOException error) { public void onException(IOException error) {
closeDown();
if (!failed.compareAndSet(false,true)) { if (!failed.compareAndSet(false,true)) {
transportListener.onException(error);
}
}
private void closeDown() {
stopped.set(true);
if (monitorStarted.get()) {
stopMonitorThreads(); stopMonitorThreads();
transportListener.onException(error);
} }
} }