From 18c13339982eb6040c8356b90055933337ff8c32 Mon Sep 17 00:00:00 2001 From: chimp1984 <54558767+chimp1984@users.noreply.github.com> Date: Sun, 27 Oct 2019 03:53:35 -0500 Subject: [PATCH] Avoid null objects (#3481) * Avoid null objects * Remove check for type Historical data can be arbitration instead of mediation (arbitration was fallback at last update), so we need to tolerate the incorrect type here. Is only for tickets from pre 1.2. --- .../account/witness/AccountAgeWitnessService.java | 2 ++ .../dispute/mediation/MediationDisputeList.java | 12 +----------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java index 3e5a948f64d..7fe43ecc7d2 100644 --- a/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java +++ b/core/src/main/java/bisq/core/account/witness/AccountAgeWitnessService.java @@ -65,6 +65,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.Random; import java.util.concurrent.TimeUnit; @@ -616,6 +617,7 @@ public List getTraderPaymentAccounts(long safeDate, PaymentMetho .filter(this::hasChargebackRisk) .filter(this::isBuyerWinner) .flatMap(this::getTraderData) + .filter(Objects::nonNull) .filter(traderDataItem -> !signedWitnessService.isSignedAccountAgeWitness(traderDataItem.getAccountAgeWitness())) .filter(traderDataItem -> traderDataItem.getAccountAgeWitness().getDate() < safeDate) diff --git a/core/src/main/java/bisq/core/support/dispute/mediation/MediationDisputeList.java b/core/src/main/java/bisq/core/support/dispute/mediation/MediationDisputeList.java index 2b58f98d586..ce45e2fede5 100644 --- a/core/src/main/java/bisq/core/support/dispute/mediation/MediationDisputeList.java +++ b/core/src/main/java/bisq/core/support/dispute/mediation/MediationDisputeList.java @@ -18,7 +18,6 @@ package bisq.core.support.dispute.mediation; import bisq.core.proto.CoreProtoResolver; -import bisq.core.support.SupportType; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.DisputeList; @@ -34,8 +33,6 @@ import lombok.ToString; import lombok.extern.slf4j.Slf4j; -import static com.google.common.base.Preconditions.checkArgument; - @Slf4j @ToString /* @@ -69,9 +66,6 @@ private MediationDisputeList(Storage storage, List checkArgument(dispute.getSupportType().equals(SupportType.MEDIATION), "Support type has to be MEDIATION")); - return protobuf.PersistableEnvelope.newBuilder().setMediationDisputeList(protobuf.MediationDisputeList.newBuilder() .addAllDispute(ProtoUtil.collectionToProto(new ArrayList<>(list)))).build(); } @@ -82,11 +76,7 @@ public static MediationDisputeList fromProto(protobuf.MediationDisputeList proto List list = proto.getDisputeList().stream() .map(disputeProto -> Dispute.fromProto(disputeProto, coreProtoResolver)) .collect(Collectors.toList()); - - list.forEach(e -> { - checkArgument(e.getSupportType().equals(SupportType.MEDIATION), "Support type has to be MEDIATION"); - e.setStorage(storage); - }); + list.forEach(e -> e.setStorage(storage)); return new MediationDisputeList(storage, list); } }