Skip to content

Commit 9d9295d

Browse files
committed
refactor sse error handling to catch Throwable instead of IOException
Signed-off-by: neo <1100909+neowu@users.noreply.github.com>
1 parent 5c3e84a commit 9d9295d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

core-ng/src/main/java/core/framework/internal/web/sse/ChannelImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.xnio.ChannelListener;
1515
import org.xnio.channels.StreamSinkChannel;
1616

17-
import java.io.IOException;
1817
import java.nio.ByteBuffer;
1918
import java.util.ArrayList;
2019
import java.util.Deque;
@@ -219,7 +218,7 @@ public void handleEvent(StreamSinkChannel channel) {
219218
return;
220219
}
221220
}
222-
} catch (IOException e) {
221+
} catch (Throwable e) {
223222
LOGGER.warn("failed to write sse message, error={}", e.getMessage(), e);
224223
exchange.endExchange();
225224
} finally {

core-ng/src/main/java/core/framework/internal/web/sse/ServerSentEventHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.xnio.IoUtils;
2424
import org.xnio.channels.StreamSinkChannel;
2525

26-
import java.io.IOException;
2726
import java.time.Duration;
2827
import java.util.HashMap;
2928
import java.util.List;
@@ -70,7 +69,7 @@ public void handleRequest(HttpServerExchange exchange) {
7069
sink.getWriteSetter().set(listener);
7170
sink.resumeWrites();
7271
}
73-
} catch (IOException e) {
72+
} catch (Throwable e) {
7473
logger.warn("failed to establish sse connection, error={}", e.getMessage(), e);
7574
IoUtils.safeClose(exchange.getConnection());
7675
}

0 commit comments

Comments
 (0)