Add null check

This commit is contained in:
Manfred Karrer 2014-11-19 14:33:39 +01:00
parent 3c6f31a421
commit aff235dbb0

View file

@ -323,14 +323,20 @@ public class TomP2PNode implements ClientNode {
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (peerDHT != null && !storedPeerAddress.equals(peerDHT.peerAddress())) {
try {
storeAddress();
} catch (IOException e) {
e.printStackTrace();
log.error(e.toString());
if (storedPeerAddress != null) {
if (peerDHT != null && !storedPeerAddress.equals(peerDHT.peerAddress())) {
try {
storeAddress();
} catch (IOException e) {
e.printStackTrace();
log.error(e.toString());
}
}
}
else {
log.error("storedPeerAddress is null. That should not happen. " +
"Seems there is a problem with DHT storage.");
}
}
}, checkIfIPChangedPeriod, checkIfIPChangedPeriod);
}