You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/09/15 15:04:12 UTC
[isis] branch ISIS-1976-rethink-object-adapters updated: ISIS-1976:
reinstate selective IOException suppression on resource filter
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch ISIS-1976-rethink-object-adapters
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/ISIS-1976-rethink-object-adapters by this push:
new 84073ce ISIS-1976: reinstate selective IOException suppression on resource filter
84073ce is described below
commit 84073cea771d6478d366c3607295fc4a1936037b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sat Sep 15 17:04:00 2018 +0200
ISIS-1976: reinstate selective IOException suppression on resource
filter
Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
---
.../core/webapp/content/ResourceCachingFilter.java | 39 +++++++++++++++++++---
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/webapp/content/ResourceCachingFilter.java b/core/metamodel/src/main/java/org/apache/isis/core/webapp/content/ResourceCachingFilter.java
index d3f18ef..1eafb56 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/webapp/content/ResourceCachingFilter.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/webapp/content/ResourceCachingFilter.java
@@ -36,6 +36,8 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import org.apache.isis.commons.internal.exceptions._Exceptions.FluentException;
+
//@WebFilter(
// initParams = { @WebInitParam(name = "CacheTime", value = "86400") },
// urlPatterns = {
@@ -144,6 +146,11 @@ public class ResourceCachingFilter implements Filter {
httpDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
}
+ @Override
+ public void destroy() {
+ // nothing to do
+ }
+
/**
* Do filter.
*
@@ -178,13 +185,35 @@ public class ResourceCachingFilter implements Filter {
httpResponse.addHeader(EXPIRES_HEADER, httpDateFormat.format(new Date(now + (this.cacheTime * MILLISECONDS_IN_SECOND))));
}
httpRequest.setAttribute(REQUEST_ATTRIBUTE, true);
-
- chain.doFilter(servletRequest, servletResponse);
+
+ // try to suppress java.io.IOException of kind 'client connection abort'
+ // 1) the TCP protocol (by design) does not provide a means to check, whether a
+ // connection has been closed by the client
+ // 2) the exception thrown and the exception message text are specific to the
+ // servlet-engine implementation, so we can only guess here
+ try {
+ chain.doFilter(servletRequest, servletResponse);
+ } catch (IOException e) {
+ FluentException.of(e)
+ .suppressIf(this::isConnectionAbortException);
+ }
}
- @Override
- public void destroy() {
- // nothing to do
+ // -- HELPER
+
+ private boolean isConnectionAbortException(IOException e) {
+ // tomcat 9
+ if(e.getMessage().contains("An established connection was aborted by the software in your host machine")) {
+ return true;
+ }
+ // payara 4
+ if(e.getMessage().contains("Connection is closed")) {
+ return true;
+ }
+
+ return false;
}
+
+
}