Hi Wicketeers,

I noticed that WicketFilter.getLastModified creates a RequestCycle but does not /detach /it, so onEndRequest is not called. I use JCR and open a session to it on first use (lazy init). I store the JCR session in th RequestCycle. I close the JCR session in RequestCycle.onEndRequest (overriden). Kind of Open Session In View pattern. When WicketFilter.getLastModified calls Resource.getResourceStream() I have to open a JCR session to stream the requested resource. But then onEndRequest is not called on the RequestCycle so the JCR session remains open.

By debugging I found the following sequence in WicketFilter:
doFilter
   getLastModified
      webApplication.newRequestCycle
      resource.getResourceStream
      // requestCycle.detach - this is commented
      requestCycle.unset // this does not call onEndRequest
   doGet
      webApplication.newRequestCycle // second RequestCycle is created
cycle.request() // this calls again getResourceStream but also RequestCycle.detach

It turns out two RequestCycle's are created but only the second one is detached. Also Resource.getResourceStream is called twice. This is all for one request.

I use Wicket 1.4.1.

Best regards,
Peter

Reply via email to