fix: ConcurrentModificationException

This commit is contained in:
huanghongxun 2020-04-23 08:02:55 +08:00
parent 02cb2a3fb1
commit 43de254a98
2 changed files with 8 additions and 13 deletions

View File

@ -100,12 +100,7 @@ public abstract class VersionList<T extends RemoteVersion> {
}
protected Collection<T> getVersionsImpl(String gameVersion) {
lock.readLock().lock();
try {
return versions.get(gameVersion);
} finally {
lock.readLock().unlock();
}
return versions.get(gameVersion);
}
/**
@ -115,7 +110,12 @@ public abstract class VersionList<T extends RemoteVersion> {
* @return the collection of specific remote versions
*/
public final Collection<T> getVersions(String gameVersion) {
return Collections.unmodifiableCollection(getVersionsImpl(gameVersion));
lock.readLock().lock();
try {
return Collections.unmodifiableCollection(new ArrayList<>(getVersionsImpl(gameVersion)));
} finally {
lock.readLock().unlock();
}
}
/**

View File

@ -45,12 +45,7 @@ public final class GameVersionList extends VersionList<GameRemoteVersion> {
@Override
protected Collection<GameRemoteVersion> getVersionsImpl(String gameVersion) {
lock.readLock().lock();
try {
return versions.values();
} finally {
lock.readLock().unlock();
}
return versions.values();
}
@Override