|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
@@ -259,6 +259,14 @@ private void drainInputQueue() {
|
259 | 259 | }
|
260 | 260 | }
|
261 | 261 |
|
| 262 | + @Override |
| 263 | + void nullBody(HttpResponse<T> resp, Throwable t) { |
| 264 | + if (debug.on()) debug.log("nullBody: streamid=%d", streamid); |
| 265 | + // We should have an END_STREAM data frame waiting in the inputQ. |
| 266 | + // We need a subscriber to force the scheduler to process it. |
| 267 | + pendingResponseSubscriber = HttpResponse.BodySubscribers.replacing(null); |
| 268 | + sched.runOrSchedule(); |
| 269 | + } |
262 | 270 |
|
263 | 271 | // Callback invoked after the Response BodySubscriber has consumed the
|
264 | 272 | // buffers contained in a DataFrame.
|
@@ -382,6 +390,7 @@ void incoming(Http2Frame frame) throws IOException {
|
382 | 390 | Log.logTrace("handling response (streamid={0})", streamid);
|
383 | 391 | handleResponse();
|
384 | 392 | if (hframe.getFlag(HeaderFrame.END_STREAM)) {
|
| 393 | + if (debug.on()) debug.log("handling END_STREAM: %d", streamid); |
385 | 394 | receiveDataFrame(new DataFrame(streamid, DataFrame.END_STREAM, List.of()));
|
386 | 395 | }
|
387 | 396 | }
|
@@ -688,6 +697,7 @@ HttpHeaders getRequestPseudoHeaders() {
|
688 | 697 |
|
689 | 698 | /** Sets endStreamReceived. Should be called only once. */
|
690 | 699 | void setEndStreamReceived() {
|
| 700 | + if (debug.on()) debug.log("setEndStreamReceived: streamid=%d", streamid); |
691 | 701 | assert remotelyClosed == false: "Unexpected endStream already set";
|
692 | 702 | remotelyClosed = true;
|
693 | 703 | responseReceived();
|
@@ -1032,14 +1042,24 @@ void completeResponse(Response resp) {
|
1032 | 1042 | synchronized void requestSent() {
|
1033 | 1043 | requestSent = true;
|
1034 | 1044 | if (responseReceived) {
|
| 1045 | + if (debug.on()) debug.log("requestSent: streamid=%d", streamid); |
1035 | 1046 | close();
|
| 1047 | + } else { |
| 1048 | + if (debug.on()) { |
| 1049 | + debug.log("requestSent: streamid=%d but response not received", streamid); |
| 1050 | + } |
1036 | 1051 | }
|
1037 | 1052 | }
|
1038 | 1053 |
|
1039 | 1054 | synchronized void responseReceived() {
|
1040 | 1055 | responseReceived = true;
|
1041 | 1056 | if (requestSent) {
|
| 1057 | + if (debug.on()) debug.log("responseReceived: streamid=%d", streamid); |
1042 | 1058 | close();
|
| 1059 | + } else { |
| 1060 | + if (debug.on()) { |
| 1061 | + debug.log("responseReceived: streamid=%d but request not sent", streamid); |
| 1062 | + } |
1043 | 1063 | }
|
1044 | 1064 | }
|
1045 | 1065 |
|
@@ -1162,6 +1182,7 @@ void close() {
|
1162 | 1182 | if (closed) return;
|
1163 | 1183 | closed = true;
|
1164 | 1184 | }
|
| 1185 | + if (debug.on()) debug.log("close stream %d", streamid); |
1165 | 1186 | Log.logTrace("Closing stream {0}", streamid);
|
1166 | 1187 | connection.closeStream(streamid);
|
1167 | 1188 | Log.logTrace("Stream {0} closed", streamid);
|
|
0 commit comments