Skip to content

Commit 1137b22

Browse files
committed
autoRead fix
1 parent c4d8038 commit 1137b22

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpContentSizeHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* TODO: move to {@link org.elasticsearch.rest.RestController}
2525
*/
2626
public class Netty4HttpContentSizeHandler extends HttpObjectAggregator {
27-
private boolean ignoreContentAfterContinueResponse = false;
2827
private boolean ignoreFollowingContent = false;
2928
private int contentLength = 0;
3029
private HttpRequest currentRequest;

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpHeaderValidator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ State getState() {
5050
}
5151

5252
boolean canAutoRead() {
53-
return state != WAITING_TO_START && state != QUEUEING_DATA;
53+
return state != QUEUEING_DATA && state != DROPPING_DATA_PERMANENTLY;
5454
}
5555

5656
@SuppressWarnings("fallthrough")

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestBodyStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public void next() {
106106
send();
107107
} catch (Throwable t) {
108108
// must catch everything
109+
doClose();
109110
channel.pipeline().fireExceptionCaught(t);
110111
} finally {
111112
activityTracker.stopActivity();

server/src/main/java/org/elasticsearch/rest/RestContentAggregator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,14 @@ static class NoContent implements ChunkHandler {
167167

168168
@Override
169169
public void onNext(final ReleasableBytesReference lastEmptyChunk, boolean isLast) throws Exception {
170+
lastEmptyChunk.close();
170171
if (lastEmptyChunk.length() == 0 && isLast) {
171172
var aggReq = new RestRequest(request, new AggregatedHttpRequest(request.getHttpRequest(), HttpBody.empty()));
172173
var aggChan = new AggregatedRestRequestChannel(channel, aggReq);
173174
result.accept(aggReq, aggChan);
174175
} else {
175176
request.contentStream().close();
176-
throw new IllegalStateException("unexpected HTTP content");
177+
channel.sendResponse(new RestResponse(RestStatus.BAD_REQUEST, "unexpected HTTP content"));
177178
}
178179
}
179180
}

0 commit comments

Comments
 (0)