From 316424b992f51e6ceed14781b07e204cc7323b30 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Wed, 4 Dec 2024 09:50:05 +0200 Subject: [PATCH] Polish PublisherResponseHandler --- .../server/handlers/PublisherResponseHandler.java | 12 ++++++------ .../reactive/server/jaxrs/SseEventSinkImpl.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java index 20110476a41f8e..9a82c247bca5f5 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/handlers/PublisherResponseHandler.java @@ -312,21 +312,21 @@ private boolean requiresChunkedStream(MediaType mediaType) { || mediaType.isCompatible(RestMediaType.APPLICATION_STREAM_JSON_TYPE); } + @SuppressWarnings("rawtypes") private void handleChunkedStreaming(ResteasyReactiveRequestContext requestContext, Publisher result, boolean json) { long demand = 1L; - if (result instanceof RestMulti.SyncRestMulti) { - RestMulti.SyncRestMulti rest = (RestMulti.SyncRestMulti) result; + if (result instanceof RestMulti.SyncRestMulti rest) { demand = rest.getDemand(); } result.subscribe( new StreamingMultiSubscriber(requestContext, streamingResponseCustomizers, result, json, demand, false)); } + @SuppressWarnings("rawtypes") private void handleStreaming(ResteasyReactiveRequestContext requestContext, Publisher result, boolean json) { long demand = 1L; boolean encodeAsJsonArray = true; - if (result instanceof RestMulti.SyncRestMulti) { - RestMulti.SyncRestMulti rest = (RestMulti.SyncRestMulti) result; + if (result instanceof RestMulti.SyncRestMulti rest) { demand = rest.getDemand(); encodeAsJsonArray = rest.encodeAsJsonArray(); } @@ -334,10 +334,10 @@ private void handleStreaming(ResteasyReactiveRequestContext requestContext, Publ encodeAsJsonArray)); } + @SuppressWarnings("rawtypes") private void handleSse(ResteasyReactiveRequestContext requestContext, Publisher result) { long demand; - if (result instanceof RestMulti.SyncRestMulti) { - RestMulti.SyncRestMulti rest = (RestMulti.SyncRestMulti) result; + if (result instanceof RestMulti.SyncRestMulti rest) { demand = rest.getDemand(); } else { demand = 1L; diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java index bce377a34da90d..c963813fe7e1e0 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/jaxrs/SseEventSinkImpl.java @@ -14,7 +14,7 @@ public class SseEventSinkImpl implements SseEventSink { public static final byte[] EMPTY_BUFFER = new byte[0]; - private ResteasyReactiveRequestContext context; + private final ResteasyReactiveRequestContext context; private SseBroadcasterImpl broadcaster; private boolean closed;