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

This commit is contained in:
xy 2026-10-09 13:38:00 +08:00
parent 56b73f0432
commit 1e9815a0d5

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