[
https://issues.apache.org/jira/browse/FLINK-22930?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated FLINK-22930:
-----------------------------------
Labels: pull-request-available (was: )
> [flink-python]: Resources should be closed
> ------------------------------------------
>
> Key: FLINK-22930
> URL: https://issues.apache.org/jira/browse/FLINK-22930
> Project: Flink
> Issue Type: Bug
> Components: API / Python
> Affects Versions: 1.13.1
> Reporter: wuguihu
> Priority: Minor
> Labels: pull-request-available
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> Files that implement the Closeable interface or its super-interface,
> AutoCloseable, needs to be closed after use.
> 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:
> {code: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) {
> ……
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)