From 9338ef2496a356cd0f866b647a490fc022d09e8e Mon Sep 17 00:00:00 2001 From: "jian.wang" <824612544@qq.com> Date: Mon, 27 May 2024 12:57:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3pdf=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=8C=85=E6=96=87=E4=BB=B6=E6=8D=9F=E5=9D=8F?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../templateSearch/TemplateSearchController.java | 2 ++ .../batchExport/BatchExportServiceImpl.java | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java b/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java index 17469bb..61cee73 100644 --- a/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java +++ b/src/main/java/com/emr/controller/templateSearch/TemplateSearchController.java @@ -1344,6 +1344,8 @@ public class TemplateSearchController { while ((len = bis.read(buf, 0, buf.length)) != -1) { bos.write(buf, 0, len); } + bis.close(); // 及时关闭流,避免资源泄露 + out.reset(); } } catch (Exception e) { ExceptionPrintUtil.printException(e); diff --git a/src/main/java/com/emr/service/batchExport/BatchExportServiceImpl.java b/src/main/java/com/emr/service/batchExport/BatchExportServiceImpl.java index 1da3ecb..35515f5 100644 --- a/src/main/java/com/emr/service/batchExport/BatchExportServiceImpl.java +++ b/src/main/java/com/emr/service/batchExport/BatchExportServiceImpl.java @@ -295,7 +295,7 @@ public class BatchExportServiceImpl implements BatchExportService { public Boolean imageToPdf1(List scanPathVos, ByteArrayOutputStream bos, EmrPdfWaterSet pdfWaterSet) { //ByteArrayOutputStream bos = null; - FileOutputStream fileOutputStream = null; + //FileOutputStream fileOutputStream = null; PdfWriter writer = null; try { //bos = new ByteArrayOutputStream(); @@ -380,22 +380,20 @@ public class BatchExportServiceImpl implements BatchExportService { e.printStackTrace(); return false; } finally { - //try { + try { if (writer != null) { writer.close(); } /*if (fileOutputStream != null) { fileOutputStream.close(); - } - + }*/ if (bos != null) { bos.flush(); bos.close(); - }*/ - - /*} catch (IOException e) { + } + } catch (IOException e) { e.printStackTrace(); - }*/ + } } return true; }