fix possible concurrent modification exception
This commit is contained in:
parent
cebdef31c0
commit
4901808844
@ -91,6 +91,7 @@ import javafx.collections.ObservableList;
|
|||||||
|
|
||||||
import org.bouncycastle.crypto.params.KeyParameter;
|
import org.bouncycastle.crypto.params.KeyParameter;
|
||||||
import org.fxmisc.easybind.EasyBind;
|
import org.fxmisc.easybind.EasyBind;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -881,24 +882,22 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateTradePeriodState() {
|
private void updateTradePeriodState() {
|
||||||
UserThread.execute(() -> { // prevent concurrent modification error
|
for (Trade trade : new ArrayList<Trade>(tradableList.getList())) {
|
||||||
getObservableList().forEach(trade -> {
|
if (!trade.isPayoutPublished()) {
|
||||||
if (!trade.isPayoutPublished()) {
|
Date maxTradePeriodDate = trade.getMaxTradePeriodDate();
|
||||||
Date maxTradePeriodDate = trade.getMaxTradePeriodDate();
|
Date halfTradePeriodDate = trade.getHalfTradePeriodDate();
|
||||||
Date halfTradePeriodDate = trade.getHalfTradePeriodDate();
|
if (maxTradePeriodDate != null && halfTradePeriodDate != null) {
|
||||||
if (maxTradePeriodDate != null && halfTradePeriodDate != null) {
|
Date now = new Date();
|
||||||
Date now = new Date();
|
if (now.after(maxTradePeriodDate)) {
|
||||||
if (now.after(maxTradePeriodDate)) {
|
trade.setPeriodState(Trade.TradePeriodState.TRADE_PERIOD_OVER);
|
||||||
trade.setPeriodState(Trade.TradePeriodState.TRADE_PERIOD_OVER);
|
requestPersistence();
|
||||||
requestPersistence();
|
} else if (now.after(halfTradePeriodDate)) {
|
||||||
} else if (now.after(halfTradePeriodDate)) {
|
trade.setPeriodState(Trade.TradePeriodState.SECOND_HALF);
|
||||||
trade.setPeriodState(Trade.TradePeriodState.SECOND_HALF);
|
requestPersistence();
|
||||||
requestPersistence();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user