Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,13 @@ protected void handleTextMessage(WebSocketSession session, TextMessage webSocket
}

private void handleInternal(WebSocketSession session, TextMessage webSocketMessage) throws IOException {
SessionState state = this.sessionInfoMap.get(session.getId());
if (state == null) {
return;
}
GraphQlWebSocketMessage message = decode(webSocketMessage);
String id = message.getId();
Map<String, Object> payload = message.getPayload();
SessionState state = getSessionInfo(session);
switch (message.resolvedType()) {
case SUBSCRIBE -> {
if (state.getConnectionInitPayload() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@

import static org.assertj.core.api.Assertions.as;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import static org.mockito.Mockito.mock;
import static org.springframework.graphql.server.support.GraphQlWebSocketMessageType.CONNECTION_ACK;
import static org.springframework.graphql.server.support.GraphQlWebSocketMessageType.PING;
Expand Down Expand Up @@ -273,6 +274,22 @@ public void handleConnectionClosed(WebSocketSessionInfo info, int status, Map<St
assertThat(called).isTrue();
}

@Test
void messageAfterConnectionClosed() throws Exception {
handle(this.handler, new TextMessage("{\"type\":\"connection_init\"}"));

StepVerifier.create(this.session.getOutput())
.consumeNextWith((message) -> assertMessageType(message, GraphQlWebSocketMessageType.CONNECTION_ACK))
.then(this.session::close)
.expectComplete()
.verify(TIMEOUT);

this.handler.afterConnectionClosed(this.session, CloseStatus.NORMAL);

assertThatNoException().isThrownBy(() ->
this.handler.handleTextMessage(this.session, new TextMessage("{\"type\":\"ping\"}")));
}

@Test
void connectionInitRejected() throws Exception {

Expand Down