Skip to content

Commit f0bbb97

Browse files
committed
PR feedback
1 parent 213b150 commit f0bbb97

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/de/rwth/idsg/steve/ocpp/ws/SessionContextStoreImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ public void closeSessions(String chargeBoxId) {
142142
if (endpointDeque == null) {
143143
return;
144144
}
145-
for (SessionContext sessionContext : endpointDeque) {
145+
146+
// To prevent a ConcurrentModificationException, iterate over a copy of
147+
// endpointDeque when closing sessions. The close() operation can trigger an event
148+
// that modifies the deque, causing an error.
149+
for (SessionContext sessionContext : new ArrayDeque<>(endpointDeque)) {
146150
try {
147151
sessionContext.getSession().close();
148152
} catch (IOException e) {

0 commit comments

Comments
 (0)