Skip to content

Commit da6d411

Browse files
authored
Merge pull request #2387 from dani8art/output-stream-flush-order
fix: WebSocketStreamHandler flush first and then close WebSocket
2 parents 09edcde + f3e972e commit da6d411

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

util/src/main/java/io/kubernetes/client/util/WebSocketStreamHandler.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,6 @@ public Throwable getError() {
111111
@Override
112112
public synchronized void close() {
113113
if (state != State.CLOSED) {
114-
state = State.CLOSED;
115-
if (null != socket) {
116-
// code 1000 means "Normal Closure"
117-
socket.close(1000, "Triggered client-side terminate");
118-
log.debug("Successfully closed socket.");
119-
}
120114
// Close all output streams. Caller of getInputStream(int) is responsible
121115
// for closing returned input streams
122116
for (PipedOutputStream out : pipedOutput.values()) {
@@ -143,6 +137,13 @@ public synchronized void close() {
143137
log.error("Error on close", ex);
144138
}
145139
}
140+
141+
state = State.CLOSED;
142+
if (null != socket) {
143+
// code 1000 means "Normal Closure"
144+
socket.close(1000, "Triggered client-side terminate");
145+
log.debug("Successfully closed socket.");
146+
}
146147
}
147148
notifyAll();
148149
}

0 commit comments

Comments
 (0)