Author: david.lloyd(a)jboss.com
Date: 2010-03-08 18:32:07 -0500 (Mon, 08 Mar 2010)
New Revision: 5805
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestContextImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestListenerExecutor.java
Log:
JBREM-1080 - just use a finalize method to see if a reply was not sent
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestContextImpl.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestContextImpl.java 2010-03-08
23:18:30 UTC (rev 5804)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestContextImpl.java 2010-03-08
23:32:07 UTC (rev 5805)
@@ -29,7 +29,6 @@
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.remoting3.spi.RemoteReplyHandler;
import org.jboss.remoting3.spi.SpiUtils;
@@ -42,7 +41,6 @@
private final Object cancelLock = new Object();
private final RemoteReplyHandler replyHandler;
private final ClientContextImpl clientContext;
- private final AtomicInteger taskCount = new AtomicInteger();
// @protectedby cancelLock
private boolean cancelled;
@@ -59,7 +57,7 @@
this.serviceClassLoader = serviceClassLoader;
final Executor executor = clientContext.getExecutor();
//noinspection ThisEscapedInObjectConstruction
- interruptingExecutor = new RequestListenerExecutor(executor, this);
+ interruptingExecutor = new RequestListenerExecutor(executor);
}
public ClientContext getContext() {
@@ -184,13 +182,8 @@
}
}
- void startTask() {
- taskCount.incrementAndGet();
- }
-
- void finishTask() {
- if (taskCount.decrementAndGet() == 0 && ! closed.getAndSet(true)) {
- // no response sent! send back IndeterminateOutcomeException
+ protected void finalize() throws Throwable {
+ if (! closed.getAndSet(true)) {
SpiUtils.safeHandleException(replyHandler, new
IndeterminateOutcomeException("No reply was sent by the request listener"));
}
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestListenerExecutor.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestListenerExecutor.java 2010-03-08
23:18:30 UTC (rev 5804)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/RequestListenerExecutor.java 2010-03-08
23:32:07 UTC (rev 5805)
@@ -34,11 +34,9 @@
private final Set<Task> tasks = Collections.synchronizedSet(new
HashSet<Task>());
private final Executor executor;
- private final RequestContextImpl<?> requestContext;
- public RequestListenerExecutor(final Executor executor, final
RequestContextImpl<?> context) {
+ public RequestListenerExecutor(final Executor executor) {
this.executor = executor;
- requestContext = context;
}
private final class Task implements Runnable {
@@ -50,13 +48,11 @@
}
public void run() {
- requestContext.startTask();
thread = Thread.currentThread();
tasks.add(this);
try {
runnable.run();
} finally {
- requestContext.finishTask();
tasks.remove(this);
thread = null;
}
Show replies by date