Skip to content

Commit b37f4d0

Browse files
committed
Clean up QueryIO#failRemainingCommands
1 parent 2b09a03 commit b37f4d0

File tree

1 file changed

+8
-5
lines changed
  • src/main/java/com/github/theholywaffle/teamspeak3

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
import java.io.IOException;
3737
import java.net.Socket;
38+
import java.util.ArrayList;
39+
import java.util.Collection;
3840
import java.util.concurrent.ArrayBlockingQueue;
3941
import java.util.concurrent.BlockingQueue;
4042
import java.util.concurrent.LinkedBlockingQueue;
@@ -120,11 +122,12 @@ public void disconnect() {
120122
}
121123

122124
void failRemainingCommands() {
123-
for (ResponseBuilder toReceive : receiveQueue) {
124-
toReceive.getCommand().getFuture().fail(new TS3QueryShutDownException());
125-
}
126-
for (Command toSend : sendQueue) {
127-
toSend.getFuture().fail(new TS3QueryShutDownException());
125+
Collection<Command> commands = new ArrayList<>(receiveQueue.size() + sendQueue.size() + 1);
126+
socketReader.drainCommandsTo(commands);
127+
socketWriter.drainCommandsTo(commands);
128+
129+
for (Command command : commands) {
130+
command.getFuture().fail(new TS3QueryShutDownException());
128131
}
129132
}
130133

0 commit comments

Comments
 (0)