Skip to content

Commit

Permalink
Take ReaderInterceptor into account when reading SSE events
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Oct 16, 2023
1 parent 2a2e719 commit 6a84fe9
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.ext.ReaderInterceptor;
import jakarta.ws.rs.sse.InboundSseEvent;
import jakarta.ws.rs.sse.SseEvent;

Expand All @@ -24,12 +25,18 @@ public class InboundSseEventImpl implements InboundSseEvent {
private String data;
private MediaType mediaType;
private long reconnectDelay = SseEvent.RECONNECT_NOT_SET;
private Serialisers serialisers;
private ConfigurationImpl configuration;
private final Serialisers serialisers;
private final ConfigurationImpl configuration;
private final ReaderInterceptor[] interceptors;

public InboundSseEventImpl(ConfigurationImpl configuration, Serialisers serialisers) {
this.configuration = configuration;
this.serialisers = serialisers;
var interceptors = Serialisers.NO_READER_INTERCEPTOR;
if ((configuration != null) && configuration.getReaderInterceptors() != null) {
interceptors = configuration.getReaderInterceptors().toArray(Serialisers.NO_READER_INTERCEPTOR);
}
this.interceptors = interceptors;
}

public MediaType getMediaType() {
Expand Down Expand Up @@ -122,7 +129,7 @@ public <T> T readData(GenericType<T> type, MediaType mediaType) {
try {
return (T) ClientSerialisers.invokeClientReader(null, type.getRawType(), type.getType(),
mediaType, null, null, new QuarkusMultivaluedHashMap<>(),
serialisers, in, Serialisers.NO_READER_INTERCEPTOR, configuration);
serialisers, in, interceptors, configuration);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
Expand Down

0 comments on commit 6a84fe9

Please sign in to comment.