[MGNLDAM-1146] Better checks for broken pipe exceptions in DamDownloadServlet Created: 31/Mar/23  Updated: 13/Apr/23

Status: Open
Project: Magnolia DAM Module
Component/s: DAM Core
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Neutral
Reporter: Marzena Sieradzka Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLDAM-1147 Implementation Sub-task To Do  
MGNLDAM-1148 Review Sub-task To Do  
MGNLDAM-1149 Pre-Integration QA Sub-task To Do  
MGNLDAM-1150 QA Sub-task To Do  
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Epic Link: AuthorX Support
Team: AuthorX

 Description   

On Tomcat 9 broken pipe exceptions are (often? always?) thrown without setting partial content response code. Proposed patch fixes this.

Subject: [PATCH] tomcat class patch
---
Index: info/magnolia/dam/core/download/DamDownloadServlet.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/info/magnolia/dam/core/download/DamDownloadServlet.java b/info/magnolia/dam/core/download/DamDownloadServlet.java
--- a/info/magnolia/dam/core/download/DamDownloadServlet.java	(revision 06fa5448169640aa8d4471a3c994784e47ee3ed7)
+++ b/info/magnolia/dam/core/download/DamDownloadServlet.java	(revision fd24dd353346cde6951828db43f71a02e1538959)
@@ -78,6 +78,8 @@
 public class DamDownloadServlet extends HttpServlet implements SelfMappingServlet {
     private static final Logger log = LoggerFactory.getLogger(DamDownloadServlet.class);
 
+    private static final String CLIENT_ABORT_CLASS = "org.apache.catalina.connector.ClientAbortException";
+
     static final String CONTENT_DISPOSITION = "Content-Disposition";
     static final String LAST_MODIFIED = "Last-Modified";
 
@@ -194,7 +196,8 @@
             }
             // re-throw exception only if it's not a partial content response, else logs would fill up with (harmless)
             // broken pipe exceptions on some app servers (e.g. Tomcat)
-            if (res.getStatus() != HttpServletResponse.SC_PARTIAL_CONTENT) {
+            if (res.getStatus() != HttpServletResponse.SC_PARTIAL_CONTENT &&
+                    !CLIENT_ABORT_CLASS.equals(e.getClass().getName())) {
                throw e;
             }
         } finally {

Generated at Mon Feb 12 05:06:42 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.