mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 10:49:41 +02:00
Synchronize PacketWriter shutdown
try the best to send the queue elements and the closing stream element.
This commit is contained in:
parent
74d188aabb
commit
07d6b9203c
2 changed files with 30 additions and 3 deletions
|
@ -83,6 +83,8 @@ public class PacketWriterTest {
|
|||
// Not really cool, but may increases the chances for 't' to block in sendPacket.
|
||||
Thread.sleep(250);
|
||||
|
||||
// Set to true for testing purposes, so that shutdown() won't wait packet writer
|
||||
pw.shutdownDone.set(true);
|
||||
// Shutdown the packetwriter
|
||||
pw.shutdown();
|
||||
shutdown = true;
|
||||
|
@ -90,13 +92,16 @@ public class PacketWriterTest {
|
|||
if (prematureUnblocked) {
|
||||
fail("Should not unblock before the thread got shutdown");
|
||||
}
|
||||
synchronized (t) {
|
||||
t.notify();
|
||||
}
|
||||
}
|
||||
|
||||
public class BlockingStringWriter extends Writer {
|
||||
@Override
|
||||
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||
try {
|
||||
Thread.sleep(Integer.MAX_VALUE);
|
||||
wait();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue