|
19 | 19 |
|
20 | 20 | package org.elasticsearch.test.transport; |
21 | 21 |
|
22 | | -import org.elasticsearch.ElasticsearchException; |
23 | 22 | import org.elasticsearch.action.ActionListener; |
24 | 23 | import org.elasticsearch.cluster.node.DiscoveryNode; |
25 | 24 | import org.elasticsearch.common.Nullable; |
@@ -91,7 +90,18 @@ public TransportService createTransportService(Settings settings, ThreadPool thr |
91 | 90 | public void handleResponse(final long requestId, final TransportResponse response) { |
92 | 91 | final TransportResponseHandler transportResponseHandler = responseHandlers.onResponseReceived(requestId, listener); |
93 | 92 | if (transportResponseHandler != null) { |
94 | | - transportResponseHandler.handleResponse(response); |
| 93 | + final TransportResponse deliveredResponse; |
| 94 | + if (rarely()) { |
| 95 | + deliveredResponse = response; |
| 96 | + } else { |
| 97 | + try (BytesStreamOutput output = new BytesStreamOutput()) { |
| 98 | + response.writeTo(output); |
| 99 | + deliveredResponse = transportResponseHandler.read(output.bytes().streamInput()); |
| 100 | + } catch (IOException | UnsupportedOperationException e) { |
| 101 | + throw new AssertionError("failed to serialize/deserialize response " + response, e); |
| 102 | + } |
| 103 | + } |
| 104 | + transportResponseHandler.handleResponse(deliveredResponse); |
95 | 105 | } |
96 | 106 | } |
97 | 107 |
|
@@ -126,7 +136,7 @@ public void handleRemoteError(final long requestId, final Throwable t) { |
126 | 136 | output.writeException(t); |
127 | 137 | remoteException = new RemoteTransportException("remote failure", output.bytes().streamInput().readException()); |
128 | 138 | } catch (IOException ioException) { |
129 | | - throw new ElasticsearchException("failed to serialize/deserialize supplied exception " + t, ioException); |
| 139 | + throw new AssertionError("failed to serialize/deserialize supplied exception " + t, ioException); |
130 | 140 | } |
131 | 141 | } |
132 | 142 | this.handleError(requestId, remoteException); |
|
0 commit comments