Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/19802#discussion_r160680820
--- Diff:
common/network-common/src/test/java/org/apache/spark/network/TransportRequestHandlerSuite.java
---
@@ -100,6 +101,43 @@ public void handleFetchRequestAndStreamRequest()
throws Exception {
assert responseAndPromisePairs.size() == 3;
}
+ @Test
+ public void handleOneWayMessageWithWrongSerialVersionUID() throws
Exception {
+ RpcHandler rpcHandler = new NoOpRpcHandler();
+ Channel channel = mock(Channel.class);
+ List<Pair<Object, ExtendedChannelPromise>> responseAndPromisePairs
=
+ new ArrayList<>();
+
+ when(channel.writeAndFlush(any()))
+ .thenAnswer(invocationOnMock -> {
+ Object response = invocationOnMock.getArguments()[0];
+ ExtendedChannelPromise channelFuture = new
ExtendedChannelPromise(channel);
+ responseAndPromisePairs.add(ImmutablePair.of(response,
channelFuture));
+ return channelFuture;
+ });
+
+ TransportClient reverseClient = mock(TransportClient.class);
+ TransportRequestHandler requestHandler = new
TransportRequestHandler(channel, reverseClient,
+ rpcHandler, 2L);
+
+ // req.body().nioByteBuffer() is the method that throws the
InvalidClassException
+ // with wrong svUID, so let's mock it
+ ManagedBuffer body = mock(ManagedBuffer.class);
+ when(body.nioByteBuffer()).thenThrow(new
InvalidClassException("test - wrong version"));
+ RequestMessage msg = new OneWayMessage(body);
+
+ requestHandler.handle(msg);
+
+ assert responseAndPromisePairs.size() == 1;
--- End diff --
These are JVM asserts, not JUnit asserts.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]