Tiles
  1. Tiles
  2. TILES-255

forward not checking for null on getRequestDispatcher(path)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.5
    • Fix Version/s: 2.0.6
    • Component/s: tiles-core
    • Labels:
      None
    • Flags:
      Patch

      Description

      getRequestDispatcher(path) may return null if it cannot create a request dispatcher. In ServletTilesRequestContext.forward getRequestDispatcher is called, but the variable rd is never checked for null and can cause a NullPointerException in error conditions. Please change code from:

      private void forward(String path) throws IOException {
      RequestDispatcher rd = request.getRequestDispatcher(path);
      try

      { rd.forward(request, response); } catch (ServletException ex) { LOG.error("Servlet Exception while including path", ex); throw new IOException("Error including path '" + path + "'. " + ex.getMessage()); }
      }

      to:

      private void forward(String path) throws IOException {
      RequestDispatcher rd = request.getRequestDispatcher(path);

      if(rd==null){ LOG.error("No request dispatcher returned for path", ex); throw new IOException("No request dispatcher returned for path '" + path + "'. " + ex.getMessage()); }


      try { rd.forward(request, response); }

      catch (ServletException ex)

      { LOG.error("Servlet Exception while including path", ex); throw new IOException("Error including path '" + path + "'. " + ex.getMessage()); }

      }

        Activity

        Hide
        Antonio Petrelli added a comment -

        Please post a patch if you want it to be fixed.

        Thanks.

        Show
        Antonio Petrelli added a comment - Please post a patch if you want it to be fixed. Thanks.
        Hide
        Thom Hehl added a comment -

        I have provided the source code. How do I go about providing a patch if i don't have commit authority?

        Show
        Thom Hehl added a comment - I have provided the source code. How do I go about providing a patch if i don't have commit authority?
        Hide
        Antonio Petrelli added a comment -
        Show
        Antonio Petrelli added a comment - Use "svn diff": http://struts.apache.org/helping.html#patches
        Hide
        Antonio Petrelli added a comment -

        Applied a modified version of the patch submitted by Thom Hehl.
        Thanks Thom!

        Show
        Antonio Petrelli added a comment - Applied a modified version of the patch submitted by Thom Hehl. Thanks Thom!
        Hide
        Antonio Petrelli added a comment -

        Tiles 2.0.6 released.

        Show
        Antonio Petrelli added a comment - Tiles 2.0.6 released.

          People

          • Assignee:
            Antonio Petrelli
            Reporter:
            Thom Hehl
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development