From ca898dfa09e2ddb30bfc3ca8107c3546d9d36b80 Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Wed, 22 Apr 2020 15:54:15 +0800 Subject: [PATCH] [#859]:Allow SseEventSink.close() to throw IOException --- .../java/jaxrs/examples/sse/ServerSentEventsResource.java | 2 ++ jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSink.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java b/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java index 667e27e8e..d7e893b6c 100644 --- a/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java +++ b/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java @@ -98,6 +98,8 @@ public void startDomain(@PathParam("id") final String id, sseEventSink.close(); } catch (final InterruptedException e) { e.printStackTrace(); + } catch (IOException ioe) { + //handle I/O error } }); } diff --git a/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSink.java b/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSink.java index bf37ce372..e27b1630d 100644 --- a/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSink.java +++ b/jaxrs-api/src/main/java/jakarta/ws/rs/sse/SseEventSink.java @@ -16,6 +16,7 @@ package jakarta.ws.rs.sse; +import java.io.IOException; import java.util.concurrent.CompletionStage; /** @@ -71,7 +72,9 @@ public interface SseEventSink extends AutoCloseable { *

* Subsequent calls have no effect and are ignored. Once the {@link SseEventSink} is closed, invoking any method other * than this one and {@link #isClosed()} would result in an {@link IllegalStateException} being thrown. + * + * @exception IOException if an I/O error occurs. */ @Override - void close(); + void close() throws IOException; }