details:   https://code.openbravo.com/erp/devel/pi/rev/d142537185dc
changeset: 26620:d142537185dc
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Wed May 13 13:50:58 2015 +0200
summary:   fixed bug 29849: RequestDispatcher.include deletes context from 
current thread

  This code:

     RequestDispatcher dispatcher = request.getRequestDispatcher(url);
     dispatcher.include(wrappedRequest, response)

  deletes context OBContext and RequestContext.

  The problem is caused because the way Tomcat internally manages it. By 
definition
  RequestDispatcher.include should not execute the Request filters (only the 
include
  ones) but they were executed causing this issue. They were executed because
  of the manner the special attribute to get the dispatch type is obtained, as
  the wrappedRequest now extends javax.servlet.http.HttpServletRequestWrapper it
  is managed differently than before when this was not the case, now type was 
always
  "Request" even when it should be "Include".

  The fix consists on managing getAttribute from request differently when they 
are
  special Tomcat internal attributes getting them from the request instead of 
from
  the delegate.

diffstat:

 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/RequestContext.java
 |  8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diffs (18 lines):

diff -r 46c71bc865ae -r d142537185dc 
modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/RequestContext.java
--- 
a/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/RequestContext.java
   Tue May 12 17:14:50 2015 +0200
+++ 
b/modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/RequestContext.java
   Wed May 13 13:50:58 2015 +0200
@@ -216,6 +216,14 @@
       if (delegate == null) {
         return attributes.get(arg0);
       }
+
+      if (arg0 != null && arg0.startsWith("org.apache.catalina.core") && 
getRequest() != null) {
+        // Retrieving internal Tomcat attributes, manage it as special case. 
Ie. dispatcher type is
+        // treated internally in a different manner and requires to be 
obtained from the request
+        // rather than from the delegate.
+        return getRequest().getAttribute(arg0);
+      }
+
       return delegate.getAttribute(arg0);
     }
 

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to