Skip to content

Commit 313a8c7

Browse files
committed
Fix warning messages when shutting down the query.
1 parent c094b2b commit 313a8c7

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/main/java/com/github/theholywaffle/teamspeak3/SocketReader.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
*/
2828

2929
import com.github.theholywaffle.teamspeak3.api.Callback;
30+
import com.github.theholywaffle.teamspeak3.commands.CQuit;
3031
import com.github.theholywaffle.teamspeak3.commands.Command;
3132

3233
import java.io.BufferedReader;
@@ -73,13 +74,15 @@ public void run() {
7374
line = in.readLine();
7475
} catch (IOException io) {
7576
if (!isInterrupted()) {
76-
io.printStackTrace();
77+
TS3Query.log.log(Level.WARNING, "Connection error occurred.", io);
7778
}
7879
break;
7980
}
8081

8182
if (line == null) {
82-
break; // The underlying socket was closed
83+
// End of stream: connection terminated by server
84+
TS3Query.log.warning("Connection closed by the server.");
85+
break;
8386
} else if (line.isEmpty()) {
8487
continue; // The server is sending garbage
8588
}
@@ -102,6 +105,11 @@ public void run() {
102105
} else if (c != null && c.isSent()) {
103106
TS3Query.log.info("[" + c.getName() + "] < " + line);
104107
if (line.startsWith("error")) {
108+
if (c instanceof CQuit) {
109+
// Response to a quit command received, we're done
110+
interrupt();
111+
}
112+
105113
c.feedError(line.substring("error ".length()));
106114
if (c.getError().getId() != 0) {
107115
TS3Query.log.severe("TS3 command error: " + c.getError());

src/main/java/com/github/theholywaffle/teamspeak3/TS3Query.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public void exit() {
120120
// This will guarantee that all previously sent commands have been processed
121121
doCommand(new CQuit());
122122

123-
userThreadPool.shutdown();
124123
io.disconnect();
124+
userThreadPool.shutdown();
125125
for (final Handler lh : log.getHandlers()) {
126126
log.removeHandler(lh);
127127
}

0 commit comments

Comments
 (0)