diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java index b5bad572..9d90b7d8 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/concurrency/BlockingHashMap.java @@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; +import com.google.common.cache.RemovalCause; import com.google.common.cache.RemovalListener; import com.google.common.cache.RemovalNotification; @@ -69,7 +70,9 @@ public class BlockingHashMap { @Override public void onRemoval(RemovalNotification entry) { // Clean up locks too - locks.remove(entry.getKey()); + if (entry.getCause() != RemovalCause.REPLACED) { + locks.remove(entry.getKey()); + } } }).build( BlockingHashMap.newInvalidCacheLoader() diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/AbstractInputStreamLookup.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/AbstractInputStreamLookup.java index 86b13605..2ed52ae4 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/AbstractInputStreamLookup.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/AbstractInputStreamLookup.java @@ -93,7 +93,7 @@ public abstract class AbstractInputStreamLookup { /** * Associate a given socket address to the provided socket injector. - * @param input - the socket address to associate. + * @param address - the socket address to associate. * @param injector - the injector. */ public abstract void setSocketInjector(SocketAddress address, SocketInjector injector); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/InputStreamReflectLookup.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/InputStreamReflectLookup.java index 58305d49..2d971f5a 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/InputStreamReflectLookup.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/server/InputStreamReflectLookup.java @@ -88,7 +88,7 @@ class InputStreamReflectLookup extends AbstractInputStreamLookup { @Override public SocketInjector waitSocketInjector(InputStream input) { try { - SocketAddress address = getSocketAddress(input); + SocketAddress address = waitSocketAddress(input); // Guard against NPE if (address != null) @@ -106,10 +106,10 @@ class InputStreamReflectLookup extends AbstractInputStreamLookup { * @return The underlying socket address, or NULL if not found. * @throws IllegalAccessException Unable to access socket field. */ - private SocketAddress getSocketAddress(InputStream stream) throws IllegalAccessException { + private SocketAddress waitSocketAddress(InputStream stream) throws IllegalAccessException { // Extra check, just in case if (stream instanceof FilterInputStream) - return getSocketAddress(getInputStream((FilterInputStream) stream)); + return waitSocketAddress(getInputStream((FilterInputStream) stream)); SocketAddress result = inputLookup.get(stream);