Add null check

This commit is contained in:
Manfred Karrer 2015-04-05 16:59:28 +02:00
parent 22338a8d4d
commit f4f1f9f451
4 changed files with 13 additions and 5 deletions

View File

@ -22,7 +22,7 @@ import java.util.List;
public interface BootstrapNodes {
Node DIGITAL_OCEAN_1 = Node.at("digitalocean1.bitsquare.io", "188.226.179.109");
Node DIGITAL_OCEAN_1 = Node.at("digitalocean1.bitsquare.io", "188.226.179.109", 7366);
/**
* Alias to the default bootstrap node.
@ -33,7 +33,7 @@ public interface BootstrapNodes {
* A locally-running BootstrapNode instance.
* Typically used only for testing. Not included in results from {@link #all()}.
*/
Node LOCALHOST = Node.at("localhost", "127.0.0.1");
Node LOCALHOST = Node.at("localhost", "127.0.0.1", 7366);
/**
* All known public bootstrap nodes.

View File

@ -85,6 +85,7 @@ public final class Node {
try {
ServerSocket server = new ServerSocket(0);
port = server.getLocalPort();
log.debug("Random system port used for client: {}", port);
server.close();
} catch (IOException e) {
e.printStackTrace();

View File

@ -34,6 +34,7 @@ import javax.inject.Inject;
import net.tomp2p.dht.FutureGet;
import net.tomp2p.dht.FuturePut;
import net.tomp2p.dht.FutureRemove;
import net.tomp2p.futures.BaseFuture;
import net.tomp2p.futures.BaseFutureAdapter;
import net.tomp2p.futures.BaseFutureListener;
@ -174,8 +175,11 @@ public class TomP2PAddressService extends TomP2PDHTService implements AddressSer
private void removeAddress() {
try {
boolean success = removeDataFromMyProtectedDomain(locationKey).awaitUninterruptibly(1000);
log.debug("removeDataFromMyProtectedDomain success=" + success);
FutureRemove futureRemove = removeDataFromMyProtectedDomain(locationKey);
if (futureRemove != null) {
boolean success = futureRemove.awaitUninterruptibly(1000);
log.debug("removeDataFromMyProtectedDomain success=" + success);
}
} catch (Throwable t) {
t.printStackTrace();
log.error(t.getMessage());

View File

@ -130,7 +130,10 @@ public class TomP2PDHTService extends TomP2PService implements DHTService {
*/
public FutureRemove removeDataFromMyProtectedDomain(Number160 locationKey) {
log.trace("removeDataOfProtectedDomain");
return peerDHT.remove(locationKey).domainKey(pubKeyHashForMyDomain).keyPair(keyPair).start();
if (peerDHT != null)
return peerDHT.remove(locationKey).domainKey(pubKeyHashForMyDomain).keyPair(keyPair).start();
else
return null;
}
/**