diff --git a/server/src/main/java/org/elasticsearch/transport/InboundMessage.java b/server/src/main/java/org/elasticsearch/transport/InboundMessage.java index 99dd23e940d..f3652b392b4 100644 --- a/server/src/main/java/org/elasticsearch/transport/InboundMessage.java +++ b/server/src/main/java/org/elasticsearch/transport/InboundMessage.java @@ -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 { diff --git a/server/src/test/java/org/elasticsearch/transport/InboundAggregatorTests.java b/server/src/test/java/org/elasticsearch/transport/InboundAggregatorTests.java index 82389c29a6c..92d333d45e1 100644 --- a/server/src/test/java/org/elasticsearch/transport/InboundAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/transport/InboundAggregatorTests.java @@ -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 {