mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 12:37:58 +01:00
Wait for Socks5TestProxy initialization
to prevent org.jivesoftware.smackx.bytestreams.socks5.Socks5ClientForInitiatorTest > shouldSuccessfullyEstablishConnectionAndActivateSocks5Proxy FAILED java.lang.NullPointerException at Socks5ClientForInitiatorTest.java:292
This commit is contained in:
parent
52673bad3c
commit
fe9606adb2
1 changed files with 19 additions and 0 deletions
|
@ -55,6 +55,8 @@ public class Socks5TestProxy {
|
|||
/* port of the test proxy */
|
||||
private int port = 7777;
|
||||
|
||||
private boolean startupComplete;
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*/
|
||||
|
@ -169,6 +171,19 @@ public class Socks5TestProxy {
|
|||
* @return socket or null if there is no socket for the given digest
|
||||
*/
|
||||
public Socket getSocket(String digest) {
|
||||
synchronized(this) {
|
||||
if (!startupComplete) {
|
||||
try {
|
||||
wait(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (!startupComplete) {
|
||||
throw new IllegalStateException("Startup of Socks5TestProxy failed within 5 seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.connectionMap.get(digest);
|
||||
}
|
||||
|
||||
|
@ -205,6 +220,10 @@ public class Socks5TestProxy {
|
|||
// initialize connection
|
||||
establishConnection(socket);
|
||||
|
||||
synchronized (this) {
|
||||
startupComplete = true;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
catch (SocketException e) {
|
||||
/* do nothing */
|
||||
|
|
Loading…
Reference in a new issue