Fix some static analysis warnings.

This commit is contained in:
md_5 2014-07-12 13:33:13 +10:00
parent 4dfd510583
commit 19bb8f72c7
10 changed files with 30 additions and 15 deletions

View File

@ -104,7 +104,7 @@ public class BungeeCord extends ProxyServer
/** /**
* Server socket listener. * Server socket listener.
*/ */
private Collection<Channel> listeners = new HashSet<>(); private final Collection<Channel> listeners = new HashSet<>();
/** /**
* Fully qualified connections. * Fully qualified connections.
*/ */
@ -127,7 +127,7 @@ public class BungeeCord extends ProxyServer
@Getter @Getter
private final BungeeScheduler scheduler = new BungeeScheduler(); private final BungeeScheduler scheduler = new BungeeScheduler();
@Getter @Getter
private ConsoleReader consoleReader; private final ConsoleReader consoleReader;
@Getter @Getter
private final Logger logger; private final Logger logger;
public final Gson gson = new GsonBuilder() public final Gson gson = new GsonBuilder()
@ -251,7 +251,7 @@ public class BungeeCord extends ProxyServer
if ( future.isSuccess() ) if ( future.isSuccess() )
{ {
listeners.add( future.channel() ); listeners.add( future.channel() );
getLogger().info( "Listening on " + info.getHost() ); getLogger().log( Level.INFO, "Listening on {0}", info.getHost() );
} else } else
{ {
getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() ); getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() );
@ -277,7 +277,7 @@ public class BungeeCord extends ProxyServer
if ( future.isSuccess() ) if ( future.isSuccess() )
{ {
listeners.add( future.channel() ); listeners.add( future.channel() );
getLogger().info( "Started query on " + future.channel().localAddress() ); getLogger().log( Level.INFO, "Started query on {0}", future.channel().localAddress() );
} else } else
{ {
getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() ); getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() );
@ -311,6 +311,7 @@ public class BungeeCord extends ProxyServer
new Thread( "Shutdown Thread" ) new Thread( "Shutdown Thread" )
{ {
@Override @Override
@SuppressWarnings("TooBroadCatch")
public void run() public void run()
{ {
BungeeCord.this.isRunning = false; BungeeCord.this.isRunning = false;
@ -321,7 +322,7 @@ public class BungeeCord extends ProxyServer
connectionLock.readLock().lock(); connectionLock.readLock().lock();
try try
{ {
getLogger().info( "Disconnecting " + connections.size() + " connections" ); getLogger().log( Level.INFO, "Disconnecting {0} connections", connections.size() );
for ( UserConnection user : connections.values() ) for ( UserConnection user : connections.values() )
{ {
user.disconnect( getTranslation( "restart" ) ); user.disconnect( getTranslation( "restart" ) );
@ -362,8 +363,7 @@ public class BungeeCord extends ProxyServer
} }
} catch ( Throwable t ) } catch ( Throwable t )
{ {
getLogger().severe( "Exception disabling plugin " + plugin.getDescription().getName() ); getLogger().log( Level.SEVERE, "Exception disabling plugin " + plugin.getDescription().getName(), t );
t.printStackTrace();
} }
getScheduler().cancel( plugin ); getScheduler().cancel( plugin );
plugin.getExecutorService().shutdownNow(); plugin.getExecutorService().shutdownNow();
@ -458,6 +458,7 @@ public class BungeeCord extends ProxyServer
} }
} }
@Override
public ProxiedPlayer getPlayer(UUID uuid) public ProxiedPlayer getPlayer(UUID uuid)
{ {
connectionLock.readLock().lock(); connectionLock.readLock().lock();

View File

@ -26,7 +26,7 @@ public class EncryptionUtil
private static final Random random = new Random(); private static final Random random = new Random();
public static KeyPair keys; public static KeyPair keys;
@Getter @Getter
private static SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" ); private static final SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" );
static static
{ {

View File

@ -229,6 +229,7 @@ public final class UserConnection implements ProxiedPlayer
ChannelFutureListener listener = new ChannelFutureListener() ChannelFutureListener listener = new ChannelFutureListener()
{ {
@Override @Override
@SuppressWarnings("ThrowableResultIgnored")
public void operationComplete(ChannelFuture future) throws Exception public void operationComplete(ChannelFuture future) throws Exception
{ {
if ( callback != null ) if ( callback != null )
@ -295,7 +296,10 @@ public final class UserConnection implements ProxiedPlayer
{ {
if ( ch.getHandle().isActive() ) if ( ch.getHandle().isActive() )
{ {
bungee.getLogger().log( Level.INFO, "[" + getName() + "] disconnected with: " + BaseComponent.toLegacyText( reason ) ); bungee.getLogger().log( Level.INFO, "[{0}] disconnected with: {1}", new Object[]
{
getName(), BaseComponent.toLegacyText( reason )
} );
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) ); unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
ch.close(); ch.close();
if ( server != null ) if ( server != null )

View File

@ -120,12 +120,14 @@ public class Configuration implements ProxyConfig
} }
} }
@Override
@Deprecated @Deprecated
public String getFavicon() public String getFavicon()
{ {
return getFaviconObject().getEncoded(); return getFaviconObject().getEncoded();
} }
@Override
public Favicon getFaviconObject() public Favicon getFaviconObject()
{ {
return favicon; return favicon;

View File

@ -29,6 +29,7 @@ public class HttpClient
public static final int TIMEOUT = 5000; public static final int TIMEOUT = 5000;
private static final Cache<String, InetAddress> addressCache = CacheBuilder.newBuilder().expireAfterWrite( 5, TimeUnit.MINUTES ).build(); private static final Cache<String, InetAddress> addressCache = CacheBuilder.newBuilder().expireAfterWrite( 5, TimeUnit.MINUTES ).build();
@SuppressWarnings("UnusedAssignment")
public static void get(String url, EventLoop eventLoop, final Callback<String> callback) public static void get(String url, EventLoop eventLoop, final Callback<String> callback)
{ {
Preconditions.checkNotNull( url, "url" ); Preconditions.checkNotNull( url, "url" );

View File

@ -14,6 +14,10 @@ public class BungeeLogger extends Logger
private final Formatter formatter = new ConciseFormatter(); private final Formatter formatter = new ConciseFormatter();
private final LogDispatcher dispatcher = new LogDispatcher( this ); private final LogDispatcher dispatcher = new LogDispatcher( this );
@SuppressWarnings(
{
"CallToPrintStackTrace", "CallToThreadStartDuringObjectConstruction"
})
public BungeeLogger(BungeeCord bungee) public BungeeLogger(BungeeCord bungee)
{ {
super( "BungeeCord", null ); super( "BungeeCord", null );

View File

@ -13,6 +13,7 @@ public class ConciseFormatter extends Formatter
private final DateFormat date = new SimpleDateFormat( System.getProperty( "net.md_5.bungee.log-date-format", "HH:mm:ss" ) ); private final DateFormat date = new SimpleDateFormat( System.getProperty( "net.md_5.bungee.log-date-format", "HH:mm:ss" ) );
@Override @Override
@SuppressWarnings("ThrowableResultIgnored")
public String format(LogRecord record) public String format(LogRecord record)
{ {
StringBuilder formatted = new StringBuilder(); StringBuilder formatted = new StringBuilder();

View File

@ -96,13 +96,16 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{ {
if ( cause instanceof ReadTimeoutException ) if ( cause instanceof ReadTimeoutException )
{ {
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - read timed out" ); ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - read timed out", handler );
} else if ( cause instanceof BadPacketException ) } else if ( cause instanceof BadPacketException )
{ {
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - bad packet ID, are mods in use!?" ); ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - bad packet ID, are mods in use!?", handler );
} else if ( cause instanceof IOException ) } else if ( cause instanceof IOException )
{ {
ProxyServer.getInstance().getLogger().log( Level.WARNING, handler + " - IOException: " + cause.getMessage() ); ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - IOException: {1}", new Object[]
{
handler, cause.getMessage()
} );
} else } else
{ {
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause ); ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause );

View File

@ -22,8 +22,8 @@ public class Custom extends TabListAdapter implements CustomTabList
/*========================================================================*/ /*========================================================================*/
private final Collection<String> sentStuff = new HashSet<>(); private final Collection<String> sentStuff = new HashSet<>();
/*========================================================================*/ /*========================================================================*/
private String[][] sent = new String[ ROWS ][ COLUMNS ]; private final String[][] sent = new String[ ROWS ][ COLUMNS ];
private String[][] slots = new String[ ROWS ][ COLUMNS ]; private final String[][] slots = new String[ ROWS ][ COLUMNS ];
private int rowLim; private int rowLim;
private int colLim; private int colLim;

View File

@ -1,7 +1,6 @@
package net.md_5.bungee.tab; package net.md_5.bungee.tab;
import net.md_5.bungee.BungeeCord; import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.packet.PlayerListItem; import net.md_5.bungee.protocol.packet.PlayerListItem;
public class GlobalPing extends Global public class GlobalPing extends Global