mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-25 07:07:39 +01:00
Fix race in TestWithNetworkConnections
There was a nasty bug where a connection-failed interrupt was run afer any interruptible calls were made, making the next test-case fail due to interruption.
This commit is contained in:
parent
f7a944983c
commit
c61ec5023e
1 changed files with 8 additions and 3 deletions
|
@ -117,8 +117,10 @@ public class TestWithNetworkConnections {
|
|||
peer.addEventListener(new AbstractPeerEventListener() {
|
||||
@Override
|
||||
public void onPeerDisconnected(Peer p, int peerCount) {
|
||||
if (!doneConnecting.get())
|
||||
thisThread.interrupt();
|
||||
synchronized (doneConnecting) {
|
||||
if (!doneConnecting.get())
|
||||
thisThread.interrupt();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (clientType == ClientType.NIO_CLIENT_MANAGER || clientType == ClientType.BLOCKING_CLIENT_MANAGER)
|
||||
|
@ -138,7 +140,10 @@ public class TestWithNetworkConnections {
|
|||
try {
|
||||
assertTrue(writeTarget.nextMessageBlocking() instanceof VersionMessage);
|
||||
assertTrue(writeTarget.nextMessageBlocking() instanceof VersionAck);
|
||||
doneConnecting.set(true);
|
||||
synchronized (doneConnecting) {
|
||||
doneConnecting.set(true);
|
||||
}
|
||||
Thread.interrupted(); // Clear interrupted bit in case it was set before we got into the CS
|
||||
} catch (InterruptedException e) {
|
||||
// We were disconnected before we got back version/verack
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue