Remove awaitUninterruptibly() in listener (can cause a deadlock)

This commit is contained in:
Manfred Karrer 2014-10-29 00:31:16 +01:00
parent 74fa325aee
commit f91b0ba349

View file

@ -152,7 +152,7 @@ public class BootstrappedPeerFactory {
FutureDiscover futureDiscover; FutureDiscover futureDiscover;
// just temporary while port forwarding is not working // just temporary while port forwarding is not working
lastSuccessfulBootstrap = "relay"; //lastSuccessfulBootstrap = "relay";
switch (lastSuccessfulBootstrap) { switch (lastSuccessfulBootstrap) {
case "relay": case "relay":
@ -203,7 +203,7 @@ public class BootstrappedPeerFactory {
@Override @Override
public void exceptionCaught(Throwable t) throws Exception { public void exceptionCaught(Throwable t) throws Exception {
setState("Exception at discover: " + t.getMessage(), false); setState("Exception at discover: " + t.getMessage(), false);
peerDHT.shutdown().awaitUninterruptibly(); peerDHT.shutdown();
settableFuture.setException(t); settableFuture.setException(t);
} }
}); });
@ -231,7 +231,7 @@ public class BootstrappedPeerFactory {
@Override @Override
public void exceptionCaught(Throwable t) throws Exception { public void exceptionCaught(Throwable t) throws Exception {
setState("Exception at port forwarding: " + t.getMessage(), false); setState("Exception at port forwarding: " + t.getMessage(), false);
peerDHT.shutdown().awaitUninterruptibly(); peerDHT.shutdown();
settableFuture.setException(t); settableFuture.setException(t);
} }
}); });
@ -253,7 +253,7 @@ public class BootstrappedPeerFactory {
setState("Discover with automatic port forwarding has failed " + futureDiscover setState("Discover with automatic port forwarding has failed " + futureDiscover
.failedReason(), false); .failedReason(), false);
persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default"); persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default");
peerDHT.shutdown().awaitUninterruptibly(); peerDHT.shutdown();
settableFuture.setException(new Exception("Discover with automatic port forwarding failed " + settableFuture.setException(new Exception("Discover with automatic port forwarding failed " +
futureDiscover.failedReason())); futureDiscover.failedReason()));
} }
@ -263,7 +263,7 @@ public class BootstrappedPeerFactory {
public void exceptionCaught(Throwable t) throws Exception { public void exceptionCaught(Throwable t) throws Exception {
setState("Exception at discover: " + t, false); setState("Exception at discover: " + t, false);
persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default"); persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default");
peerDHT.shutdown().awaitUninterruptibly(); peerDHT.shutdown();
settableFuture.setException(t); settableFuture.setException(t);
} }
}); });
@ -286,7 +286,7 @@ public class BootstrappedPeerFactory {
setState("Bootstrap using relay has failed " + futureRelayNAT.failedReason(), false); setState("Bootstrap using relay has failed " + futureRelayNAT.failedReason(), false);
persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default"); persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default");
futureRelayNAT.shutdown(); futureRelayNAT.shutdown();
peerDHT.shutdown().awaitUninterruptibly(); peerDHT.shutdown();
settableFuture.setException(new Exception("Bootstrap using relay failed " + settableFuture.setException(new Exception("Bootstrap using relay failed " +
futureRelayNAT.failedReason())); futureRelayNAT.failedReason()));
} }
@ -297,7 +297,7 @@ public class BootstrappedPeerFactory {
setState("Exception at bootstrapWithRelay: " + t, false); setState("Exception at bootstrapWithRelay: " + t, false);
persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default"); persistence.write(BootstrappedPeerFactory.this, "lastSuccessfulBootstrap", "default");
futureRelayNAT.shutdown(); futureRelayNAT.shutdown();
peerDHT.shutdown().awaitUninterruptibly(); peerDHT.shutdown();
settableFuture.setException(t); settableFuture.setException(t);
} }
}); });