提交 2aad4029 编写于 作者: K Kohsuke Kawaguchi

[FIXED JENKINS-9050] Improved the error diagnostics when a remote method call fails to deserialize.

上级 ca4de00c
......@@ -90,6 +90,9 @@ Upcoming changes</a>
<li class=rfe>
Added a new axis type to the matrix project that lets you use boolean expressions
(<a href="https://github.com/jenkinsci/jenkins/pull/66">pull request #66</a>)
<li class=rfe>
Improved the error diagnostics when a remote method call fails to deserialize.
(<a href="http://issues.jenkins-ci.org/browse/JENKINS-9050">issue 9050</a>)
</ul>
</div><!--=TRUNK-END=-->
......
......@@ -98,6 +98,10 @@ final class UserRequest<RSP,EXC extends Throwable> extends Request<UserResponse<
o = deserialize(channel,request,cl);
} catch (ClassNotFoundException e) {
throw new ClassNotFoundException("Failed to deserialize the Callable object. Perhaps you needed to implement DelegatingCallable?",e);
} catch (RuntimeException e) {
// if the error is during deserialization, throw it in one of the types Channel.call will
// capture its call site stack trace. See
throw new Error("Failed to deserialize the Callable object.",e);
}
Callable<RSP,EXC> callable = (Callable<RSP,EXC>)o;
......
package hudson.remoting;
import org.jvnet.hudson.test.Bug;
import java.io.IOException;
import java.io.ObjectInputStream;
/**
* @author Kohsuke Kawaguchi
*/
......@@ -7,4 +12,26 @@ public class ChannelTest extends RmiTestBase {
public void testCapability() {
assertTrue(channel.remoteCapability.supportsMultiClassLoaderRPC());
}
@Bug(9050)
public void testFailureInDeserialization() throws Exception {
try {
channel.call(new CallableImpl());
fail();
} catch (IOException e) {
e.printStackTrace();
assertEquals("foobar",e.getCause().getCause().getMessage());
assertTrue(e.getCause().getCause() instanceof ClassCastException);
}
}
private static class CallableImpl implements Callable<Object,IOException> {
public Object call() throws IOException {
return null;
}
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
throw new ClassCastException("foobar");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册