TakahikoKawasaki / nv-websocket-client

High-quality WebSocket client implementation in Java.
Apache License 2.0
2.03k stars 292 forks source link

Cancel close timer after task execution #191

Closed RustedBones closed 1 year ago

RustedBones commented 5 years ago

Fixes #140

When WebSocket.disconnec(closeCode, reason, closeDelay) is called and the close frame is not received from the server, the CloseTask fires.

However, in this case, no cancelCloseTask is called, leading to leave the thread from the close timer waiting for a new task.

Solution: If CloseTask fires, cancel the timer since it is used for a one time scheduling only.

As stated in the [Timer](https://docs.oracle.com/javase/7/docs/api/java/util/Timer.html#cancel()) Javadoc, it is safe to cancel within the task

RustedBones commented 1 year ago

staled project. closing PR