Author: david.lloyd(a)jboss.com
Date: 2009-08-11 22:31:22 -0400 (Tue, 11 Aug 2009)
New Revision: 5326
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FutureReplyImpl.java
Log:
Generics fixes and error message improvements
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java 2009-08-06
02:41:11 UTC (rev 5325)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/ClientImpl.java 2009-08-12
02:31:22 UTC (rev 5326)
@@ -75,7 +75,7 @@
final ReplyHandler replyHandler = futureReply.getReplyHandler();
final RemoteRequestContext requestContext = handler.receiveRequest(actualRequest,
replyHandler);
futureReply.setRemoteRequestContext(requestContext);
- futureReply.addNotifier(IoUtils.attachmentClosingNotifier(), executor);
+ futureReply.addNotifier(IoUtils.<O>attachmentClosingNotifier(), executor);
executor.runQueue();
try {
final O reply = futureReply.getInterruptibly();
Modified:
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FutureReplyImpl.java
===================================================================
---
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FutureReplyImpl.java 2009-08-06
02:41:11 UTC (rev 5325)
+++
remoting3/trunk/jboss-remoting/src/main/java/org/jboss/remoting3/FutureReplyImpl.java 2009-08-12
02:31:22 UTC (rev 5326)
@@ -65,11 +65,22 @@
private final class Handler implements ReplyHandler {
public void handleReply(final Object reply) {
+ final Class<O> replyType = FutureReplyImpl.this.replyType;
final O actualReply;
try {
actualReply = replyType.cast(reply);
} catch (ClassCastException e) {
- setException(new ReplyException("Reply was of the wrong type (got
<" + reply.getClass().getName() + ">; expected <? extends " +
replyType.getName() + ">"));
+ // reply can't be null, else we wouldn't be here...
+ final Class<? extends Object> actualReplyType = reply.getClass();
+ final String actualReplyTypeName = actualReplyType.getName();
+ final String replyTypeName = replyType.getName();
+ final ReplyException replyException;
+ if (actualReplyTypeName.equals(replyTypeName)) {
+ replyException = new ReplyException("Reply appears to be of the
right type (" + replyTypeName + "), but from the wrong classloader (the reply is
from classloader " + actualReplyType.getClassLoader() + " but the client
expected it to be classloader " + replyType.getClassLoader() + ")");
+ } else {
+ replyException = new ReplyException("Reply was of the wrong type
(got a " + actualReplyTypeName + "; expected a " + replyTypeName +
")");
+ }
+ setException(replyException);
return;
}
setResult(actualReply);
Show replies by date