Add null checks

This commit is contained in:
Manfred Karrer 2016-03-20 19:08:37 +01:00
parent 19eb61f30c
commit e7967cc0e1
3 changed files with 3 additions and 2 deletions

View file

@ -288,7 +288,7 @@ public final class Offer implements StoragePayload, RequiresOwnerIsOnlinePayload
@Override
public PublicKey getOwnerPubKey() {
return pubKeyRing.getSignaturePubKey();
return pubKeyRing != null ? pubKeyRing.getSignaturePubKey() : null;
}
public long getProtocolVersion() {

View file

@ -540,6 +540,7 @@ public class Connection implements MessageListener {
} else if (e instanceof EOFException || e instanceof StreamCorruptedException) {
closeConnectionReason = CloseConnectionReason.TERMINATED;
} else {
// TODO sometimes we get StreamCorruptedException, OptionalDataException, IllegalStateException
closeConnectionReason = CloseConnectionReason.UNKNOWN_EXCEPTION;
log.warn("Unknown reason for exception at socket {}\n\tconnection={}\n\tException=",
socket.toString(), this, e.toString());

View file

@ -443,7 +443,7 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
result = expirableMailboxStoragePayload.receiverPubKeyForRemoveOperation.equals(protectedStorageEntry.ownerPubKey);
} else {
result = protectedStorageEntry != null && protectedStorageEntry.getStoragePayload() != null &&
protectedStorageEntry.getStoragePayload().getOwnerPubKey().equals(protectedStorageEntry.ownerPubKey);
protectedStorageEntry.ownerPubKey.equals(protectedStorageEntry.getStoragePayload().getOwnerPubKey());
}
if (!result)