Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UNDERTOW-2503] Review anonymous classes in Undertow io.undertow.websockets.jsr.test.reconnect #1700

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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 @@ -69,22 +69,7 @@ public static void setup() throws Exception {
.setWorker(DefaultServer.getWorkerSupplier())
.addEndpoint(DisconnectServerEndpoint.class)
.addEndpoint(AnnotatedClientReconnectEndpoint.class)
.addListener(containerReady -> deployment = containerReady).setReconnectHandler(new WebSocketReconnectHandler() {
@Override
public long disconnected(CloseReason closeReason, URI connectionUri, Session session, int disconnectCount) {
if (disconnectCount < 3) {
return 1;
} else {
return -1;
}
}

@Override
public long reconnectFailed(IOException exception, URI connectionUri, Session session, int failedCount) {
failed = true;
return -1;
}
})
.addListener(containerReady -> deployment = containerReady).setReconnectHandler(new CustomWebSocketReconnectHandler())
)
.setDeploymentName("servletContext.war");
deploymentManager = container.addDeployment(builder);
Expand Down Expand Up @@ -125,4 +110,22 @@ public void testAnnotatedClientEndpoint() throws Exception {
Assert.assertNull(endpoint.quickMessage());
Assert.assertFalse(failed);
}

private static class CustomWebSocketReconnectHandler implements WebSocketReconnectHandler {

@Override
public long disconnected(CloseReason closeReason, URI connectionUri, Session session, int disconnectCount) {
if (disconnectCount < 3) {
return 1;
} else {
return -1;
}
}

@Override
public long reconnectFailed(IOException exception, URI connectionUri, Session session, int failedCount) {
failed = true;
return -1;
}
}
}
Loading