Author: david.lloyd(a)jboss.com
Date: 2010-04-09 09:37:42 -0400 (Fri, 09 Apr 2010)
New Revision: 5847
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyExceptionTask.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
Log:
Fix test failures
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientConnectorImpl.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -23,7 +23,9 @@
package org.jboss.remoting3;
import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
+import org.jboss.marshalling.FieldSetter;
import org.jboss.remoting3.spi.RemoteRequestHandler;
import org.jboss.remoting3.spi.RequestHandlerConnector;
import org.jboss.xnio.FutureResult;
@@ -34,7 +36,10 @@
private static final long serialVersionUID = -263585821458635701L;
+ private static final FieldSetter connectionSetter =
FieldSetter.get(ClientConnectorImpl.class, "connection");
+
private transient final ClientContext clientContext;
+ private transient final Connection connection;
private final RequestHandlerConnector requestHandlerConnector;
private final EndpointImpl endpoint;
@@ -47,6 +52,7 @@
this.requestClass = requestClass;
this.replyClass = replyClass;
this.clientContext = clientContext;
+ connection = clientContext.getConnection();
}
public IoFuture<? extends Client<I, O>> getFutureClient() throws
SecurityException {
@@ -57,7 +63,7 @@
final FutureResult<Client<I, O>> futureResult = new
FutureResult<Client<I, O>>();
requestHandlerConnector.createRequestHandler(new
TranslatingResult<RemoteRequestHandler, Client<I, O>>(futureResult) {
protected Client<I, O> translate(final RemoteRequestHandler input)
throws IOException {
- return endpoint.createClient(input, requestClass, replyClass,
classloader, RemotingContext.requireCurrent().getConnection());
+ return endpoint.createClient(input, requestClass, replyClass,
classloader, connection);
}
});
return futureResult.getIoFuture();
@@ -69,4 +75,9 @@
}
return clientContext;
}
+
+ private void readObject(ObjectInputStream ois) throws ClassNotFoundException,
IOException {
+ ois.defaultReadObject();
+ connectionSetter.set(this, RemotingContext.requireCurrent().getConnection());
+ }
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyExceptionTask.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyExceptionTask.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyExceptionTask.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -48,10 +48,11 @@
replyHandler = outboundRequest.getInboundReplyHandler();
oldByteInput = outboundRequest.getByteInput();
}
+ final RemoteConnectionHandler connectionHandler = remoteConnectionHandler;
+ connectionHandler.getConnectionContext().beginContext();
try {
final Object exception;
try {
- final RemoteConnectionHandler connectionHandler =
remoteConnectionHandler;
final Unmarshaller unmarshaller =
connectionHandler.getMarshallerFactory().createUnmarshaller(connectionHandler.getMarshallingConfiguration());
unmarshaller.start(outboundRequest.getByteInput());
exception = unmarshaller.readObject();
@@ -76,6 +77,7 @@
if (oldByteInput != null) {
oldByteInput.pushEof();
}
+ connectionHandler.getConnectionContext().endContext();
}
}
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundReplyTask.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -51,20 +51,25 @@
final Object reply;
try {
final RemoteConnectionHandler connectionHandler = remoteConnectionHandler;
- final Unmarshaller unmarshaller =
connectionHandler.getMarshallerFactory().createUnmarshaller(connectionHandler.getMarshallingConfiguration());
+ connectionHandler.getConnectionContext().beginContext();
try {
- log.trace("Unmarshalling inbound reply");
- unmarshaller.start(outboundRequest.getByteInput());
- final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ final Unmarshaller unmarshaller =
connectionHandler.getMarshallerFactory().createUnmarshaller(connectionHandler.getMarshallingConfiguration());
try {
- reply = unmarshaller.readObject();
- unmarshaller.close();
+ log.trace("Unmarshalling inbound reply");
+ unmarshaller.start(outboundRequest.getByteInput());
+ final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ try {
+ reply = unmarshaller.readObject();
+ unmarshaller.close();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
+ log.trace("Unmarshalled inbound reply %s", reply);
} finally {
- RemoteConnectionHandler.setCurrent(old);
+ IoUtils.safeClose(unmarshaller);
}
- log.trace("Unmarshalled inbound reply %s", reply);
} finally {
- IoUtils.safeClose(unmarshaller);
+ connectionHandler.getConnectionContext().endContext();
}
} catch (IOException e) {
log.trace(e, "Unmarshalling inbound reply failed");
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/InboundRequestTask.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -53,21 +53,27 @@
inboundRequest.setReplyHandler(replyHandler = new
OutboundReplyHandler(inboundRequest, rid));
}
final Object request;
+ final RemoteConnectionHandler connectionHandler = remoteConnectionHandler;
try {
- final Unmarshaller unmarshaller =
remoteConnectionHandler.getMarshallerFactory().createUnmarshaller(remoteConnectionHandler.getMarshallingConfiguration());
+ connectionHandler.getConnectionContext().beginContext();
try {
- log.trace("Unmarshalling inbound request");
- unmarshaller.start(inboundRequest.getByteInput());
- final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(remoteConnectionHandler);
+ final Unmarshaller unmarshaller =
connectionHandler.getMarshallerFactory().createUnmarshaller(connectionHandler.getMarshallingConfiguration());
try {
- request = unmarshaller.readObject();
- unmarshaller.close();
+ log.trace("Unmarshalling inbound request");
+ unmarshaller.start(inboundRequest.getByteInput());
+ final RemoteConnectionHandler old =
RemoteConnectionHandler.setCurrent(connectionHandler);
+ try {
+ request = unmarshaller.readObject();
+ unmarshaller.close();
+ } finally {
+ RemoteConnectionHandler.setCurrent(old);
+ }
+ log.trace("Unmarshalled inbound request %s", request);
} finally {
- RemoteConnectionHandler.setCurrent(old);
+ IoUtils.safeClose(unmarshaller);
}
- log.trace("Unmarshalled inbound request %s", request);
} finally {
- IoUtils.safeClose(unmarshaller);
+ connectionHandler.getConnectionContext().endContext();
}
} catch (IOException e) {
log.trace(e, "Unmarshalling inbound request failed");
@@ -83,7 +89,7 @@
throw e;
}
final InboundClient inboundClient;
- final IntKeyMap<InboundClient> inboundClients =
remoteConnectionHandler.getInboundClients();
+ final IntKeyMap<InboundClient> inboundClients =
connectionHandler.getInboundClients();
synchronized (inboundClients) {
inboundClient = inboundClients.get(cid);
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundReplyHandler.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -60,6 +60,7 @@
if (! done.getAndSet(true)) {
final RemoteConnectionHandler connectionHandler =
inboundRequest.getRemoteConnectionHandler();
boolean ok = false;
+ connectionHandler.getConnectionContext().beginContext();
try {
final Marshaller marshaller =
connectionHandler.getMarshallerFactory().createMarshaller(connectionHandler.getMarshallingConfiguration());
marshaller.start(new NioByteOutput(new
OutboundReplyBufferWriter(inboundRequest, rid, true)));
@@ -72,6 +73,7 @@
}
ok = true;
} finally {
+ connectionHandler.getConnectionContext().endContext();
if (! ok) {
// attempt to send an exception abort
final Pool<ByteBuffer> bufferPool =
connectionHandler.getBufferPool();
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/OutboundRequestHandler.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -57,6 +57,7 @@
outboundRequests.put(rid, outboundRequest);
}
final NioByteOutput byteOutput = new NioByteOutput(new
OutboundRequestBufferWriter(outboundRequest, rid));
+ connectionHandler.getConnectionContext().beginContext();
try {
log.trace("Starting sending request %s for %s", request,
Integer.valueOf(rid));
final Marshaller marshaller =
connectionHandler.getMarshallerFactory().createMarshaller(connectionHandler.getMarshallingConfiguration());
@@ -89,6 +90,8 @@
} catch (IOException e1) {
log.trace("Send failed: %s", e1);
}
+ } finally {
+ connectionHandler.getConnectionContext().endContext();
}
return outboundRequest;
}
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java 2010-04-09
13:06:00 UTC (rev 5846)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/remote/RemoteConnectionHandler.java 2010-04-09
13:37:42 UTC (rev 5847)
@@ -31,7 +31,6 @@
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
import org.jboss.marshalling.util.IntKeyMap;
-import org.jboss.remoting3.CloseHandler;
import org.jboss.remoting3.ClosingCloseHandler;
import org.jboss.remoting3.IndeterminateOutcomeException;
import org.jboss.remoting3.ServiceOpenException;