456956 Reduce ThreadLocal.remove() weak reference garbage

This commit is contained in:
Greg Wilkins 2015-01-07 19:53:30 +01:00
parent 3abfbe26b3
commit 3270af81e8
6 changed files with 8 additions and 18 deletions

View File

@ -126,14 +126,14 @@ public class ServletCallbackHandler implements CallbackHandler
public CallerPrincipalCallback getThreadCallerPrincipalCallback()
{
CallerPrincipalCallback callerPrincipalCallback = _callerPrincipals.get();
_callerPrincipals.remove();
_callerPrincipals.set(null);
return callerPrincipalCallback;
}
public GroupPrincipalCallback getThreadGroupPrincipalCallback()
{
GroupPrincipalCallback groupPrincipalCallback = _groupPrincipals.get();
_groupPrincipals.remove();
_groupPrincipals.set(null);
return groupPrincipalCallback;
}
}

View File

@ -211,7 +211,6 @@ public class ContextFactory implements ObjectFactory
return (Context)__contextMap.get(loader);
}
/**
* Associate the given Context with the current thread.
* disassociate method should be called to reset the context.
@ -227,10 +226,9 @@ public class ContextFactory implements ObjectFactory
public static void disassociateContext(final Context ctx)
{
__threadContext.remove();
__threadContext.set(null);
}
public static ClassLoader associateClassLoader(final ClassLoader loader)
{
ClassLoader prev = (ClassLoader)__threadClassLoader.get();
@ -238,10 +236,9 @@ public class ContextFactory implements ObjectFactory
return prev;
}
public static void disassociateClassLoader ()
{
__threadClassLoader.remove();
__threadClassLoader.set(null);
}
public static void dump(Appendable out, String indent) throws IOException
@ -259,5 +256,4 @@ public class ContextFactory implements ObjectFactory
context.dump(out,indent+(last?" ":" | "));
}
}
}

View File

@ -86,10 +86,7 @@ public class HttpChannel<T> implements HttpParser.RequestHandler<T>, Runnable, H
protected static HttpChannel<?> setCurrentHttpChannel(HttpChannel<?> channel)
{
HttpChannel<?> last=__currentChannel.get();
if (channel==null)
__currentChannel.remove();
else
__currentChannel.set(channel);
__currentChannel.set(channel);
return last;
}

View File

@ -80,10 +80,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
protected static HttpConnection setCurrentConnection(HttpConnection connection)
{
HttpConnection last=__currentConnection.get();
if (connection==null)
__currentConnection.remove();
else
__currentConnection.set(connection);
__currentConnection.set(connection);
return last;
}

View File

@ -496,7 +496,7 @@ public class GzipFilter extends UserAgentFilter
_allocatedDeflater = new Deflater(_deflateCompressionLevel,_deflateNoWrap);
else
{
_deflater.remove();
_deflater.set(null);
_allocatedDeflater.reset();
}

View File

@ -53,7 +53,7 @@ public class NonBlockingThread implements Runnable
}
finally
{
__nonBlockingThread.remove();
__nonBlockingThread.set(Boolean.FALSE);
}
}
}