Skip to content

Commit 6c24a98

Browse files
authored
fix: prevent logging of RejectedExecutionException
closes: #6215 Signed-off-by: Steve Hawkins <[email protected]>
1 parent 806a918 commit 6c24a98

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#### Bugs
66
* Fix #6038: Support for Gradle configuration cache
77
* Fix #6110: VolumeSource (and other file mode fields) in Octal are correctly interpreted
8+
* Fix #6215: Suppressing rejected execution exception for port forwarder
89

910
#### Improvements
1011
* Fix #6008: removing the optional dependency on bouncy castle

kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/internal/PortForwarderWebsocketListener.java

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.concurrent.Executor;
3333
import java.util.concurrent.ExecutorService;
3434
import java.util.concurrent.Executors;
35+
import java.util.concurrent.RejectedExecutionException;
3536
import java.util.concurrent.atomic.AtomicBoolean;
3637
import java.util.function.BooleanSupplier;
3738

@@ -75,16 +76,20 @@ public void onOpen(final WebSocket webSocket) {
7576
if (e instanceof InterruptedException) {
7677
Thread.currentThread().interrupt();
7778
}
78-
logger.debug("Error while writing client data");
79-
if (alive.get()) {
80-
clientThrowables.add(e);
81-
closeBothWays(webSocket, 1001, "Client error");
82-
}
79+
clientError(webSocket, "writing client data", e);
8380
}
8481
});
8582
}
8683
}
8784

85+
private void clientError(final WebSocket webSocket, String operation, Exception e) {
86+
if (alive.get()) {
87+
logger.debug("Error while " + operation, e);
88+
clientThrowables.add(e);
89+
closeBothWays(webSocket, 1001, "Client error");
90+
}
91+
}
92+
8893
@Override
8994
public void onMessage(WebSocket webSocket, String text) {
9095
logger.debug("{}: onMessage(String)", LOG_PREFIX);
@@ -125,27 +130,27 @@ public void onMessage(WebSocket webSocket, ByteBuffer buffer) {
125130
} else {
126131
// Data
127132
if (out != null) {
128-
serialExecutor.execute(() -> {
129-
try {
130-
while (buffer.hasRemaining()) {
131-
int written = out.write(buffer); // channel byte already skipped
132-
if (written == 0) {
133-
// out is non-blocking, prevent a busy loop
134-
Thread.sleep(50);
133+
try {
134+
serialExecutor.execute(() -> {
135+
try {
136+
while (buffer.hasRemaining()) {
137+
int written = out.write(buffer); // channel byte already skipped
138+
if (written == 0) {
139+
// out is non-blocking, prevent a busy loop
140+
Thread.sleep(50);
141+
}
135142
}
143+
webSocket.request();
144+
} catch (IOException | InterruptedException e) {
145+
if (e instanceof InterruptedException) {
146+
Thread.currentThread().interrupt();
147+
}
148+
clientError(webSocket, "forwarding data to the client", e);
136149
}
137-
webSocket.request();
138-
} catch (IOException | InterruptedException e) {
139-
if (e instanceof InterruptedException) {
140-
Thread.currentThread().interrupt();
141-
}
142-
if (alive.get()) {
143-
clientThrowables.add(e);
144-
logger.debug("Error while forwarding data to the client", e);
145-
closeBothWays(webSocket, 1002, PROTOCOL_ERROR);
146-
}
147-
}
148-
});
150+
});
151+
} catch (RejectedExecutionException e) {
152+
// just ignore
153+
}
149154
}
150155
}
151156
}

0 commit comments

Comments
 (0)