You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by srowen <gi...@git.apache.org> on 2018/01/10 13:49:51 UTC

[GitHub] spark pull request #19802: [SPARK-22594][CORE] Handling spark-submit and mas...

Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/19802#discussion_r160681021
  
    --- 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;
    +        assert responseAndPromisePairs.get(0).getLeft() instanceof RpcFailure;
    +        assert (responseAndPromisePairs.get(0).getLeft().toString()
    +                .contains("version mismatch between client and server"));
    +        assert (((RpcFailure)responseAndPromisePairs.get(0).getLeft()).requestId
    --- End diff --
    
    Space after casts


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org