Mantis - Resin
Viewing Issue Advanced Details
4990 minor always 03-15-12 16:23 05-22-12 16:14
rickHigh  
ferg  
normal  
closed  
fixed  
none    
none 4.0.28  
0004990: ProxyCacheFilterChain calls getHeader but wrapped HttpServletResponse missing getHeader method
ProxyCacheFilterChain calls getHeader but wrapped HttpServletResponse missing getHeader method.


CauchoResponseWrapper.getHeader is called by ProxyCacheFilterChain.



Here is the code.

CauchoResponseWrapper

  public String getHeader(String name)

  {

    return _response.getHeader(name);

  }


In Resin 3, it checked its own internal getHeader because the Servlet specification did not have a getHeader.
Without the cache control headers, the ProxyCache will not cache the results.

To make this backwards compatible with Resin 3, the proposed changes are as follows:




  public String getHeader(String name)

  {

    return _response.getHeader(name);

  }

In a way, the problem is in their code because they were suppose to subclass javax..HttpServletResponseWrapper not implement javax..HttpServletResponse. HttpServletResponseWrapper was created to avoid this type of problem. But if their code predates Servlet specification 2.3, then it is certainly not their problem. Going to make a note to make sure we do the same type of support for all new methods in our wrapper class.

  public String getHeader(String name)

  {

      try {

          return _response.getHeader(name);

      } catch (AbstractMethodError ame) {

          return null;

      }

  }

The above should do the trick, and make Resin 4 backwards compatible with Resin 3 wrt to ProxyCache.

  public String getHeader(String name) {
      try {
          return _response.getHeader(name);
      } catch (AbstractMethodError ame) {
          return null;
      }
  }


Stack trace...



[12-03-14 11:39:59.208] {http://*:8080-2} [^] java.lang.AbstractMethodError
                        at com.caucho.server.http.CauchoResponseWrapper.getHeader(CauchoResponseWrapper.java:314)
                        at com.caucho.server.httpcache.ProxyCacheFilterChain.fillEntry(ProxyCacheFilterChain.java:1018)
                        at com.caucho.server.httpcache.ProxyCacheFilterChain.startCaching(ProxyCacheFilterChain.java:859)
                        at com.caucho.server.webapp.IncludeResponseStream2.startCaching(IncludeResponseStream2.java:336)
                        at com.caucho.server.webapp.IncludeResponseStream2.flushCharBuffer(IncludeResponseStream2.java:184)
                        at com.caucho.server.http.ToByteResponseStream.flushBuffer(ToByteResponseStream.java:608)
                        at com.caucho.jsp.JspWriterAdapter.close(JspWriterAdapter.java:297)
                        at com.caucho.jsp.JspWriterAdapter.popWriter(JspWriterAdapter.java:280)
                        at com.caucho.jsp.PageContextImpl.release(PageContextImpl.java:1412)
                        at com.caucho.jsp.PageManager.freePageContext(PageManager.java:215)

Notes
(0005712)
rickHigh   
03-15-12 16:30   
Fixed in 4.0.27

http://bugs.caucho.com/view.php?id=4990 [^]

CauchoResponseWrapper.getHeader is called by ProxyCacheFilterChain.



Here is the code.

CauchoResponseWrapper

  public String getHeader(String name)

  {

    return _response.getHeader(name);

  }


In Resin 3, it checked its own internal getHeader because the Servlet specification did not have a getHeader.
Without the cache control headers, the ProxyCache will not cache the results.

To make this backwards compatible with Resin 3, the proposed changes are as follows:




  public String getHeader(String name)

  {

    return _response.getHeader(name);

  }

In a way, the problem is in their code becaue they were suppose to subclass javax..HttpServletResponseWrapper not implement javax..HttpServletResponse. HttpServletResponseWrapper was created to avoid this type of problem. But if their code predates Servlet specification 2.3, then it is certainly not their problem. I am going to make a note to make sure we do the same type of support for all new methods in our wrapper class.

  public String getHeader(String name)

  {

      try {

          return _response.getHeader(name);

      } catch (AbstractMethodError ame) {

          return null;

      }

  }

The above should do the trick, and make Resin 4 backwards compatible with Resin 3 wrt to ProxyCache.