mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-10 05:03:35 +01:00
synchronize chat messages to avoid concurrency exception
This commit is contained in:
parent
dc015ad83d
commit
548cae004d
@ -1210,19 +1210,23 @@ public abstract class Trade implements Tradable, Model {
|
||||
}
|
||||
|
||||
public void addAndPersistChatMessage(ChatMessage chatMessage) {
|
||||
if (!chatMessages.contains(chatMessage)) {
|
||||
chatMessages.add(chatMessage);
|
||||
} else {
|
||||
log.error("Trade ChatMessage already exists");
|
||||
synchronized (chatMessages) {
|
||||
if (!chatMessages.contains(chatMessage)) {
|
||||
chatMessages.add(chatMessage);
|
||||
} else {
|
||||
log.error("Trade ChatMessage already exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean removeAllChatMessages() {
|
||||
if (chatMessages.size() > 0) {
|
||||
chatMessages.clear();
|
||||
return true;
|
||||
synchronized (chatMessages) {
|
||||
if (chatMessages.size() > 0) {
|
||||
chatMessages.clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean mediationResultAppliedPenaltyToSeller() {
|
||||
@ -1646,6 +1650,12 @@ public abstract class Trade implements Tradable, Model {
|
||||
throw new IllegalArgumentException("Trade is not buyer, seller, or arbitrator");
|
||||
}
|
||||
|
||||
public ObservableList<ChatMessage> getChatMessages() {
|
||||
synchronized (chatMessages) {
|
||||
return FXCollections.observableArrayList(chatMessages);
|
||||
}
|
||||
}
|
||||
|
||||
public MessageState getPaymentSentMessageState() {
|
||||
if (isPaymentReceived()) 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))
|
||||
.setDisputeState(Trade.DisputeState.toProtoMessage(disputeState))
|
||||
.setPeriodState(Trade.TradePeriodState.toProtoMessage(periodState))
|
||||
.addAllChatMessage(chatMessages.stream()
|
||||
.addAllChatMessage(getChatMessages().stream()
|
||||
.map(msg -> msg.toProtoNetworkEnvelope().getChatMessage())
|
||||
.collect(Collectors.toList()))
|
||||
.setLockTime(lockTime)
|
||||
|
Loading…
Reference in New Issue
Block a user