From 118574e535c27731530f225d9497bfb447fb216d Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Thu, 28 Mar 2019 22:27:51 -0400 Subject: [PATCH] Updated log4j and Checker Framework Updating Checker Framework flagged numerous warnings, which have been corrected. These probably involve type declarations lacking a nullness annotation that appeared elsewhere. --- .../api/event/query/ProxyQueryEvent.java | 6 +----- .../api/plugin/meta/PluginDependency.java | 3 +-- .../api/proxy/server/QueryResponse.java | 20 +++++-------------- build.gradle | 4 ++-- proxy/build.gradle | 2 +- .../proxy/command/VelocityCommandManager.java | 6 +++--- .../proxy/connection/MinecraftConnection.java | 6 ++---- .../backend/VelocityServerConnection.java | 3 +-- .../connection/client/ConnectedPlayer.java | 6 ++---- .../proxy/protocol/netty/GS4QueryHandler.java | 4 ++-- .../protocol/packet/AvailableCommands.java | 9 +++------ .../proxy/protocol/packet/LegacyPing.java | 6 ++---- .../proxy/protocol/packet/PlayerListItem.java | 3 +-- .../protocol/packet/ResourcePackRequest.java | 12 ++++------- .../protocol/packet/ResourcePackResponse.java | 3 +-- .../protocol/packet/TabCompleteResponse.java | 3 +-- .../ByteArgumentPropertySerializer.java | 2 -- .../DoubleArgumentPropertySerializer.java | 2 -- .../packet/brigadier/DummyProperty.java | 3 +-- .../DummyVoidArgumentPropertySerializer.java | 3 +-- .../FloatArgumentPropertySerializer.java | 2 -- .../IntegerArgumentPropertySerializer.java | 2 -- .../StringArgumentPropertySerializer.java | 2 -- .../VoidArgumentPropertySerializer.java | 3 +-- 24 files changed, 35 insertions(+), 80 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java b/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java index 8f87c6020..721a2f74b 100644 --- a/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java +++ b/api/src/main/java/com/velocitypowered/api/event/query/ProxyQueryEvent.java @@ -3,7 +3,6 @@ package com.velocitypowered.api.event.query; import com.google.common.base.Preconditions; import com.velocitypowered.api.proxy.server.QueryResponse; import java.net.InetAddress; -import org.checkerframework.checker.nullness.qual.NonNull; /** * This event is fired if proxy is getting queried over GS4 Query protocol. @@ -32,7 +31,6 @@ public final class ProxyQueryEvent { * * @return query type */ - @NonNull public QueryType getQueryType() { return queryType; } @@ -42,7 +40,6 @@ public final class ProxyQueryEvent { * * @return querier address */ - @NonNull public InetAddress getQuerierAddress() { return querierAddress; } @@ -52,7 +49,6 @@ public final class ProxyQueryEvent { * * @return the current query response */ - @NonNull public QueryResponse getResponse() { return response; } @@ -62,7 +58,7 @@ public final class ProxyQueryEvent { * * @param response the new non-null query response */ - public void setResponse(@NonNull QueryResponse response) { + public void setResponse(QueryResponse response) { this.response = Preconditions.checkNotNull(response, "response"); } diff --git a/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java b/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java index a07bb8a4c..dc7464a39 100644 --- a/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java +++ b/api/src/main/java/com/velocitypowered/api/plugin/meta/PluginDependency.java @@ -14,8 +14,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public final class PluginDependency { private final String id; - @Nullable - private final String version; + private final @Nullable String version; private final boolean optional; diff --git a/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java b/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java index 9d7c54749..09993c366 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/server/QueryResponse.java @@ -219,21 +219,11 @@ public final class QueryResponse { * A builder for {@link QueryResponse} objects. */ public static final class Builder { - - @MonotonicNonNull - private String hostname; - - @MonotonicNonNull - private String gameVersion; - - @MonotonicNonNull - private String map; - - @MonotonicNonNull - private String proxyHost; - - @MonotonicNonNull - private String proxyVersion; + private @MonotonicNonNull String hostname; + private @MonotonicNonNull String gameVersion; + private @MonotonicNonNull String map; + private @MonotonicNonNull String proxyHost; + private @MonotonicNonNull String proxyVersion; private int currentPlayers; private int maxPlayers; diff --git a/build.gradle b/build.gradle index 45b62ac27..e1c21ac5c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,10 +22,10 @@ allprojects { // dependency versions junitVersion = '5.3.0-M1' slf4jVersion = '1.7.25' - log4jVersion = '2.11.1' + log4jVersion = '2.11.2' nettyVersion = '4.1.34.Final' guavaVersion = '25.1-jre' - checkerFrameworkVersion = '2.5.6' + checkerFrameworkVersion = '2.7.0' getCurrentShortRevision = { new ByteArrayOutputStream().withStream { os -> diff --git a/proxy/build.gradle b/proxy/build.gradle index 281f9d23d..838e740ac 100644 --- a/proxy/build.gradle +++ b/proxy/build.gradle @@ -52,7 +52,7 @@ dependencies { runtime 'net.java.dev.jna:jna:4.5.2' // Needed for JLine runtime 'com.lmax:disruptor:3.4.2' // Async loggers - compile 'it.unimi.dsi:fastutil:8.2.1' + compile 'it.unimi.dsi:fastutil:8.2.2' compile 'net.kyori:event-method-asm:3.0.0' compile 'com.mojang:brigadier:1.0.15' diff --git a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java index 0e649f942..1e7e7d936 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/command/VelocityCommandManager.java @@ -20,7 +20,7 @@ public class VelocityCommandManager implements CommandManager { private final Map commands = new HashMap<>(); @Override - public void register(@NonNull final Command command, final String... aliases) { + public void register(final Command command, final String... aliases) { Preconditions.checkNotNull(aliases, "aliases"); Preconditions.checkNotNull(command, "executor"); for (int i = 0, length = aliases.length; i < length; i++) { @@ -31,13 +31,13 @@ public class VelocityCommandManager implements CommandManager { } @Override - public void unregister(@NonNull final String alias) { + public void unregister(final String alias) { Preconditions.checkNotNull(alias, "name"); this.commands.remove(alias.toLowerCase(Locale.ENGLISH)); } @Override - public boolean execute(@NonNull CommandSource source, @NonNull String cmdLine) { + public boolean execute(CommandSource source, String cmdLine) { Preconditions.checkNotNull(source, "invoker"); Preconditions.checkNotNull(cmdLine, "cmdLine"); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index d654a685b..f210ac402 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -255,8 +255,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { } } - @Nullable - public MinecraftSessionHandler getSessionHandler() { + public @Nullable MinecraftSessionHandler getSessionHandler() { return sessionHandler; } @@ -318,8 +317,7 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { .addBefore(FRAME_ENCODER, CIPHER_ENCODER, new MinecraftCipherEncoder(encryptionCipher)); } - @Nullable - public MinecraftConnectionAssociation getAssociation() { + public @Nullable MinecraftConnectionAssociation getAssociation() { return association; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java index 89770d050..99a88c706 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/VelocityServerConnection.java @@ -160,8 +160,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation, mc.write(new ServerLogin(proxyPlayer.getUsername())); } - @Nullable - public MinecraftConnection getConnection() { + public @Nullable MinecraftConnection getConnection() { return connection; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 5045a2ee6..f69422380 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -86,8 +86,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { private final VelocityServer server; private ClientConnectionPhase connectionPhase; - @MonotonicNonNull - private List serversToTry = null; + private @MonotonicNonNull List serversToTry = null; ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection minecraftConnection, @Nullable InetSocketAddress virtualHost) { @@ -289,8 +288,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { } - @Nullable - public VelocityServerConnection getConnectedServer() { + public @Nullable VelocityServerConnection getConnectedServer() { return connectedServer; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java index 1b8ef41d8..234f9b493 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/GS4QueryHandler.java @@ -60,8 +60,8 @@ public class GS4QueryHandler extends SimpleChannelInboundHandler .expireAfterWrite(30, TimeUnit.SECONDS) .build(); - @MonotonicNonNull - private volatile List pluginInformationList = null; + private volatile @MonotonicNonNull List pluginInformationList + = null; private final VelocityServer server; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java index 671d1b128..ebf7f5b10 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/AvailableCommands.java @@ -45,8 +45,7 @@ public class AvailableCommands implements MinecraftPacket { private static final byte FLAG_HAS_SUGGESTIONS = 0x10; // Note: Velocity doesn't use Brigadier for command handling. This may change in Velocity 2.0.0. - @MonotonicNonNull - private RootCommandNode rootNode; + private @MonotonicNonNull RootCommandNode rootNode; /** * Returns the root node. @@ -206,10 +205,8 @@ public class AvailableCommands implements MinecraftPacket { private final byte flags; private final int[] children; private final int redirectTo; - @Nullable - private final ArgumentBuilder args; - @MonotonicNonNull - private CommandNode built; + private final @Nullable ArgumentBuilder args; + private @MonotonicNonNull CommandNode built; private WireNode(int idx, byte flags, int[] children, int redirectTo, @Nullable ArgumentBuilder args) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java index 7f0a4fabf..eb8e754c6 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/LegacyPing.java @@ -12,8 +12,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class LegacyPing implements MinecraftPacket { private final LegacyMinecraftPingVersion version; - @Nullable - private final InetSocketAddress vhost; + private final @Nullable InetSocketAddress vhost; public LegacyPing(LegacyMinecraftPingVersion version) { this.version = version; @@ -29,8 +28,7 @@ public class LegacyPing implements MinecraftPacket { return version; } - @Nullable - public InetSocketAddress getVhost() { + public @Nullable InetSocketAddress getVhost() { return vhost; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java index 439202483..df5bffa5d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/PlayerListItem.java @@ -75,8 +75,7 @@ public class PlayerListItem implements MinecraftPacket { } } - @Nullable - private static Component readOptionalComponent(ByteBuf buf) { + private static @Nullable Component readOptionalComponent(ByteBuf buf) { if (buf.readBoolean()) { return ComponentSerializers.JSON.deserialize(ProtocolUtils.readString(buf)); } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java index 5170e3b9f..435b5fb53 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackRequest.java @@ -11,13 +11,10 @@ import org.checkerframework.checker.nullness.qual.Nullable; public class ResourcePackRequest implements MinecraftPacket { - @MonotonicNonNull - private String url; - @MonotonicNonNull - private String hash; + private @MonotonicNonNull String url; + private @MonotonicNonNull String hash; - @Nullable - public String getUrl() { + public @Nullable String getUrl() { return url; } @@ -25,8 +22,7 @@ public class ResourcePackRequest implements MinecraftPacket { this.url = url; } - @Nullable - public String getHash() { + public @Nullable String getHash() { return hash; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java index d78c5d96e..16f47ac3c 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/ResourcePackResponse.java @@ -12,8 +12,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public class ResourcePackResponse implements MinecraftPacket { private String hash = ""; - @MonotonicNonNull - private Status status; + private @MonotonicNonNull Status status; public Status getStatus() { if (status == null) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java index 5fcb3a7bd..4523d5cbf 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/TabCompleteResponse.java @@ -109,8 +109,7 @@ public class TabCompleteResponse implements MinecraftPacket { public static class Offer implements Comparable { private final String text; - @Nullable - private final Component tooltip; + private final @Nullable Component tooltip; public Offer(String text) { this(text, null); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java index d62c19c8b..742084a0e 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/ByteArgumentPropertySerializer.java @@ -1,7 +1,6 @@ package com.velocitypowered.proxy.protocol.packet.brigadier; import io.netty.buffer.ByteBuf; -import org.checkerframework.checker.nullness.qual.Nullable; class ByteArgumentPropertySerializer implements ArgumentPropertySerializer { @@ -11,7 +10,6 @@ class ByteArgumentPropertySerializer implements ArgumentPropertySerializer } - @Nullable @Override public Byte deserialize(ByteBuf buf) { return buf.readByte(); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java index b36e5869c..bd15c2ba3 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DoubleArgumentPropertySerializer.java @@ -6,7 +6,6 @@ import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumen import com.mojang.brigadier.arguments.DoubleArgumentType; import io.netty.buffer.ByteBuf; -import org.checkerframework.checker.nullness.qual.Nullable; class DoubleArgumentPropertySerializer implements ArgumentPropertySerializer { @@ -15,7 +14,6 @@ class DoubleArgumentPropertySerializer implements ArgumentPropertySerializer implements ArgumentType { private final String identifier; private final ArgumentPropertySerializer serializer; - @Nullable - private final T result; + private final @Nullable T result; DummyProperty(String identifier, ArgumentPropertySerializer serializer, @Nullable T result) { this.identifier = identifier; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java index 075d0435f..c134cc3cd 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/DummyVoidArgumentPropertySerializer.java @@ -14,9 +14,8 @@ class DummyVoidArgumentPropertySerializer implements ArgumentPropertySerializer< private DummyVoidArgumentPropertySerializer() { } - @Nullable @Override - public Void deserialize(ByteBuf buf) { + public @Nullable Void deserialize(ByteBuf buf) { return null; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java index ec7da4d17..c3b465d19 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/packet/brigadier/FloatArgumentPropertySerializer.java @@ -6,7 +6,6 @@ import static com.velocitypowered.proxy.protocol.packet.brigadier.IntegerArgumen import com.mojang.brigadier.arguments.FloatArgumentType; import io.netty.buffer.ByteBuf; -import org.checkerframework.checker.nullness.qual.Nullable; class FloatArgumentPropertySerializer implements ArgumentPropertySerializer { @@ -16,7 +15,6 @@ class FloatArgumentPropertySerializer implements ArgumentPropertySerializer { @@ -15,7 +14,6 @@ class IntegerArgumentPropertySerializer implements ArgumentPropertySerializer> return new VoidArgumentPropertySerializer(supplier); } - @Nullable @Override - public T deserialize(ByteBuf buf) { + public @Nullable T deserialize(ByteBuf buf) { return argumentSupplier.get(); }