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/06/04 06:45:23 UTC

[isis] 02/02: ISIS-1961: intercepting by 'magic text' handling tomcat-9 and payara-4

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 7b0fafa64b4208e60e76374d10d872794a198d93
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Jun 4 08:45:07 2018 +0200

    ISIS-1961: intercepting by 'magic text' handling tomcat-9 and payara-4
    
    Task-Url: https://issues.apache.org/jira/browse/ISIS-1961
---
 .../core/webapp/content/ResourceCachingFilter.java | 29 +++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

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 1d0ed24..0d9c81d 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
@@ -226,7 +226,19 @@ public class ResourceCachingFilter implements Filter {
             httpResponse.addHeader(EXPIRES_HEADER, httpDateFormat.format(new Date(now + (this.cacheTime.longValue() * 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) {
+        	if(!isConnectionAbortException(e)) {
+        		throw e;
+        	}
+		}
     }
 
     /**
@@ -237,5 +249,20 @@ public class ResourceCachingFilter implements Filter {
     @Override
     public void destroy() {
     }
+    
+    // -- 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;
+    }
 
 }

-- 
To stop receiving notification emails like this one, please contact
ahuber@apache.org.