https://issues.apache.org/bugzilla/show_bug.cgi?id=54019

          Priority: P2
            Bug ID: 54019
          Assignee: dev@tomcat.apache.org
           Summary: org.apache.coyote.Response & org.apache.coyote.Request
                    don't call recycle() on notes[] elements.
          Severity: critical
    Classification: Unclassified
          Reporter: frederic.arn...@gmail.com
          Hardware: PC
            Status: NEW
           Version: unspecified
         Component: Connectors
           Product: Tomcat 7

Note: I'll use coyoteRequest (resp. coyoteResponse) where in code it's req
(resp. res), it just to help because there's also the connectorRequest (resp.
connectorResponse).

CoyoteAdapter checks coyoteRequest (resp. coyoteResponse) notes content in
CoyoteAdapter method service(coyoreRequest, coyoteResponse):
        Request request = (Request) req.getNote(ADAPTER_NOTES);
        Response response = (Response) res.getNote(ADAPTER_NOTES);

If they exist, it will not create a new one and set it as note in coyoteRequest
(resp. coyoteResponse):
        if (request == null) {
            ...
            // Set as notes
            req.setNote(ADAPTER_NOTES, request);
            res.setNote(ADAPTER_NOTES, response);
            ...
        }

There's no change later on theses notes, so recycle must work for them!

But (here the but): coyoteRequest (resp. coyoteResponse) will not recycle
theses notes.

Side effect of bug: in some cases (in my case it's for IOException while using
Comet API):
1) I can get the request attributes of previous request
2) My output buffer in response is corrupted, on first access like
setBufferSize I got an IllegalStateException buffer already commited (today I'm
not sure if it's the root cause, but now I can't reproduce it with my fix).
3) Side effect also on traditional servlet (and JSP for sure!).



Fix (for me, below a general fix):
==================================
I added this in org.apache.coyote.Request at end of recycle() method:
        for(Object note : notes) {
            if (note instanceof org.apache.catalina.connector.Request) {
                ((org.apache.catalina.connector.Request) note).recycle();
            }
        }

And this in org.apache.coyote.Response at end of recycle() method:
        for(Object note : notes) {
            if (note instanceof org.apache.catalina.connector.Response) {
                ((org.apache.catalina.connector.Response) note).recycle();
            }
        }



Final fix need a solution like (since notes will not use only connector Request
and Response):
1) Create a new Recyclable interface like:
public interface Recyclable {
        void recycle();
}

2) Change some object that could be used in notes (but maybe all recyclable
objects) to implements this interface:
        package org.apache.coyote;
        ...
        public final class Response implements Recyclable {
        ...
        }
and:
        package org.apache.coyote;
        ...
        public final class Request implements Recyclable {
        ...
        }

3) Do this in recycle method for org.apache.coyote.Request and Response:
        for(Object note : notes) {
            if (note instanceof Recyclable) {
                ((Recyclable) note).recycle();
            }
        }



IMPORTANT: THIS HAPPENS ALSO ON TOMCAT 6!



best regards
f.arnoud

-- 
You are receiving this mail because:
You are the assignee for the bug.

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

Reply via email to