Skip to content

Commit a53b057

Browse files
committed
keep the platform lock until preferences are updated in #unregister
1 parent 0a8d199 commit a53b057

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java

+22-22
Original file line numberDiff line numberDiff line change
@@ -141,36 +141,36 @@ public boolean unregister(Platform platform) {
141141

142142
try {
143143
removed = platforms.remove(platform);
144-
} finally {
145-
platformsLock.writeLock().unlock();
146-
}
147144

148-
if (removed) {
149-
LOGGER.info("Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit");
145+
if (removed) {
146+
LOGGER.info("Unregistering " + platform.getClass().getCanonicalName() + " from WorldEdit");
150147

151-
boolean choosePreferred = false;
148+
boolean choosePreferred = false;
152149

153-
preferencesLock.writeLock().lock();
150+
preferencesLock.writeLock().lock();
154151

155-
try {
156-
// Check whether this platform was chosen to be the preferred one
157-
// for any capability and be sure to remove it
158-
Iterator<Entry<Capability, Platform>> it = preferences.entrySet().iterator();
159-
while (it.hasNext()) {
160-
Entry<Capability, Platform> entry = it.next();
161-
if (entry.getValue().equals(platform)) {
162-
entry.getKey().uninitialize(this, entry.getValue());
163-
it.remove();
164-
choosePreferred = true; // Have to choose new favorites
152+
try {
153+
// Check whether this platform was chosen to be the preferred one
154+
// for any capability and be sure to remove it
155+
Iterator<Entry<Capability, Platform>> it = preferences.entrySet().iterator();
156+
while (it.hasNext()) {
157+
Entry<Capability, Platform> entry = it.next();
158+
if (entry.getValue().equals(platform)) {
159+
entry.getKey().uninitialize(this, entry.getValue());
160+
it.remove();
161+
choosePreferred = true; // Have to choose new favorites
162+
}
165163
}
164+
} finally {
165+
preferencesLock.writeLock().unlock();
166166
}
167-
} finally {
168-
preferencesLock.writeLock().unlock();
169-
}
170167

171-
if (choosePreferred) {
172-
choosePreferred();
168+
if (choosePreferred) {
169+
choosePreferred();
170+
}
173171
}
172+
} finally {
173+
platformsLock.writeLock().unlock();
174174
}
175175

176176
return removed;

0 commit comments

Comments
 (0)