Skip to content

Commit

Permalink
Avoid possible NPEs
Browse files Browse the repository at this point in the history
Found by coverity.
  • Loading branch information
rmaucher committed Jan 17, 2024
1 parent 87091ce commit c63ba52
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions java/org/apache/jasper/servlet/JspCServletContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ public String getRealPath(String path) {
return null;
}
try {
File f = new File(getResource(path).toURI());
URL url = getResource(path);
if (url == null) {
return null;
}
File f = new File(url.toURI());
return f.getAbsolutePath();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
Expand Down Expand Up @@ -425,7 +429,11 @@ public URL getResource(String path) throws MalformedURLException {
@Override
public InputStream getResourceAsStream(String path) {
try {
return getResource(path).openStream();
URL url = getResource(path);
if (url == null) {
return null;
}
return url.openStream();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
return null;
Expand Down

0 comments on commit c63ba52

Please sign in to comment.