From 587e6568314bb37caa66dc63ddcde53bf82cc03a Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Mon, 1 Jan 2018 12:23:18 +0000 Subject: [PATCH] No functional refactoring changes while reviewing r1819730 Removes useless exceptions handling. Uses try-w/-ress for ByteArrayInputStream git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1819764 13f79535-47bb-0310-9956-ffa450edef68 --- .../ofbiz/content/compdoc/CompDocEvents.java | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java b/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java index 30887e935c..a6a8f60df6 100644 --- a/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java +++ b/applications/content/src/main/java/org/apache/ofbiz/content/compdoc/CompDocEvents.java @@ -43,7 +43,6 @@ import org.apache.ofbiz.entity.util.EntityQuery; import org.apache.ofbiz.service.GenericServiceException; import org.apache.ofbiz.service.LocalDispatcher; import org.apache.ofbiz.service.ModelService; -import org.apache.ofbiz.service.ServiceAuthException; import org.apache.ofbiz.service.ServiceUtil; import org.apache.ofbiz.webapp.event.CoreEvents; import org.apache.ofbiz.webapp.website.WebSiteWorker; @@ -176,15 +175,9 @@ public class CompDocEvents { Debug.logError(errorMessage, module); return "error"; } - } catch (ServiceAuthException e) { - request.setAttribute("_ERROR_MESSAGE_", e.toString()); - return "error"; } catch (GenericServiceException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; - } catch (Exception e) { - request.setAttribute("_ERROR_MESSAGE_", e.toString()); - return "error"; } ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer"); @@ -192,9 +185,7 @@ public class CompDocEvents { // setup content type String contentType = "application/pdf; charset=ISO-8859-1"; - ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array()); - - try { + try (ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array())) { UtilHttp.streamContentToBrowser(response, bais, outByteBuffer.limit(), contentType); } catch (IOException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); @@ -233,15 +224,9 @@ public class CompDocEvents { Debug.logError(errorMessage, module); return "error"; } - } catch (ServiceAuthException e) { - request.setAttribute("_ERROR_MESSAGE_", e.toString()); - return "error"; } catch (GenericServiceException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString()); return "error"; - } catch (Exception e) { - request.setAttribute("_ERROR_MESSAGE_", e.toString()); - return "error"; } ByteBuffer outByteBuffer = (ByteBuffer) results.get("outByteBuffer"); @@ -249,9 +234,7 @@ public class CompDocEvents { // setup content type String contentType = "application/pdf; charset=ISO-8859-1"; - ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array()); - - try { + try (ByteArrayInputStream bais = new ByteArrayInputStream(outByteBuffer.array())) { UtilHttp.streamContentToBrowser(response, bais, outByteBuffer.limit(), contentType); } catch (IOException e) { request.setAttribute("_ERROR_MESSAGE_", e.toString());