Small fix for OpenJDK (FindBugs).

This commit is contained in:
Kristian S. Stangeland 2012-11-20 06:48:05 +01:00
parent 95dbddf9bb
commit dc186df695

View File

@ -79,6 +79,7 @@ public class ProtocolLibrary extends JavaPlugin {
// Logger
private Logger logger;
private Handler redirectHandler;
// Commands
private CommandProtocol commandProtocol;
@ -137,8 +138,12 @@ public class ProtocolLibrary extends JavaPlugin {
}
private void broadcastUsers(final String permission) {
// Broadcast information to every user too
logger.addHandler(new Handler() {
// Guard against multiple calls
if (redirectHandler != null)
return;
// Broadcast information to every user too
redirectHandler = new Handler() {
@Override
public void publish(LogRecord record) {
commandPacket.broadcastMessageSilently(record.getMessage(), permission);
@ -153,7 +158,9 @@ public class ProtocolLibrary extends JavaPlugin {
public void close() throws SecurityException {
// Do nothing.
}
});
};
logger.addHandler(redirectHandler);
}
@Override
@ -293,6 +300,11 @@ public class ProtocolLibrary extends JavaPlugin {
asyncPacketTask = -1;
}
// And redirect handler too
if (redirectHandler != null) {
logger.removeHandler(redirectHandler);
}
unhookTask.close();
protocolManager.close();
protocolManager = null;