tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Gagnon <dgag...@siunik.com>
Subject Bug + Patch on StandardPipeline.removeValve(Valve valve) for T5.5.16+
Date Mon, 05 Jun 2006 12:40:18 GMT
Hi all,

  I run into this problem with T5 when tring to add/remove/add a valve 
to the standard engine. 
-For what I understand an empty pipeline has:
basic = StandardEngineValve (For example);
first = null;

-If you add a valve you will get
basic = StandardEngineValve
first = myValve (with myValve.next = StandardEngineValve)

-If you remove the valve you will get
basic =StandardEngineValve
first = StandardEngineValve
Note that StandardEngineValve is in first too here.

-If I try to add a new valve given the actual code in  addValve the 
valve will not be added because (see the **) current = basic and 
current.getNext() = null;

addValve(Valve valve) {
   

        // Add this Valve to the set associated with this Pipeline
        if (first == null) {
            first = valve;
            valve.setNext(basic);
        } else {
            Valve current = first;
            while (current != null) {
**                if (current.getNext() == basic) {
                    current.setNext(valve);
                    valve.setNext(basic);
                    break;
                }
                current = current.getNext();
            }
        }

    }


PATCH:
For what I understand the right patch will be in the removeValve 
method.  We need to remove the basic valve when that the only one in the 
pipeline:

 public void removeValve(Valve valve) {

        Valve current;
        if(first == valve) {
            first = first.getNext();
            current = null;
        } else {
            current = first;
        }
        while (current != null) {
            if (current.getNext() == valve) {
                current.setNext(valve.getNext());
                break;
            }
            current = current.getNext();
        }

         // PATCH: Empty the pipeline if only the basic valve is there
        if (first == basic) first == null;

        if (valve instanceof Contained)
            ((Contained) valve).setContainer(null);

        // Stop this valve if necessary
        if (started) {
            if (valve instanceof Lifecycle) {
                try {
                    ((Lifecycle) valve).stop();
                } catch (LifecycleException e) {
                    log.error("StandardPipeline.removeValve: stop: ", e);
                }
            }
            // Unregister the removed valave
            unregisterValve(valve);
        }
   
    }

Hope that oki.  I look the 5.5.17 code and the problem is still there.  
Is that the right way to submit a Patch. If I need to open a bug 
directly, let me know



Best Regard
/David


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message