!889 fix: 修复 downloadCode 两个重载 ZipOutputStream 异常时未关闭问题

* fix: 修复 downloadCode 两个重载 ZipOutputStream 异常时未关闭问题
This commit is contained in:
xy 2026-10-09 05:40:52 +00:00 committed by 疯狂的狮子Li
parent 56b73f0432
commit 03e8f097b2

View File

@ -341,8 +341,11 @@ public class GenTableServiceImpl implements IGenTableService {
public byte[] downloadCode(Long tableId) { public byte[] downloadCode(Long tableId) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
try {
writeCodeToZip(tableId, zip); writeCodeToZip(tableId, zip);
} finally {
IoUtil.close(zip); IoUtil.close(zip);
}
return outputStream.toByteArray(); return outputStream.toByteArray();
} }
@ -408,10 +411,13 @@ public class GenTableServiceImpl implements IGenTableService {
public byte[] downloadCode(String[] tableIds) { public byte[] downloadCode(String[] tableIds) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream); ZipOutputStream zip = new ZipOutputStream(outputStream);
try {
for (String tableId : tableIds) { for (String tableId : tableIds) {
writeCodeToZip(Long.parseLong(tableId), zip); writeCodeToZip(Long.parseLong(tableId), zip);
} }
} finally {
IoUtil.close(zip); IoUtil.close(zip);
}
return outputStream.toByteArray(); return outputStream.toByteArray();
} }