mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-01-11 15:29:48 -05:00
synchronize chat messages to avoid concurrency exception
This commit is contained in:
parent
dc015ad83d
commit
548cae004d
@ -1210,20 +1210,24 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
||||||
|
synchronized (chatMessages) {
|
||||||
if (!chatMessages.contains(chatMessage)) {
|
if (!chatMessages.contains(chatMessage)) {
|
||||||
chatMessages.add(chatMessage);
|
chatMessages.add(chatMessage);
|
||||||
} else {
|
} else {
|
||||||
log.error("Trade ChatMessage already exists");
|
log.error("Trade ChatMessage already exists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean removeAllChatMessages() {
|
public boolean removeAllChatMessages() {
|
||||||
|
synchronized (chatMessages) {
|
||||||
if (chatMessages.size() > 0) {
|
if (chatMessages.size() > 0) {
|
||||||
chatMessages.clear();
|
chatMessages.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean mediationResultAppliedPenaltyToSeller() {
|
public boolean mediationResultAppliedPenaltyToSeller() {
|
||||||
// If mediated payout is same or more then normal payout we enable otherwise a penalty was applied
|
// If mediated payout is same or more then normal payout we enable otherwise a penalty was applied
|
||||||
@ -1646,6 +1650,12 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
|
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableList<ChatMessage> getChatMessages() {
|
||||||
|
synchronized (chatMessages) {
|
||||||
|
return FXCollections.observableArrayList(chatMessages);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MessageState getPaymentSentMessageState() {
|
public MessageState getPaymentSentMessageState() {
|
||||||
if (isPaymentReceived()) return MessageState.ACKNOWLEDGED;
|
if (isPaymentReceived()) return MessageState.ACKNOWLEDGED;
|
||||||
if (processModel.getPaymentSentMessageStateProperty().get() == MessageState.ACKNOWLEDGED) return MessageState.ACKNOWLEDGED;
|
if (processModel.getPaymentSentMessageStateProperty().get() == MessageState.ACKNOWLEDGED) return MessageState.ACKNOWLEDGED;
|
||||||
@ -2296,7 +2306,7 @@ public abstract class Trade implements Tradable, Model {
|
|||||||
.setPayoutState(Trade.PayoutState.toProtoMessage(payoutState))
|
.setPayoutState(Trade.PayoutState.toProtoMessage(payoutState))
|
||||||
.setDisputeState(Trade.DisputeState.toProtoMessage(disputeState))
|
.setDisputeState(Trade.DisputeState.toProtoMessage(disputeState))
|
||||||
.setPeriodState(Trade.TradePeriodState.toProtoMessage(periodState))
|
.setPeriodState(Trade.TradePeriodState.toProtoMessage(periodState))
|
||||||
.addAllChatMessage(chatMessages.stream()
|
.addAllChatMessage(getChatMessages().stream()
|
||||||
.map(msg -> msg.toProtoNetworkEnvelope().getChatMessage())
|
.map(msg -> msg.toProtoNetworkEnvelope().getChatMessage())
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.setLockTime(lockTime)
|
.setLockTime(lockTime)
|
||||||
|
Loading…
Reference in New Issue
Block a user