Manevolent / ts3j

An open-source Java Teamspeak 3 client library using the TS3 full client protocol
Apache License 2.0
107 stars 15 forks source link

Threads not interrupted in AbstractTeamspeakClientSocket #9

Closed matobodo closed 4 years ago

matobodo commented 4 years ago

Application is not exiting due to running threads

LocalTeamspeakClientSocket client = new LocalTeamspeakClientSocket();
client.setNickname(...);
client.setHWID(...);
client.setIdentity(...);
client.connect(...);
// Stay connected for a while
Thread.sleep(10000);
client.disconnect();
client.close();

These threads are still running after disconnecting and closing the client

TS3J AudioThread
TS3J/NetworkHandler/{thread ID}
TS3J/NetworkReader/{thread ID}

The issue with 1st thread is in LocalTeamSpeakClientSocket, this.microphoneThread is nowhere interrupted.

The issue with the 2nd and 3rd thread is in AbstractTeamspeakClientSocket when the setReading(boolean b) method (line 858) is called after disconnecting, this.networkThread and this.handlerThread are always null because they are never assigned. In the start() method (line 149) there are only local variables.

Manevolent commented 4 years ago

I just made this commit to address this, my ServerConnectionTest exits properly now: https://github.com/Manevolent/ts3j/commit/614b3d9d698fc5afe783dcff1b9def37718e7b8f