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:
parent
edd049f9cd
commit
9eb6736500
|
@ -87,7 +87,11 @@ public class InboundMessage implements Releasable {
|
||||||
public Releasable takeBreakerReleaseControl() {
|
public Releasable takeBreakerReleaseControl() {
|
||||||
final Releasable toReturn = breakerRelease;
|
final Releasable toReturn = breakerRelease;
|
||||||
breakerRelease = null;
|
breakerRelease = null;
|
||||||
return toReturn;
|
if (toReturn != null) {
|
||||||
|
return toReturn;
|
||||||
|
} else {
|
||||||
|
return () -> {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamInput openOrGetStreamInput() throws IOException {
|
public StreamInput openOrGetStreamInput() throws IOException {
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class InboundAggregatorTests extends ESTestCase {
|
||||||
assertThat(aggregated, notNullValue());
|
assertThat(aggregated, notNullValue());
|
||||||
assertTrue(aggregated.isShortCircuit());
|
assertTrue(aggregated.isShortCircuit());
|
||||||
assertThat(aggregated.getException(), instanceOf(ActionNotFoundTransportException.class));
|
assertThat(aggregated.getException(), instanceOf(ActionNotFoundTransportException.class));
|
||||||
|
assertNotNull(aggregated.takeBreakerReleaseControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCircuitBreak() throws IOException {
|
public void testCircuitBreak() throws IOException {
|
||||||
|
|
Loading…
Reference in New Issue