Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-11153

ThreadLocal is not cleaned when an exception occurs in ExceptionFilter.endWebRequestAfterException

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: EAP_EWP 5.1.0
    • Fix Version/s: EAP_EWP 5.3.0.GA
    • Component/s: Seam2
    • Labels:
      None
    • Docs QE Status:
      NEW

      Description

      If the seam application outputs the exception in executing ExceptionFilter.endWebRequestAfterException (ex1,ex2), ThreadLocal is not cleaned because the endRequest(line 133 ex3) is not executed.

      The following example is EAP 5.1 environment. However, it should occur in latest EAP version (EAP 5.2) too.

      ex1
      org.jboss.seam.ConcurrentRequestTimeoutException: Concurrent call to conversation
          at org.jboss.seam.core.Manager.restoreAndLockConversation(Manager.java:641)
          at org.jboss.seam.core.Manager.restoreConversation(Manager.java:603)
      ->    at org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:107)
      
      ex2
      java.lang.NullPointerException
      	at org.jboss.web.tomcat.service.session.JBossCacheManager.loadSession(JBossCacheManager.java:2096)
      	at org.jboss.web.tomcat.service.session.JBossCacheManager.findSession(JBossCacheManager.java:595)
      	at org.apache.catalina.connector.Request.doGetSession(Request.java:2351)
      	at org.apache.catalina.connector.Request.getSession(Request.java:2094)
      	at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)
      	at org.jboss.seam.mock.MockExternalContext.getSessionMap(MockExternalContext.java:357)
      	at org.jboss.seam.contexts.FacesLifecycle.beginExceptionRecovery(FacesLifecycle.java:86)
      ->	at org.jboss.seam.web.ExceptionFilter.endWebRequestAfterException(ExceptionFilter.java:96)
      
      ex3 org.jboss.seam.web.ExceptionFilter.java
       74#   protected void endWebRequestAfterException(HttpServletRequest request, HttpServletResponse response, Exception e) 
       75#         throws ServletException, IOException
       76#   {
       77#      
       78#      log.debug("running exception handlers");
       79#      
       80#      //if the event context was cleaned up, fish the conversation id 
       81#      //directly out of the ServletRequest attributes, else get it from
       82#      //the event context
       83#      Manager manager = Contexts.isEventContextActive() ?
       84#              (Manager) Contexts.getEventContext().get(Manager.class) :
       85#              (Manager) request.getAttribute( Seam.getComponentName(Manager.class) );
       86#      String conversationId = manager==null ? null : manager.getCurrentConversationId();
       87#      
       88#      // Ensure that the call in which the exception occurred was cleaned up - it might not be, and there is no harm in trying
       89#      Lifecycle.endRequest();
       90#      
       91#      //the FacesContext is gone - create a fake one for Redirect and HttpError to call
       92#      MockFacesContext facesContext = createFacesContext(request, response);
       93#      facesContext.setCurrent();
       94#      
       95#      //Initialize the temporary context objects
      -> 96#      FacesLifecycle.beginExceptionRecovery( facesContext.getExternalContext() );
       97#      
       98#      //If there is an existing long-running conversation on
       99#      //the failed request, propagate it
      100#      if (conversationId==null)
      101#      {
      102#          Manager.instance().initializeTemporaryConversation();
      103#      }
      104#      else
      105#      {
      106#          ConversationPropagation.instance().setConversationId(conversationId);
      ->107#          Manager.instance().restoreConversation();
      108#      }
      109#      
      110#      //Now do the exception handling
      111#      try
      112#      {
      113#         rollbackTransactionIfNecessary();
      114#         Exceptions.instance().handle(e);
      115#      }
      116#      catch (ServletException se)
      117#      {
      118#         throw se;
      119#      }
      120#      catch (IOException ioe)
      121#      {
      122#         throw ioe;
      123#      }
      124#      catch (Exception ehe)
      125#      {
      126#         throw new ServletException(ehe);
      127#      }
      128#      finally
      129#      {
      130#         //Finally, clean up the contexts
      131#         try 
      132#         {
      ->133#            FacesLifecycle.endRequest( facesContext.getExternalContext() );
      134#            facesContext.release();
      135#            log.debug("done running exception handlers");
      136#         }
      137#         catch (Exception ere)
      138#         {
      139#            log.error("could not destroy contexts", ere);
      140#         }
      141#      }
      142#   }
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                manaRH Marek Novotny
                Reporter:
                enagai Eiichi Nagai
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: