Skip to content

Commit

Permalink
Management SSE for apps fails when Accept-Encoding is sent #8518
Browse files Browse the repository at this point in the history
  • Loading branch information
rymsha committed Dec 1, 2020
1 parent 0f1d172 commit 6409dfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ public void deactivate()
@Context
public void setSse( final Sse sse )
{
this.contextHolder = new SseContextHolder( sse );
final SseContextHolder ctx = contextHolder;
if ( ctx == null )
{
this.contextHolder = new SseContextHolder( sse );
}
}

@GET
Expand All @@ -88,11 +92,9 @@ public void subscribe( final @Context SseEventSink sseEventSink )

if ( ctx == null )
{
return;
throw new IllegalStateException( "No SSE context" );
}

ctx.broadcaster.register( sseEventSink );

final OutboundSseEvent sseEvent = ctx.sse.newEventBuilder().
name( "list" ).
id( UUID.randomUUID().toString() ).
Expand All @@ -102,6 +104,8 @@ public void subscribe( final @Context SseEventSink sseEventSink )
collect( Collectors.toList() ) ) ).build();

sseEventSink.send( sseEvent );

ctx.broadcaster.register( sseEventSink );
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.doNothing;
Expand Down Expand Up @@ -199,7 +200,7 @@ public void testSubscribe_NoSseContext()
{
final SseEventSink eventSink = mock( SseEventSink.class );

listener.subscribe( eventSink );
assertThrows( IllegalStateException.class, () -> listener.subscribe( eventSink ) );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected void doConfigure()
handler.setExcludedAgentPatterns();
handler.setMinGzipSize( this.config.gzip_minSize() );
handler.addExcludedMimeTypes( "application/octet-stream" );
handler.addExcludedMimeTypes( "text/event-stream" );

this.object.setGzipHandler( handler );
}
Expand Down

0 comments on commit 6409dfe

Please sign in to comment.