!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) {
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();
}