From b66b4c8d5759a3b63f32efafd8edcd3be86aa095 Mon Sep 17 00:00:00 2001 From: Jorge Bescos Gascon Date: Wed, 6 Dec 2023 10:09:39 +0100 Subject: [PATCH] Catch Exception Signed-off-by: Jorge Bescos Gascon --- .../java/org/glassfish/jersey/server/ChunkedOutput.java | 7 ++++--- .../jersey/media/sse/internal/JerseyEventSink.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core-server/src/main/java/org/glassfish/jersey/server/ChunkedOutput.java b/core-server/src/main/java/org/glassfish/jersey/server/ChunkedOutput.java index faf37de02b..2ce0542b22 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/ChunkedOutput.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/ChunkedOutput.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -19,6 +19,7 @@ import java.io.Closeable; import java.io.IOException; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.lang.reflect.Type; import java.util.Collections; import java.util.concurrent.BlockingDeque; @@ -255,11 +256,11 @@ public Void call() throws IOException { // if MBW replaced the stream, let's make sure to set it in the response context. responseContext.setEntityStream(writtenStream); } - } catch (final IOException ioe) { + } catch (final IOException | UncheckedIOException ioe) { connectionCallback.onDisconnect(asyncContext); throw ioe; } catch (final MappableException mpe) { - if (mpe.getCause() instanceof IOException) { + if (mpe.getCause() instanceof IOException || mpe.getCause() instanceof UncheckedIOException) { connectionCallback.onDisconnect(asyncContext); } throw mpe; diff --git a/media/sse/src/main/java/org/glassfish/jersey/media/sse/internal/JerseyEventSink.java b/media/sse/src/main/java/org/glassfish/jersey/media/sse/internal/JerseyEventSink.java index 184814450d..b1b1dc0e61 100644 --- a/media/sse/src/main/java/org/glassfish/jersey/media/sse/internal/JerseyEventSink.java +++ b/media/sse/src/main/java/org/glassfish/jersey/media/sse/internal/JerseyEventSink.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -139,7 +139,7 @@ public CompletionStage send(OutboundSseEvent event) { try { this.write(event); return CompletableFuture.completedFuture(null); - } catch (IOException e) { + } catch (Exception e) { CompletableFuture future = new CompletableFuture<>(); future.completeExceptionally(e); return future;