Merge pull request #12981 from s1monw/serialize_interrupted_exceptions
Add serialization support for InterruptedException
This commit is contained in:
commit
ddd6be1047
|
@ -542,6 +542,8 @@ public abstract class StreamInput extends InputStream {
|
||||||
return (T) readStackTrace(new IllegalStateException(readOptionalString(), readThrowable()), this);
|
return (T) readStackTrace(new IllegalStateException(readOptionalString(), readThrowable()), this);
|
||||||
case 17:
|
case 17:
|
||||||
return (T) readStackTrace(new LockObtainFailedException(readOptionalString(), readThrowable()), this);
|
return (T) readStackTrace(new LockObtainFailedException(readOptionalString(), readThrowable()), this);
|
||||||
|
case 18:
|
||||||
|
return (T) readStackTrace(new InterruptedException(readOptionalString()), this);
|
||||||
default:
|
default:
|
||||||
assert false : "no such exception for id: " + key;
|
assert false : "no such exception for id: " + key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -590,6 +590,9 @@ public abstract class StreamOutput extends OutputStream {
|
||||||
writeVInt(16);
|
writeVInt(16);
|
||||||
} else if (throwable instanceof LockObtainFailedException) {
|
} else if (throwable instanceof LockObtainFailedException) {
|
||||||
writeVInt(17);
|
writeVInt(17);
|
||||||
|
} else if (throwable instanceof InterruptedException) {
|
||||||
|
writeVInt(18);
|
||||||
|
writeCause = false;
|
||||||
} else {
|
} else {
|
||||||
ElasticsearchException ex;
|
ElasticsearchException ex;
|
||||||
final String name = throwable.getClass().getName();
|
final String name = throwable.getClass().getName();
|
||||||
|
|
|
@ -497,7 +497,6 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
|
||||||
serverBootstrap.setOption("child.receiveBufferSizePredictorFactory", receiveBufferSizePredictorFactory);
|
serverBootstrap.setOption("child.receiveBufferSizePredictorFactory", receiveBufferSizePredictorFactory);
|
||||||
serverBootstrap.setOption("reuseAddress", reuseAddress);
|
serverBootstrap.setOption("reuseAddress", reuseAddress);
|
||||||
serverBootstrap.setOption("child.reuseAddress", reuseAddress);
|
serverBootstrap.setOption("child.reuseAddress", reuseAddress);
|
||||||
|
|
||||||
serverBootstraps.put(name, serverBootstrap);
|
serverBootstraps.put(name, serverBootstrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -607,4 +607,20 @@ public class ExceptionSerializationTests extends ESTestCase {
|
||||||
assertEquals(ex.status(), e.status());
|
assertEquals(ex.status(), e.status());
|
||||||
assertEquals(RestStatus.UNAUTHORIZED, e.status());
|
assertEquals(RestStatus.UNAUTHORIZED, e.status());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testInterruptedException() throws IOException {
|
||||||
|
InterruptedException orig = randomBoolean() ? new InterruptedException("boom") : new InterruptedException();
|
||||||
|
InterruptedException ex = serialize(orig);
|
||||||
|
assertEquals(orig.getMessage(), ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UnknownException extends Exception {
|
||||||
|
public UnknownException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnknownException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue