Archiviert
13
0

In blocking hash map, don't remove locks if the value has been replaced

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2013-03-04 13:29:46 +01:00
Ursprung 6019ab177c
Commit b1b6e9ec20
3 geänderte Dateien mit 8 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
import com.google.common.cache.Cache; import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.RemovalCause;
import com.google.common.cache.RemovalListener; import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification; import com.google.common.cache.RemovalNotification;
@ -69,7 +70,9 @@ public class BlockingHashMap<TKey, TValue> {
@Override @Override
public void onRemoval(RemovalNotification<TKey, TValue> entry) { public void onRemoval(RemovalNotification<TKey, TValue> entry) {
// Clean up locks too // Clean up locks too
locks.remove(entry.getKey()); if (entry.getCause() != RemovalCause.REPLACED) {
locks.remove(entry.getKey());
}
} }
}).build( }).build(
BlockingHashMap.<TKey, TValue>newInvalidCacheLoader() BlockingHashMap.<TKey, TValue>newInvalidCacheLoader()

Datei anzeigen

@ -93,7 +93,7 @@ public abstract class AbstractInputStreamLookup {
/** /**
* Associate a given socket address to the provided socket injector. * 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. * @param injector - the injector.
*/ */
public abstract void setSocketInjector(SocketAddress address, SocketInjector injector); public abstract void setSocketInjector(SocketAddress address, SocketInjector injector);

Datei anzeigen

@ -88,7 +88,7 @@ class InputStreamReflectLookup extends AbstractInputStreamLookup {
@Override @Override
public SocketInjector waitSocketInjector(InputStream input) { public SocketInjector waitSocketInjector(InputStream input) {
try { try {
SocketAddress address = getSocketAddress(input); SocketAddress address = waitSocketAddress(input);
// Guard against NPE // Guard against NPE
if (address != null) if (address != null)
@ -106,10 +106,10 @@ class InputStreamReflectLookup extends AbstractInputStreamLookup {
* @return The underlying socket address, or NULL if not found. * @return The underlying socket address, or NULL if not found.
* @throws IllegalAccessException Unable to access socket field. * @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 // Extra check, just in case
if (stream instanceof FilterInputStream) if (stream instanceof FilterInputStream)
return getSocketAddress(getInputStream((FilterInputStream) stream)); return waitSocketAddress(getInputStream((FilterInputStream) stream));
SocketAddress result = inputLookup.get(stream); SocketAddress result = inputLookup.get(stream);