From e1bdb03d69f65a294f4ec7e09829c072a667a325 Mon Sep 17 00:00:00 2001 From: CodeLancet <545073804@qq.com> Date: Fri, 9 Oct 2026 21:40:13 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20downloadCode=20?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E9=87=8D=E8=BD=BD=20ZipOutputStream=20?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/gen/service/GenTableServiceImpl.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/service/GenTableServiceImpl.java b/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/service/GenTableServiceImpl.java index 27a9a609c..201146e39 100644 --- a/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/service/GenTableServiceImpl.java +++ b/ruoyi-modules/ruoyi-gen/src/main/java/org/dromara/gen/service/GenTableServiceImpl.java @@ -340,11 +340,10 @@ public class GenTableServiceImpl implements IGenTableService { @Override public byte[] downloadCode(Long tableId) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ZipOutputStream zip = new ZipOutputStream(outputStream); - try { + try(ZipOutputStream zip = new ZipOutputStream(outputStream)) { writeCodeToZip(tableId, zip); - } finally { - IoUtil.close(zip); + } catch (IOException e) { + log.error("渲染模板失败,Zip输出流IO异常。", e); } return outputStream.toByteArray(); } @@ -410,13 +409,12 @@ public class GenTableServiceImpl implements IGenTableService { @Override public byte[] downloadCode(String[] tableIds) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - ZipOutputStream zip = new ZipOutputStream(outputStream); - try { + try(ZipOutputStream zip = new ZipOutputStream(outputStream)) { for (String tableId : tableIds) { writeCodeToZip(Long.parseLong(tableId), zip); } - } finally { - IoUtil.close(zip); + } catch (IOException e) { + log.error("渲染模板失败,Zip输出流IO异常。", e); } return outputStream.toByteArray(); }