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

NPE during reconnect #1364

Closed
Xander-Polishchuk opened this issue Oct 17, 2023 · 1 comment · Fixed by #1367
Closed

NPE during reconnect #1364

Xander-Polishchuk opened this issue Oct 17, 2023 · 1 comment · Fixed by #1367
Assignees
Milestone

Comments

@Xander-Polishchuk
Copy link

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

  • connectReadThread set to null at WebSocketClient.java:526
  • while countdown is called in a callback in engine.closeConnection WebSocketClient.java:524

To Reproduce
Steps to reproduce the behavior:

  1. Setup WS server
  2. Connect
  3. 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
@Xander-Polishchuk
Copy link
Author

While was trying to reproduce I identified another bug with WebSocketClient#closeBlocking, it sometimes gets stuck on closeLatch.await(), I'm going to create another bug for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants