341692 Fixed deadlock if stopped while starting

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2961 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-04-04 06:58:50 +00:00
parent b9db79a381
commit a775708997
4 changed files with 33 additions and 54 deletions

View File

@ -24,6 +24,7 @@ jetty-7.4.0-SNAPSHOT
+ 341561 Exception when adding o.e.j.s.DoSFilter as managed attribute
+ 341736 Split jetty-nested out of war module
+ 341726 JSONPojoConverter handles characters
+ 341692 Fixed deadlock if stopped while starting
+ JETTY-1245 Pooled Buffers implementation
+ JETTY-1354 Added jetty-nested
+ Ensure generated fragment names are unique

View File

@ -13,6 +13,8 @@
package org.eclipse.jetty.util.component;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.log.Log;
@ -33,7 +35,8 @@ public abstract class AbstractLifeCycle implements LifeCycle
private final Object _lock = new Object();
private final int __FAILED = -1, __STOPPED = 0, __STARTING = 1, __STARTED = 2, __STOPPING = 3;
private volatile int _state = __STOPPED;
protected LifeCycle.Listener[] _listeners;
protected final CopyOnWriteArrayList<LifeCycle.Listener> _listeners=new CopyOnWriteArrayList<LifeCycle.Listener>();
protected void doStart() throws Exception
{
@ -125,12 +128,12 @@ public abstract class AbstractLifeCycle implements LifeCycle
public void addLifeCycleListener(LifeCycle.Listener listener)
{
_listeners = (LifeCycle.Listener[])LazyList.addToArray(_listeners,listener,LifeCycle.Listener.class);
_listeners.add(listener);
}
public void removeLifeCycleListener(LifeCycle.Listener listener)
{
_listeners = (LifeCycle.Listener[])LazyList.removeFromArray(_listeners,listener);
_listeners.remove(listener);
}
public String getState()
@ -157,68 +160,43 @@ public abstract class AbstractLifeCycle implements LifeCycle
private void setStarted()
{
Log.debug(STARTED+" {}",this);
_state = __STARTED;
if (_listeners != null)
{
for (int i = 0; i < _listeners.length; i++)
{
_listeners[i].lifeCycleStarted(this);
}
}
Log.debug(STARTED+" {}",this);
for (Listener listener : _listeners)
listener.lifeCycleStarted(this);
}
private void setStarting()
{
Log.debug("starting {}",this);
_state = __STARTING;
if (_listeners != null)
{
for (int i = 0; i < _listeners.length; i++)
{
_listeners[i].lifeCycleStarting(this);
}
}
for (Listener listener : _listeners)
listener.lifeCycleStarting(this);
}
private void setStopping()
{
Log.debug("stopping {}",this);
_state = __STOPPING;
if (_listeners != null)
{
for (int i = 0; i < _listeners.length; i++)
{
_listeners[i].lifeCycleStopping(this);
}
}
for (Listener listener : _listeners)
listener.lifeCycleStopping(this);
}
private void setStopped()
{
Log.debug(STOPPED+" {}",this);
_state = __STOPPED;
if (_listeners != null)
{
for (int i = 0; i < _listeners.length; i++)
{
_listeners[i].lifeCycleStopped(this);
}
}
Log.debug(STOPPED+" {}",this);
for (Listener listener : _listeners)
listener.lifeCycleStopped(this);
}
private void setFailed(Throwable th)
{
_state = __FAILED;
Log.warn(FAILED+" " + this+": "+th);
Log.debug(th);
_state = __FAILED;
if (_listeners != null)
{
for (int i = 0; i < _listeners.length; i++)
{
_listeners[i].lifeCycleFailure(this,th);
}
}
for (Listener listener : _listeners)
listener.lifeCycleFailure(this,th);
}
public static abstract class AbstractLifeCycleListener implements LifeCycle.Listener

View File

@ -13,6 +13,7 @@
package org.eclipse.jetty.util.component;
import java.util.EventListener;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.log.Log;
@ -37,16 +38,16 @@ import org.eclipse.jetty.util.log.Log;
*/
public class Container
{
private Object _listeners;
private final CopyOnWriteArrayList<Container.Listener> _listeners=new CopyOnWriteArrayList<Container.Listener>();
public synchronized void addEventListener(Container.Listener listener)
public void addEventListener(Container.Listener listener)
{
_listeners=LazyList.add(_listeners,listener);
_listeners.add(listener);
}
public synchronized void removeEventListener(Container.Listener listener)
public void removeEventListener(Container.Listener listener)
{
_listeners=LazyList.remove(_listeners,listener);
_listeners.remove(listener);
}
/* ------------------------------------------------------------ */
@ -56,7 +57,7 @@ public class Container
* @param child The current child. If this is non null and differs from <code>oldChild</code>, then an add event is generated.
* @param relationship The name of the relationship
*/
public synchronized void update(Object parent, Object oldChild, final Object child, String relationship)
public void update(Object parent, Object oldChild, final Object child, String relationship)
{
if (oldChild!=null && !oldChild.equals(child))
remove(parent,oldChild,relationship);
@ -72,7 +73,7 @@ public class Container
* @param relationship The name of the relationship
* @param addRemove If true add/remove is called for the new/old children as well as the relationships
*/
public synchronized void update(Object parent, Object oldChild, final Object child, String relationship,boolean addRemove)
public void update(Object parent, Object oldChild, final Object child, String relationship,boolean addRemove)
{
if (oldChild!=null && !oldChild.equals(child))
{
@ -97,7 +98,7 @@ public class Container
* @param children The current array of children. An add event is generated for any child in this array but not in the <code>oldChildren</code> array.
* @param relationship The name of the relationship
*/
public synchronized void update(Object parent, Object[] oldChildren, final Object[] children, String relationship)
public void update(Object parent, Object[] oldChildren, final Object[] children, String relationship)
{
update(parent,oldChildren,children,relationship,false);
}
@ -111,7 +112,7 @@ public class Container
* @param relationship The name of the relationship
* @param addRemove If true add/remove is called for the new/old children as well as the relationships
*/
public synchronized void update(Object parent, Object[] oldChildren, final Object[] children, String relationship, boolean addRemove)
public void update(Object parent, Object[] oldChildren, final Object[] children, String relationship, boolean addRemove)
{
Object[] newChildren = null;
if (children!=null)
@ -293,6 +294,5 @@ public class Container
public void removeBean(Object bean);
public void add(Container.Relationship relationship);
public void remove(Container.Relationship relationship);
}
}

View File

@ -747,15 +747,15 @@ public abstract class RFC2616BaseTest
List<HttpResponseTester> responses = http.requests(req3);
System.err.println(responses);
// System.err.println(responses);
response=responses.get(0);
System.err.println(response.getRawResponse());
// System.err.println(response.getRawResponse());
response.assertStatus("8.2.3 ignored no 100",302);
response=responses.get(1);
System.err.println(response.getRawResponse());
// System.err.println(response.getRawResponse());
response.assertStatus("8.2.3 ignored no 100",200);
response.assertBody("87654321\n");
}