TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.54k stars 2.58k forks source link

Have connectBlocking clean up after a timeout #1399

Closed ysi-camerona closed 9 months ago

ysi-camerona commented 9 months ago

Related Issue

Fixes #1397

Motivation and Context

Previously, connectBlocking(long, TimeUnit) would return a boolean indicating whether the connection was set up in the given window. If false was returned, we would continue to attempt connecting in the background. This PR updates connectBlocking(long, TimeUnit) to perform cleanup on timeout.

How Has This Been Tested?

Types of changes

Checklist:

Note: I spent a couple hours spiking a unit test around this change but couldn't come up with anything solid. I found it difficult to simulate the "drop packets mid-connection" firewall rule listed in the linked issue. If we think this is necessary to test, advice on testing would be appreciated.

PhilipRoman commented 9 months ago

I think I know how to make a unit test for this, I will implement it in the next few days.