hapihu opened a new pull request #16114:
URL: https://github.com/apache/flink/pull/16114
In flink-python module, the class "org.apache.flink.python.util.ZipUtils" 's
method extractZipFileWithPermissions(), the OutputStream should be closed.
The details are shown below:
```java
// class: org.apache.flink.python.util.ZipUtils
// method: extractZipFileWithPermissions
// line71:Use try-with-resources
public static void extractZipFileWithPermissions(String zipFilePath,
String targetPath)
throws IOException {
try (ZipFile zipFile = new ZipFile(zipFilePath)) {
Enumeration<ZipArchiveEntry> entries = zipFile.getEntries();
boolean isUnix = isUnix();
while (entries.hasMoreElements()) {
ZipArchiveEntry entry = entries.nextElement();
File file;
if (entry.isDirectory()) {
……
} else {
……
if (file.createNewFile()) {
//line 71
OutputStream output = new FileOutputStream(file);
IOUtils.copyBytes(zipFile.getInputStream(entry),
output);
} else {
throw new IOException(
"Create file: " + file.getAbsolutePath() + "
failed!");
}
}
if (isUnix) {
……
}
}
}
}
```
Use try-with-resources to close the OutputStream。
```java
try (OutputStream output = new
FileOutputStream(file)) {
IOUtils.copyBytes(zipFile.getInputStream(entry),
output);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]