From bc1f02cdb5a55fe6fff9d9738e22435f5bdcccaf Mon Sep 17 00:00:00 2001 From: "lucio.lelii" Date: Mon, 1 Mar 2021 16:21:52 +0100 Subject: [PATCH] check if response is already committed on error --- CHANGELOG.md | 5 +++++ pom.xml | 2 +- .../java/org/gcube/smartgears/managers/RequestManager.java | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5769885..ab89d6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm # Changelog for Common Smartgears +## [v3.0.2] - 2020-03-01 + +- check if response is already committed on error + + ## [v3.0.1] - 2020-11-18 - new Uma Token integration diff --git a/pom.xml b/pom.xml index 38f3d5c..66a2e36 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.core common-smartgears - 3.0.1 + 3.0.2-SNAPSHOT SmartGears diff --git a/src/main/java/org/gcube/smartgears/managers/RequestManager.java b/src/main/java/org/gcube/smartgears/managers/RequestManager.java index 2cb2b3d..11cf66c 100644 --- a/src/main/java/org/gcube/smartgears/managers/RequestManager.java +++ b/src/main/java/org/gcube/smartgears/managers/RequestManager.java @@ -98,7 +98,7 @@ public class RequestManager implements Filter { // dispatch to other filters for this servlet chain.doFilter(request, response); }catch(ServletException t){ - log.error("error in doFilter",t.getRootCause()); + log.error("error in doFilter",t); handleError(httprequest,httpresponse,t.getRootCause()); } @@ -260,7 +260,8 @@ public class RequestManager implements Filter { RequestException.class.cast(t).error(): application_error; - response.resetBuffer(); + if (!response.isCommitted()) + response.resetBuffer(); if (error == request_not_authorized_error){ response.setHeader("WWW-Authenticate", "Basic realm=\"Smartgears\""); log.info("setting WWW-Authenticate to response header");