From e9b84dc4cb7e44a2ab60fd81b6fde39a4bf0cdcf Mon Sep 17 00:00:00 2001 From: Jim Ma Date: Wed, 22 Apr 2020 15:52:34 +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 df4ab7bfb..98b1e4ff7 100644 --- a/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java +++ b/examples/src/main/java/jaxrs/examples/sse/ServerSentEventsResource.java @@ -99,6 +99,8 @@ public void startDomain(@PathParam("id") final String id, eventSink.close(); } catch (final InterruptedException e) { e.printStackTrace(); + } catch (IOException ioe) { + //handle io 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; }