Add null checks

This commit is contained in:
Manfred Karrer 2016-06-03 12:02:24 +02:00
parent 3c5da3007a
commit b1a8cec3f8
3 changed files with 9 additions and 6 deletions

View file

@ -194,8 +194,10 @@ public class PriceFeed {
Futures.addCallback(future, new FutureCallback<MarketPrice>() { Futures.addCallback(future, new FutureCallback<MarketPrice>() {
public void onSuccess(MarketPrice marketPrice) { public void onSuccess(MarketPrice marketPrice) {
UserThread.execute(() -> { UserThread.execute(() -> {
cache.put(marketPrice.currencyCode, marketPrice); if (marketPrice != null && priceConsumer != null) {
priceConsumer.accept(marketPrice.getPrice(type)); cache.put(marketPrice.currencyCode, marketPrice);
priceConsumer.accept(marketPrice.getPrice(type));
}
}); });
} }

View file

@ -696,7 +696,7 @@ public class Connection implements MessageListener {
exceeds = size > MAX_MSG_SIZE_GET_DATA; exceeds = size > MAX_MSG_SIZE_GET_DATA;
else else
exceeds = size > MAX_MSG_SIZE; exceeds = size > MAX_MSG_SIZE;
if (exceeds) if (exceeds)
log.warn("size > MAX_MSG_SIZE. size={}; object={}", size, message); log.warn("size > MAX_MSG_SIZE. size={}; object={}", size, message);
@ -793,7 +793,8 @@ public class Connection implements MessageListener {
} catch (Throwable t) { } catch (Throwable t) {
t.printStackTrace(); t.printStackTrace();
stop(); stop();
sharedModel.handleConnectionException(new Exception(t)); if (sharedModel != null)
sharedModel.handleConnectionException(new Exception(t));
} }
} }
} catch (Throwable t) { } catch (Throwable t) {

View file

@ -103,8 +103,8 @@ public final class MailboxStoragePayload implements StoragePayload {
public String toString() { public String toString() {
return "MailboxStoragePayload{" + return "MailboxStoragePayload{" +
"prefixedSealedAndSignedMessage=" + prefixedSealedAndSignedMessage + "prefixedSealedAndSignedMessage=" + prefixedSealedAndSignedMessage +
", senderStoragePublicKey.hashCode()=" + senderPubKeyForAddOperation.hashCode() + ", senderPubKeyForAddOperation.hashCode()=" + (senderPubKeyForAddOperation != null ? senderPubKeyForAddOperation.hashCode() : "null") +
", receiverStoragePublicKey.hashCode()=" + receiverPubKeyForRemoveOperation.hashCode() + ", receiverPubKeyForRemoveOperation.hashCode()=" + (receiverPubKeyForRemoveOperation != null ? receiverPubKeyForRemoveOperation.hashCode() : "null") +
'}'; '}';
} }
} }