forward not checking for null on getRequestDispatcher(path)
-----------------------------------------------------------
Key: TILES-255
URL: https://issues.apache.org/struts/browse/TILES-255
Project: Tiles
Issue Type: Bug
Components: tiles-core
Affects Versions: 2.0.5
Reporter: Thom Hehl
Priority: Minor
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());
}
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.