Missed an unlock condition, lets use a finally. Should Fix #2180

This commit is contained in:
t00thpick1 2014-08-05 18:57:13 -04:00
parent 79a17b0c1c
commit c156f0c346

View File

@ -33,43 +33,43 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
public void run() { public void run() {
lock.lock(); lock.lock();
if (this.cancelled) { try {
return; if (this.cancelled) {
} return;
}
// Quit if they logged out // Quit if they logged out
if (!player.isOnline()) { if (!player.isOnline()) {
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out"); mcMMO.p.getLogger().info("Aborting profile loading recovery for " + player.getName() + " - player logged out");
this.cancel(); this.cancel();
cancelled = true; cancelled = true;
return;
}
// Increment attempt counter and try
attempt++;
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
// If successful, schedule the apply
if (profile.isLoaded()) {
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
this.cancel();
cancelled = true;
return;
}
// If we've failed five times, give up
if (attempt >= MAX_TRIES) {
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + player.getName());
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.AdminFailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
this.cancel();
cancelled = true;
return;
}
} finally {
lock.unlock(); lock.unlock();
return;
} }
// Increment attempt counter and try
attempt++;
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(player.getName(), player.getUniqueId(), true);
// If successful, schedule the apply
if (profile.isLoaded()) {
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
this.cancel();
cancelled = true;
lock.unlock();
return;
}
// If we've failed five times, give up
if (attempt >= MAX_TRIES) {
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + player.getName());
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Profile.Loading.AdminFailureNotice", player.getName()), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
player.sendMessage(LocaleLoader.getString("Profile.Loading.Failure").split("\n"));
this.cancel();
cancelled = true;
lock.unlock();
return;
}
lock.unlock();
} }
private class ApplySuccessfulProfile extends BukkitRunnable { private class ApplySuccessfulProfile extends BukkitRunnable {
@ -104,5 +104,3 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
} }
} }
} }