Add channel to the WebsocketConsumerServerHandler.CHANNELS before handshake

In attempt to fix a race condition in the tests

* Remove `log4j` deps as redundant: Spring Boot brings them anyway for logback compatibility
* Add `logback-test.xml` to the `spring-websocket-consumer.test` for test race condition failures
This commit is contained in:
Artem Bilan
2024-10-16 10:52:06 -04:00
parent ad70362c27
commit 69dade53de
4 changed files with 12 additions and 4 deletions

View File

@@ -140,9 +140,6 @@ configure(javaProjects) { subproject ->
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.testcontainers:junit-jupiter'
testRuntimeOnly 'org.apache.logging.log4j:log4j-core'
testRuntimeOnly 'org.apache.logging.log4j:log4j-jcl'
// NOTE: We explicitly specify checkstyle dep before javaformat checkstyle due to antlr class mismatch
checkstyle("com.puppycrawl.tools:checkstyle:${checkstyle.toolVersion}")
checkstyle("io.spring.javaformat:spring-javaformat-checkstyle:${javaFormatVersion}")

View File

@@ -120,8 +120,8 @@ public class WebsocketConsumerServerHandler extends SimpleChannelInboundHandler<
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
}
else {
this.handshaker.handshake(ctx.channel(), req);
WebsocketConsumerServer.CHANNELS.add(ctx.channel());
this.handshaker.handshake(ctx.channel(), req);
}
}

View File

@@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
<logger name="org.springframework" level="DEBUG" />
</configuration>