Fix some more static analysis warnings
This commit is contained in:
parent
19bb8f72c7
commit
9d5c886045
6
pom.xml
6
pom.xml
@ -87,6 +87,12 @@
|
||||
<version>3.0.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>findbugs</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
@ -16,6 +17,7 @@ import net.md_5.bungee.log.BungeeLogger;
|
||||
import net.md_5.bungee.scheduler.BungeeScheduler;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.gson.Gson;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.bootstrap.ServerBootstrap;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelException;
|
||||
@ -157,6 +159,7 @@ public class BungeeCord extends ProxyServer
|
||||
return (BungeeCord) ProxyServer.getInstance();
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
|
||||
public BungeeCord() throws IOException
|
||||
{
|
||||
System.setSecurityManager( new BungeeSecurityManager() );
|
||||
@ -200,6 +203,7 @@ public class BungeeCord extends ProxyServer
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
|
||||
public void start() throws Exception
|
||||
{
|
||||
System.setProperty( "java.net.preferIPv4Stack", "true" ); // Minecraft does not support IPv6
|
||||
@ -311,6 +315,7 @@ public class BungeeCord extends ProxyServer
|
||||
new Thread( "Shutdown Thread" )
|
||||
{
|
||||
@Override
|
||||
@SuppressFBWarnings("DM_EXIT")
|
||||
@SuppressWarnings("TooBroadCatch")
|
||||
public void run()
|
||||
{
|
||||
@ -514,7 +519,7 @@ public class BungeeCord extends ProxyServer
|
||||
|
||||
public PluginMessage registerChannels()
|
||||
{
|
||||
return new PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes() );
|
||||
return new PluginMessage( "REGISTER", Util.format( pluginChannels, "\00" ).getBytes( Charsets.UTF_8 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -614,7 +619,7 @@ public class BungeeCord extends ProxyServer
|
||||
@Override
|
||||
public boolean apply(ProxiedPlayer input)
|
||||
{
|
||||
return input.getName().toLowerCase().contains( partialName.toLowerCase() );
|
||||
return ( input == null ) ? false : input.getName().toLowerCase().contains( partialName.toLowerCase() );
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class EncryptionUtil
|
||||
{
|
||||
|
||||
private static final Random random = new Random();
|
||||
public static KeyPair keys;
|
||||
public static final KeyPair keys;
|
||||
@Getter
|
||||
private static final SecretKey secret = new SecretKeySpec( new byte[ 16 ], "AES" );
|
||||
|
||||
|
@ -96,7 +96,6 @@ public final class UserConnection implements ProxiedPlayer
|
||||
@Setter
|
||||
private int serverEntityId;
|
||||
@Getter
|
||||
@Setter
|
||||
private ClientSettings settings;
|
||||
@Getter
|
||||
private final Scoreboard serverSentScoreboard = new Scoreboard();
|
||||
@ -435,9 +434,15 @@ public final class UserConnection implements ProxiedPlayer
|
||||
return getPendingConnection().getUniqueId();
|
||||
}
|
||||
|
||||
public void setSettings(ClientSettings settings)
|
||||
{
|
||||
this.settings = settings;
|
||||
this.locale = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale()
|
||||
{
|
||||
return ( locale == null ) ? locale = Locale.forLanguageTag( settings.getLocale() ) : locale;
|
||||
return ( locale == null && settings != null ) ? locale = Locale.forLanguageTag( settings.getLocale() ) : locale;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.conf;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
@ -42,19 +43,23 @@ public class YamlConfig implements ConfigurationAdapter
|
||||
GLOBAL( Global.class ), GLOBAL_PING( GlobalPing.class ), SERVER( ServerUnique.class );
|
||||
private final Class<? extends TabListHandler> clazz;
|
||||
}
|
||||
private Yaml yaml;
|
||||
private final Yaml yaml;
|
||||
private Map config;
|
||||
private final File file = new File( "config.yml" );
|
||||
|
||||
public YamlConfig()
|
||||
{
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle( DumperOptions.FlowStyle.BLOCK );
|
||||
yaml = new Yaml( options );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
try
|
||||
{
|
||||
file.createNewFile();
|
||||
DumperOptions options = new DumperOptions();
|
||||
options.setDefaultFlowStyle( DumperOptions.FlowStyle.BLOCK );
|
||||
yaml = new Yaml( options );
|
||||
|
||||
try ( InputStream is = new FileInputStream( file ) )
|
||||
{
|
||||
@ -182,6 +187,7 @@ public class YamlConfig implements ConfigurationAdapter
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
|
||||
public Collection<ListenerInfo> getListeners()
|
||||
{
|
||||
Collection<Map<String, Object>> base = get( "listeners", (Collection) Arrays.asList( new Map[]
|
||||
|
@ -118,6 +118,8 @@ public class DownstreamBridge extends PacketHandler
|
||||
case 1:
|
||||
serverScoreboard.removeObjective( objective.getName() );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unknown objective action: " + objective.getAction() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -135,6 +137,8 @@ public class DownstreamBridge extends PacketHandler
|
||||
case 1:
|
||||
serverScoreboard.removeScore( score.getItemName() );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unknown scoreboard action: " + score.getAction() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.connection;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
@ -49,6 +50,7 @@ public class PingHandler extends PacketHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
|
||||
public void handle(StatusResponse statusResponse) throws Exception
|
||||
{
|
||||
Gson gson = protocol == ProtocolConstants.MINECRAFT_1_7_2 ? BungeeCord.getInstance().gsonLegacy : BungeeCord.getInstance().gson;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.entitymap;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
@ -80,6 +81,7 @@ public abstract class EntityMap
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
||||
protected static void rewriteVarInt(ByteBuf packet, int oldId, int newId, int offset)
|
||||
{
|
||||
// Need to rewrite the packet because VarInts are variable length
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.entitymap;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
@ -9,6 +10,7 @@ import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
|
||||
class EntityMap_14_11_a extends EntityMap
|
||||
{
|
||||
|
||||
EntityMap_14_11_a()
|
||||
{
|
||||
addRewrite( 0x04, ProtocolConstants.Direction.TO_CLIENT, true ); // Entity Equipment
|
||||
@ -42,6 +44,7 @@ class EntityMap_14_11_a extends EntityMap
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
||||
public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
||||
{
|
||||
super.rewriteClientbound( packet, oldId, newId );
|
||||
@ -153,7 +156,8 @@ class EntityMap_14_11_a extends EntityMap
|
||||
{
|
||||
DefinedPacket.readVarInt( packet );
|
||||
rewriteInt( packet, oldId, newId, packet.readerIndex() );
|
||||
} else if ( event == 2 /* Entity Dead */ ) {
|
||||
} else if ( event == 2 /* Entity Dead */ )
|
||||
{
|
||||
int position = packet.readerIndex();
|
||||
rewriteVarInt( packet, oldId, newId, packet.readerIndex() );
|
||||
packet.readerIndex( position );
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.entitymap;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
@ -8,12 +9,9 @@ import net.md_5.bungee.protocol.DefinedPacket;
|
||||
|
||||
class EntityMap_1_7_6 extends EntityMap_1_7_2
|
||||
{
|
||||
EntityMap_1_7_6()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressFBWarnings("DLS_DEAD_LOCAL_STORE")
|
||||
public void rewriteClientbound(ByteBuf packet, int oldId, int newId)
|
||||
{
|
||||
super.rewriteClientbound( packet, oldId, newId );
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.log;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Formatter;
|
||||
@ -18,6 +19,7 @@ public class BungeeLogger extends Logger
|
||||
{
|
||||
"CallToPrintStackTrace", "CallToThreadStartDuringObjectConstruction"
|
||||
})
|
||||
@SuppressFBWarnings("SC_START_IN_CTOR")
|
||||
public BungeeLogger(BungeeCord bungee)
|
||||
{
|
||||
super( "BungeeCord", null );
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.log;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
@ -18,7 +19,7 @@ public class LoggingOutputStream extends ByteArrayOutputStream
|
||||
@Override
|
||||
public void flush() throws IOException
|
||||
{
|
||||
String contents = toString();
|
||||
String contents = toString( Charsets.UTF_8.name() );
|
||||
super.reset();
|
||||
if ( !contents.isEmpty() && !contents.equals( separator ) )
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.module;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
@ -30,6 +31,10 @@ public class ModuleManager
|
||||
knownSources.put( "jenkins", new JenkinsModuleSource() );
|
||||
}
|
||||
|
||||
@SuppressFBWarnings(
|
||||
{
|
||||
"SF_SWITCH_FALLTHROUGH", "SF_SWITCH_NO_DEFAULT"
|
||||
})
|
||||
public void load(ProxyServer proxy, File moduleDirectory) throws Exception
|
||||
{
|
||||
moduleDirectory.mkdir();
|
||||
@ -125,6 +130,7 @@ public class ModuleManager
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressFBWarnings("REC_CATCH_EXCEPTION")
|
||||
private ModuleVersion getVersion(File file)
|
||||
{
|
||||
try ( JarFile jar = new JarFile( file ) )
|
||||
|
@ -65,16 +65,16 @@ public class PipelineUtils
|
||||
};
|
||||
public static final Base BASE = new Base();
|
||||
private static final Varint21LengthFieldPrepender framePrepender = new Varint21LengthFieldPrepender();
|
||||
public static String TIMEOUT_HANDLER = "timeout";
|
||||
public static String PACKET_DECODER = "packet-decoder";
|
||||
public static String PACKET_ENCODER = "packet-encoder";
|
||||
public static String BOSS_HANDLER = "inbound-boss";
|
||||
public static String ENCRYPT_HANDLER = "encrypt";
|
||||
public static String DECRYPT_HANDLER = "decrypt";
|
||||
public static String FRAME_DECODER = "frame-decoder";
|
||||
public static String FRAME_PREPENDER = "frame-prepender";
|
||||
public static String LEGACY_DECODER = "legacy-decoder";
|
||||
public static String LEGACY_KICKER = "legacy-kick";
|
||||
public static final String TIMEOUT_HANDLER = "timeout";
|
||||
public static final String PACKET_DECODER = "packet-decoder";
|
||||
public static final String PACKET_ENCODER = "packet-encoder";
|
||||
public static final String BOSS_HANDLER = "inbound-boss";
|
||||
public static final String ENCRYPT_HANDLER = "encrypt";
|
||||
public static final String DECRYPT_HANDLER = "decrypt";
|
||||
public static final String FRAME_DECODER = "frame-decoder";
|
||||
public static final String FRAME_PREPENDER = "frame-prepender";
|
||||
public static final String LEGACY_DECODER = "legacy-decoder";
|
||||
public static final String LEGACY_KICKER = "legacy-kick";
|
||||
|
||||
private static boolean epoll;
|
||||
|
||||
|
@ -56,9 +56,6 @@ public class Custom extends TabListAdapter implements CustomTabList
|
||||
rowLim = row;
|
||||
colLim = column;
|
||||
}
|
||||
} else
|
||||
{
|
||||
sentStuff.remove( text );
|
||||
}
|
||||
|
||||
slots[--row][--column] = text;
|
||||
|
Loading…
Reference in New Issue
Block a user