javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-146

NPE in ExternalContextImpl.dispatch() when file not present

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.1_01
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      146

      Description

      If you pass a bogus path to ExternalContextImpl.dispatch(), you get
      a NullPointerException.

      This happens because ServletRequest.getRequestDispatcher() returns null,
      but the code doesn't check for null. The proper fix would be checking
      for null and calling response.sendError(HttpServletResponse.SC_NOT_FOUND).

        Activity

        Hide
        jayashri added a comment -

        Taking ownership

        Show
        jayashri added a comment - Taking ownership
        Hide
        jayashri added a comment -

        Adam, fix below. can you please review ? thanks.

        Index: src/com/sun/faces/context/ExternalContextImpl.java
        ===================================================================
        RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/context/External
        ContextImpl.java,v
        retrieving revision 1.32
        diff -u -r1.32 ExternalContextImpl.java
        — src/com/sun/faces/context/ExternalContextImpl.java 1 Jun 2005 14:03:31 -000
        0 1.32
        +++ src/com/sun/faces/context/ExternalContextImpl.java 16 Jul 2005 00:52:02 -00
        00
        @@ -344,6 +344,11 @@
        public void dispatch(String requestURI) throws IOException, FacesException
        {
        RequestDispatcher requestDispatcher = request.getRequestDispatcher(
        requestURI);
        + if (requestDispatcher == null)

        { + ((HttpServletResponse) response). + sendError(HttpServletResponse.SC_NOT_FOUND); + return; + }

        try

        { requestDispatcher.forward(this.request, this.response); }

        catch (IOException ioe) {

        Show
        jayashri added a comment - Adam, fix below. can you please review ? thanks. Index: src/com/sun/faces/context/ExternalContextImpl.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/context/External ContextImpl.java,v retrieving revision 1.32 diff -u -r1.32 ExternalContextImpl.java — src/com/sun/faces/context/ExternalContextImpl.java 1 Jun 2005 14:03:31 -000 0 1.32 +++ src/com/sun/faces/context/ExternalContextImpl.java 16 Jul 2005 00:52:02 -00 00 @@ -344,6 +344,11 @@ public void dispatch(String requestURI) throws IOException, FacesException { RequestDispatcher requestDispatcher = request.getRequestDispatcher( requestURI); + if (requestDispatcher == null) { + ((HttpServletResponse) response). + sendError(HttpServletResponse.SC_NOT_FOUND); + return; + } try { requestDispatcher.forward(this.request, this.response); } catch (IOException ioe) {
        Hide
        jayashri added a comment -

        Fix checked in. Thanks Adam

        Show
        jayashri added a comment - Fix checked in. Thanks Adam
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            jayashri
            Reporter:
            adamwiner
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: