Skip to content

Commit

Permalink
Merge pull request #462 from kagemomiji/issue412-uncaught-sockjs-erro…
Browse files Browse the repository at this point in the history
…r-by-client-abort

#412 Add feature to handle nested client abort exceptions
  • Loading branch information
kagemomiji committed May 16, 2024
2 parents 4bfc6d0 + b917b90 commit 05975b6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion airsonic-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.19.4</version>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.springframework.ldap</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ public ModelAndView resolveException(
// This happens often and outside of the control of the server, so
// we catch Tomcat/Jetty "connection aborted by client" exceptions
// and display a short error message.
boolean shouldCatch = Util.isInstanceOfClassName(e, "org.apache.catalina.connector.ClientAbortException")
|| Util.isInstanceOfClassName(e.getCause(), "org.apache.catalina.connector.ClientAbortException");
boolean shouldCatch = isClientAbortException(e);
if (shouldCatch) {
LOG.info("{}: Client unexpectedly closed connection while loading {} ({})", request.getRemoteAddr(), Util.getAnonymizedURLForRequest(request), e.getCause().toString());
LOG.info("{}: Client unexpectedly closed connection while loading {}", request.getRemoteAddr(), Util.getAnonymizedURLForRequest(request));
return null;
}

Expand All @@ -41,4 +40,20 @@ public ModelAndView resolveException(
public int getOrder() {
return Integer.MIN_VALUE;
}

/**
* Check if the exception or any of its causes is a "client abort" exception.
*
* @param e The exception to check
* @return True if the exception or any of its causes is a "client abort" exception
*/
private boolean isClientAbortException(Throwable e) {
if (e == null) {
return false;
}
if (Util.isInstanceOfClassName(e, "org.apache.catalina.connector.ClientAbortException")) {
return true;
}
return isClientAbortException(e.getCause());
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<dependency>
<groupId>com.google.j2objc</groupId>
<artifactId>j2objc-annotations</artifactId>
<version>2.8</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
Expand Down Expand Up @@ -275,7 +275,7 @@
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>9.1.0</version>
<version>9.2.0</version>
<inherited>true</inherited>
<configuration>
<cveValidForHours>24</cveValidForHours>
Expand Down

0 comments on commit 05975b6

Please sign in to comment.