Skip to content

Commit

Permalink
Avoid null objects (#3481)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
chimp1984 authored and sqrrm committed Oct 27, 2019
1 parent 8a000c1 commit 18c1333
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -616,6 +617,7 @@ public List<TraderDataItem> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -34,8 +33,6 @@
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import static com.google.common.base.Preconditions.checkArgument;

@Slf4j
@ToString
/*
Expand Down Expand Up @@ -69,9 +66,6 @@ private MediationDisputeList(Storage<MediationDisputeList> storage, List<Dispute

@Override
public Message toProtoMessage() {

list.forEach(dispute -> 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();
}
Expand All @@ -82,11 +76,7 @@ public static MediationDisputeList fromProto(protobuf.MediationDisputeList proto
List<Dispute> 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);
}
}

0 comments on commit 18c1333

Please sign in to comment.