Announcement Announcement Module
Collapse
No announcement yet.
HTTP response delivered to client before flow execution state is persisted Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP response delivered to client before flow execution state is persisted

    Hi,

    I'm using JSF and Spring Web Flow 2.0.8 and I have a problem with a simple HTML page containing an image.

    The implementation is as follows: The request that renders the HTML page retrieves the image from an external source and puts it in the HTTP session. At the end of the request, a custom subclass of DefaultFlowExecutionRepository (overriding the putFlowExecution method) stores all session attributes in the database along with the flow state.
    Also, an an <img> tag is rendered into the page pointing to an URL where a custom controller (implementing org.springframework.web.servlet.mvc.Controller) is waiting.

    The browser then sends a second request to retrieve the image. The custom controller reads the flow state with all saved session attributes including the image and delivers it back to the client.

    This approach works fine most of the time. Sometimes however, the second request fails because it can't find the flow state in the database.

    After some log analyzing, it turns out that the second request is sometimes processed on the server before the first request has even stored the flow state.

    This means that the HTTP response (the html page with the img tag) in the first request was delivered back to the browser before the flow state was saved, i.e. before the putFlowExecution method was called.

    I'm a bit clueless here - is this a bug or intended behaviour? I'd expect that all state is saved before the response is delivered so it is present for any followup request.

  • #2
    After some further investigation, it turns out the problem is not limited to the image display. It can be reproduced much more easily.

    If a complex web page is being rendered and I click on a button (while the server is still sending data and the browser is still rendering), a second request is started while the first request is still being processed on the server.

    In that case the second request tries to load the flow state from the repository, but the first request hasn't stored that yet because it is still rendering the response (i.e. the executionRepository.putFlowExecution method hasn't been called yet). In that case, the second request will obviously fail.

    Am I missing something here? This can't be the intended behaviour.

    Comment

    Working...
    X