mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-03 12:29:31 +00:00
Issue #5083 - Convert synchronized usages to AutoLock.
Fixes after merge. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
a79c0cfddd
commit
062878f97b
@ -87,7 +87,6 @@ import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.component.DumpableCollection;
|
||||
import org.eclipse.jetty.util.component.Graceful;
|
||||
import org.eclipse.jetty.util.resource.Resource;
|
||||
import org.eclipse.jetty.util.thread.AutoLock;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -185,7 +184,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||
DESTROYED
|
||||
}
|
||||
|
||||
private final AutoLock _lock = new AutoLock();
|
||||
protected ContextStatus _contextStatus = ContextStatus.NOTSET;
|
||||
protected Context _scontext;
|
||||
private final AttributesMap _attributes;
|
||||
@ -1846,13 +1844,10 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||
if (className == null)
|
||||
return null;
|
||||
|
||||
try (AutoLock l = _lock.lock())
|
||||
{
|
||||
if (_classLoader == null)
|
||||
return Loader.loadClass(className);
|
||||
if (_classLoader == null)
|
||||
return Loader.loadClass(className);
|
||||
|
||||
return _classLoader.loadClass(className);
|
||||
}
|
||||
return _classLoader.loadClass(className);
|
||||
}
|
||||
|
||||
public void addLocaleEncoding(String locale, String encoding)
|
||||
@ -2084,7 +2079,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||
*/
|
||||
public class Context extends StaticContext
|
||||
{
|
||||
private final AutoLock _lock = new AutoLock();
|
||||
protected boolean _enabled = true; // whether or not the dynamic API is enabled for callers
|
||||
protected boolean _extendedListenerTypes = false;
|
||||
|
||||
@ -2324,60 +2318,51 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||
@Override
|
||||
public Object getAttribute(String name)
|
||||
{
|
||||
try (AutoLock l = _lock.lock())
|
||||
{
|
||||
Object o = ContextHandler.this.getAttribute(name);
|
||||
if (o == null)
|
||||
o = super.getAttribute(name);
|
||||
return o;
|
||||
}
|
||||
Object o = ContextHandler.this.getAttribute(name);
|
||||
if (o == null)
|
||||
o = super.getAttribute(name);
|
||||
return o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<String> getAttributeNames()
|
||||
{
|
||||
try (AutoLock l = _lock.lock())
|
||||
HashSet<String> set = new HashSet<>();
|
||||
Enumeration<String> e = super.getAttributeNames();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
HashSet<String> set = new HashSet<>();
|
||||
Enumeration<String> e = super.getAttributeNames();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
set.add(e.nextElement());
|
||||
}
|
||||
e = ContextHandler.this.getAttributeNames();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
set.add(e.nextElement());
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
set.add(e.nextElement());
|
||||
}
|
||||
e = ContextHandler.this.getAttributeNames();
|
||||
while (e.hasMoreElements())
|
||||
{
|
||||
set.add(e.nextElement());
|
||||
}
|
||||
return Collections.enumeration(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String name, Object value)
|
||||
{
|
||||
try (AutoLock l = _lock.lock())
|
||||
Object oldValue = super.getAttribute(name);
|
||||
|
||||
if (value == null)
|
||||
super.removeAttribute(name);
|
||||
else
|
||||
super.setAttribute(name, value);
|
||||
|
||||
if (!_servletContextAttributeListeners.isEmpty())
|
||||
{
|
||||
Object oldValue = super.getAttribute(name);
|
||||
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext, name, oldValue == null ? value : oldValue);
|
||||
|
||||
if (value == null)
|
||||
super.removeAttribute(name);
|
||||
else
|
||||
super.setAttribute(name, value);
|
||||
|
||||
if (!_servletContextAttributeListeners.isEmpty())
|
||||
for (ServletContextAttributeListener listener : _servletContextAttributeListeners)
|
||||
{
|
||||
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext, name, oldValue == null ? value : oldValue);
|
||||
|
||||
for (ServletContextAttributeListener listener : _servletContextAttributeListeners)
|
||||
{
|
||||
if (oldValue == null)
|
||||
listener.attributeAdded(event);
|
||||
else if (value == null)
|
||||
listener.attributeRemoved(event);
|
||||
else
|
||||
listener.attributeReplaced(event);
|
||||
}
|
||||
if (oldValue == null)
|
||||
listener.attributeAdded(event);
|
||||
else if (value == null)
|
||||
listener.attributeRemoved(event);
|
||||
else
|
||||
listener.attributeReplaced(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2385,17 +2370,14 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
||||
@Override
|
||||
public void removeAttribute(String name)
|
||||
{
|
||||
try (AutoLock l = _lock.lock())
|
||||
Object oldValue = super.getAttribute(name);
|
||||
super.removeAttribute(name);
|
||||
if (oldValue != null && !_servletContextAttributeListeners.isEmpty())
|
||||
{
|
||||
Object oldValue = super.getAttribute(name);
|
||||
super.removeAttribute(name);
|
||||
if (oldValue != null && !_servletContextAttributeListeners.isEmpty())
|
||||
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext, name, oldValue);
|
||||
for (ServletContextAttributeListener listener : _servletContextAttributeListeners)
|
||||
{
|
||||
ServletContextAttributeEvent event = new ServletContextAttributeEvent(_scontext, name, oldValue);
|
||||
for (ServletContextAttributeListener listener : _servletContextAttributeListeners)
|
||||
{
|
||||
listener.attributeRemoved(event);
|
||||
}
|
||||
listener.attributeRemoved(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user