From 113a94b1f9d1b6993a0b61087a9347f8d606b61b Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 15 May 2024 17:16:52 -0400 Subject: [PATCH] fix concurrent modification exception in spread view --- .../main/market/spread/SpreadViewModel.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java index ec30ebef97..2e5f56f3b4 100644 --- a/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/market/spread/SpreadViewModel.java @@ -113,18 +113,20 @@ class SpreadViewModel extends ActivatableViewModel { private void update(ObservableList offerBookListItems) { Map> offersByCurrencyMap = new HashMap<>(); - for (OfferBookListItem offerBookListItem : offerBookListItems) { - Offer offer = offerBookListItem.getOffer(); - String key = offer.getCurrencyCode(); - if (includePaymentMethod) { - key = offer.getPaymentMethod().getShortName(); - if (expandedView) { - key += ":" + offer.getCurrencyCode(); + synchronized (offerBookListItems) { + for (OfferBookListItem offerBookListItem : offerBookListItems) { + Offer offer = offerBookListItem.getOffer(); + String key = offer.getCurrencyCode(); + if (includePaymentMethod) { + key = offer.getPaymentMethod().getShortName(); + if (expandedView) { + key += ":" + offer.getCurrencyCode(); + } } + if (!offersByCurrencyMap.containsKey(key)) + offersByCurrencyMap.put(key, new ArrayList<>()); + offersByCurrencyMap.get(key).add(offer); } - if (!offersByCurrencyMap.containsKey(key)) - offersByCurrencyMap.put(key, new ArrayList<>()); - offersByCurrencyMap.get(key).add(offer); } spreadItems.clear();