0 Replies Latest reply on Jan 2, 2006 4:29 AM by Radhakrishnan Nariangadu

    Thread reuse for request

    Radhakrishnan Nariangadu Newbie

      Hi,

      We had an issue that has been resolved but felt it will be useful for others as an FYI posting.

      - We use a servlet to handle async requests using an iframe so that data in the page is refreshed without submitting the entire page,similar to AJAX.

      - Exceptions are not caught in the servlet and are handled by the error handler defined in web.xml (error-page for error type Throwable)

      - We have a filter that initializes request attributes and to ensure we dont do it twice we had used a threadlocal that is checked before the request initialization is performed. Due to an earlier filter mapping the filter could be called more than once for each request.

      This configuration failed in one scenario and is because JBoss was reusing the same thread to service a new request. We realized this because the threadlocal was already set and our request initialization code was being skipped. The scenario is given below...
      - When the async request servlet threw an exception and it was not caught within the servlet, JBoss reused the same thread.
      - When the exception was caught within the servlet and rethrown after cleanup the thread was not re-used.

      Not able to understand this behaviour and not sure if this is a bug in Jboss. But as we have cleaned up the filter mapping, the threadlocal was removed and therefore the request initialization always happens now.