Skip to content

Commit

Permalink
Use short circuit logic to prevent potential NPE in CorsFilter.
Browse files Browse the repository at this point in the history
The same logic is used a few lines below, so it was most probably
intended that way anyways. 


git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1837786 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
FSchumacher committed Aug 10, 2018
1 parent 6b4aa79 commit d6191c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion java/org/apache/catalina/filters/CorsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ private void addStandardHeaders(final HttpServletRequest request,
String.valueOf(preflightMaxAge));
}

if ((allowedHttpMethods != null & !allowedHttpMethods.isEmpty())) {
if ((allowedHttpMethods != null) && (!allowedHttpMethods.isEmpty())) {
response.addHeader(
CorsFilter.RESPONSE_HEADER_ACCESS_CONTROL_ALLOW_METHODS,
join(allowedHttpMethods, ","));
Expand Down
3 changes: 3 additions & 0 deletions webapps/docs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
<bug>62607</bug>: Return a non-zero exit code from
<code>catalina.[bat|sh] run</code> if Tomcat fails to start. (markt)
</add>
<fix>
Use short circuit logic to prevent potential NPE in CorsFilter. (fschumacher)
</fix>
</changelog>
</subsection>
<subsection name="Coyote">
Expand Down

0 comments on commit d6191c4

Please sign in to comment.