Copy managers list to prevent ConcurrentModificationException

This commit is contained in:
AsamK 2021-12-05 15:15:53 +01:00
parent 16bf7af297
commit c9928043b2

View file

@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -124,7 +125,7 @@ public class MultiAccountManagerImpl implements MultiAccountManager {
@Override @Override
public void close() { public void close() {
synchronized (managers) { synchronized (managers) {
for (var m : managers) { for (var m : new ArrayList<>(managers)) {
try { try {
m.close(); m.close();
} catch (IOException e) { } catch (IOException e) {