|
@@ -249,6 +249,23 @@ public class TestIPC extends TestCase {
|
|
throw new IOException(ERR_MSG);
|
|
throw new IOException(ERR_MSG);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private static class LongRTEWritable extends LongWritable {
|
|
|
|
+ private final static String ERR_MSG =
|
|
|
|
+ "Come across an runtime exception while reading";
|
|
|
|
+
|
|
|
|
+ LongRTEWritable() {}
|
|
|
|
+
|
|
|
|
+ LongRTEWritable(long longValue) {
|
|
|
|
+ super(longValue);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void readFields(DataInput in) throws IOException {
|
|
|
|
+ super.readFields(in);
|
|
|
|
+ throw new RuntimeException(ERR_MSG);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
public void testErrorClient() throws Exception {
|
|
public void testErrorClient() throws Exception {
|
|
// start server
|
|
// start server
|
|
Server server = new TestServer(1, false);
|
|
Server server = new TestServer(1, false);
|
|
@@ -268,6 +285,30 @@ public class TestIPC extends TestCase {
|
|
assertEquals(LongErrorWritable.ERR_MSG, cause.getMessage());
|
|
assertEquals(LongErrorWritable.ERR_MSG, cause.getMessage());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public void testRuntimeExceptionWritable() throws Exception {
|
|
|
|
+ // start server
|
|
|
|
+ Server server = new TestServer(1, false);
|
|
|
|
+ InetSocketAddress addr = NetUtils.getConnectAddress(server);
|
|
|
|
+ server.start();
|
|
|
|
+
|
|
|
|
+ // start client
|
|
|
|
+ Client client = new Client(LongRTEWritable.class, conf);
|
|
|
|
+ try {
|
|
|
|
+ client.call(new LongRTEWritable(RANDOM.nextLong()),
|
|
|
|
+ addr, null, null);
|
|
|
|
+ fail("Expected an exception to have been thrown");
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // check error
|
|
|
|
+ Throwable cause = e.getCause();
|
|
|
|
+ assertTrue(cause instanceof IOException);
|
|
|
|
+ // it's double-wrapped
|
|
|
|
+ Throwable cause2 = cause.getCause();
|
|
|
|
+ assertTrue(cause2 instanceof RuntimeException);
|
|
|
|
+
|
|
|
|
+ assertEquals(LongRTEWritable.ERR_MSG, cause2.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* Test that, if the socket factory throws an IOE, it properly propagates
|
|
* Test that, if the socket factory throws an IOE, it properly propagates
|