mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 07:46:05 -04:00
Fix ArrayIndexOutOfBoundsException at remove
This commit is contained in:
parent
8bf4e88c1f
commit
afb8c18d31
@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
@ -67,7 +68,16 @@ public class OfferBook {
|
||||
// clean up possible references in openOfferManager
|
||||
tradeManager.onOfferRemovedFromRemoteOfferBook(offer);
|
||||
|
||||
offerBookListItems.removeIf(item -> item.getOffer().getId().equals(offer.getId()));
|
||||
Optional<OfferBookListItem> candidate = offerBookListItems.stream().filter(item -> item.getOffer().getId().equals(offer.getId())).findAny();
|
||||
if (candidate.isPresent()) {
|
||||
try {
|
||||
OfferBookListItem item = candidate.get();
|
||||
if (offerBookListItems.contains(item))
|
||||
offerBookListItems.remove(item);
|
||||
} catch (Throwable t) {
|
||||
log.error(" offerBookListItems.remove failed " + t.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user