From 1e9815a0d5393e664ac7433201ed00073fb75a99 Mon Sep 17 00:00:00 2001 From: xy <455640711@qq.com> Date: Fri, 9 Oct 2026 13:38:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=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=E6=97=B6=E6=9C=AA=E5=85=B3=E9=97=AD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dromara/gen/service/GenTableServiceImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 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 bfd5ff909..27a9a609c 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 @@ -341,8 +341,11 @@ public class GenTableServiceImpl implements IGenTableService { public byte[] downloadCode(Long tableId) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); - writeCodeToZip(tableId, zip); - IoUtil.close(zip); + try { + writeCodeToZip(tableId, zip); + } finally { + IoUtil.close(zip); + } return outputStream.toByteArray(); } @@ -408,10 +411,13 @@ public class GenTableServiceImpl implements IGenTableService { public byte[] downloadCode(String[] tableIds) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); - for (String tableId : tableIds) { - writeCodeToZip(Long.parseLong(tableId), zip); + try { + for (String tableId : tableIds) { + writeCodeToZip(Long.parseLong(tableId), zip); + } + } finally { + IoUtil.close(zip); } - IoUtil.close(zip); return outputStream.toByteArray(); }