javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2241

ResourceHandlerImpl should not send a 404 on IOException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 2.1.3
    • Fix Version/s: 2.1.18, 2.2.0-m09
    • Component/s: None
    • Labels:
      None

      Description

      Currently, the ResourceHandlerImpl sends a 404 on an IOException of a write to response. See lines 292-294 of Mojarra 2.1.3:

      } catch (IOException ioe) {
          send404(context, resourceName, libraryName, ioe, true);
      } finally {
      

      In development stage, this will clutter the server logs with JSF1064 warnings whenever the client aborts the resource request by navigating away, or closing browser window, or by pressing Esc while the page is still busy loading.

      Those warnings are not exactly the problem, but the normal practice is to delegate such an `IOException` to the servletcontainer and let it handle the problem. Most of them will just ignore it. Sending a 404 makes only sense when the resource is indeed not physically present (i.e. InputStream is null, which is also checked at line 261-264, which is perfectly fine). Sending a 404 makes no sense halfway streaming the resource and/or when the client aborted the connection.

      I suggest to remove the catch (IOException) block altogether and let the servletcontainer do the job.

        Activity

        Hide
        Manfred Riem added a comment -

        Can you attach an example application (with sources) that demonstrates the problem?

        Show
        Manfred Riem added a comment - Can you attach an example application (with sources) that demonstrates the problem?
        Hide
        OlivierDupre added a comment -

        Hi Manfred,

        Unfortunately, I can't attach such an application. Mine is in a professional context and you would need acces to my DB...
        By the way I'm facing exactly the same "problem". Even when I'm loading the very first page of the application, I've 2 logs saying that "page.xhtml" cannot be loaded... while everything is displayed properly.

        Be sure that I'll try to reproduce the problem at home and will provide you a sample app as soon as I can give you something!

        Show
        OlivierDupre added a comment - Hi Manfred, Unfortunately, I can't attach such an application. Mine is in a professional context and you would need acces to my DB... By the way I'm facing exactly the same "problem". Even when I'm loading the very first page of the application, I've 2 logs saying that "page.xhtml" cannot be loaded... while everything is displayed properly. Be sure that I'll try to reproduce the problem at home and will provide you a sample app as soon as I can give you something!
        Hide
        Manfred Riem added a comment -

        Unfortunately the APIDoc for ResourceHandler specifies the behavior observed.

        See http://docs.oracle.com/javaee/6/api/javax/faces/application/ResourceHandler.html#handleResourceRequest(javax.faces.context.FacesContext)

        The second to last bullet point prevents me from applying the proposed fix.

        Please file a spec issue.

        Thanks!

        Show
        Manfred Riem added a comment - Unfortunately the APIDoc for ResourceHandler specifies the behavior observed. See http://docs.oracle.com/javaee/6/api/javax/faces/application/ResourceHandler.html#handleResourceRequest(javax.faces.context.FacesContext ) The second to last bullet point prevents me from applying the proposed fix. Please file a spec issue. Thanks!

          People

          • Assignee:
            Unassigned
            Reporter:
            balusc
          • Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: