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