-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
Describe the bug
It's possible to get NPE in reconnectBlocking(), due to a race with previously running client connection thread.
The race happens due to closeLatch countdown called before connectReadThread is set to null in run
connectReadThreadset to null atWebSocketClient.java:526- while countdown is called in a callback in
engine.closeConnectionWebSocketClient.java:524
To Reproduce
Steps to reproduce the behavior:
- Setup WS server
- Connect
- Call
reconnectBlocking()in a loop until NPE
Expected behavior
No NPE on reconnectBlocking()
Debug log
java.lang.NullPointerException: Cannot invoke "java.lang.Thread.start()" because "this.connectReadThread" is null
at org.java_websocket.client.WebSocketClient.connect(WebSocketClient.java:376)
at org.java_websocket.client.WebSocketClient.connectBlocking(WebSocketClient.java:386)
at org.java_websocket.client.WebSocketClient.reconnectBlocking(WebSocketClient.java:328)
at org.web3j.protocol.websocket.WebSocketService.connectToWebSocket(WebSocketService.java:140)
Environment(please complete the following information):
- Version used: 1.5.4
- Java version: 17
- Operating System and version: GCP, Linux container