Fix NullPointer when message shortcircuited (#55945)

Currently if we shortcircuit a message the breaker release is null since
there is nothing to be broken. However, the TcpTransportChannel
infrastructure still expects it. This commit resolves this issue be
returning a no-op breaker release.
This commit is contained in:
Tim Brooks 2020-04-29 10:11:39 -06:00 committed by GitHub
parent edd049f9cd
commit 9eb6736500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -87,7 +87,11 @@ public class InboundMessage implements Releasable {
public Releasable takeBreakerReleaseControl() {
final Releasable toReturn = breakerRelease;
breakerRelease = null;
return toReturn;
if (toReturn != null) {
return toReturn;
} else {
return () -> {};
}
}
public StreamInput openOrGetStreamInput() throws IOException {

View File

@ -130,6 +130,7 @@ public class InboundAggregatorTests extends ESTestCase {
assertThat(aggregated, notNullValue());
assertTrue(aggregated.isShortCircuit());
assertThat(aggregated.getException(), instanceOf(ActionNotFoundTransportException.class));
assertNotNull(aggregated.takeBreakerReleaseControl());
}
public void testCircuitBreak() throws IOException {