Skip to content

Commit

Permalink
Add channel to the WebsocketConsumerServerHandler.CHANNELS before h…
Browse files Browse the repository at this point in the history
…andshake

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
  • Loading branch information
artembilan committed Oct 16, 2024
1 parent ad70362 commit 69dade5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ private void handleHttpRequest(ChannelHandlerContext ctx, FullHttpRequest req) {
WebSocketServerHandshakerFactory.sendUnsupportedVersionResponse(ctx.channel());
}
else {
this.handshaker.handshake(ctx.channel(), req);
WebsocketConsumerServer.CHANNELS.add(ctx.channel());
this.handshaker.handshake(ctx.channel(), req);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit 69dade5

Please sign in to comment.