Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4A39D200B40 for ; Fri, 1 Jul 2016 14:56:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 48D41160A5D; Fri, 1 Jul 2016 12:56:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8E8C1160A6C for ; Fri, 1 Jul 2016 14:56:12 +0200 (CEST) Received: (qmail 90119 invoked by uid 500); 1 Jul 2016 12:56:11 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 90088 invoked by uid 99); 1 Jul 2016 12:56:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Jul 2016 12:56:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 354F12C02A5 for ; Fri, 1 Jul 2016 12:56:11 +0000 (UTC) Date: Fri, 1 Jul 2016 12:56:11 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@flink.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (FLINK-4096) Nested FileOutputStream is not closed in JarFileCreator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 01 Jul 2016 12:56:13 -0000 [ https://issues.apache.org/jira/browse/FLINK-4096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15358915#comment-15358915 ] ASF GitHub Bot commented on FLINK-4096: --------------------------------------- Github user zentol commented on a diff in the pull request: https://github.com/apache/flink/pull/2172#discussion_r69295166 --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/util/JarFileCreator.java --- @@ -189,33 +189,33 @@ public synchronized void createJarFile() throws IOException { this.outputFile.delete(); } - final JarOutputStream jos = new JarOutputStream(new FileOutputStream(this.outputFile), new Manifest()); - final Iterator> it = this.classSet.iterator(); - while (it.hasNext()) { + try ( JarOutputStream jos = new JarOutputStream(new FileOutputStream(this.outputFile), new Manifest())) { + final Iterator> it = this.classSet.iterator(); + while (it.hasNext()) { - final Class clazz = it.next(); - final String entry = clazz.getName().replace('.', '/') + CLASS_EXTENSION; + final Class clazz = it.next(); + final String entry = clazz.getName().replace('.', '/') + CLASS_EXTENSION; - jos.putNextEntry(new JarEntry(entry)); + jos.putNextEntry(new JarEntry(entry)); - String name = clazz.getName(); - int n = name.lastIndexOf('.'); - String className = null; - if (n > -1) { - className = name.substring(n + 1, name.length()); - } - //Using the part after last dot instead of class.getSimpleName() could resolve the problem of inner class. - final InputStream classInputStream = clazz.getResourceAsStream(className + CLASS_EXTENSION); + String name = clazz.getName(); + int n = name.lastIndexOf('.'); + String className = null; + if (n > -1) { + className = name.substring(n + 1, name.length()); + } + //Using the part after last dot instead of class.getSimpleName() could resolve the problem of inner class. + final InputStream classInputStream = clazz.getResourceAsStream(className + CLASS_EXTENSION); - int num = classInputStream.read(buf); - while (num != -1) { - jos.write(buf, 0, num); - num = classInputStream.read(buf); - } + int num = classInputStream.read(buf); + while (num != -1) { + jos.write(buf, 0, num); + num = classInputStream.read(buf); + } - classInputStream.close(); - jos.closeEntry(); + classInputStream.close(); + jos.closeEntry(); + } } - jos.close(); --- End diff -- close() is now never called. > Nested FileOutputStream is not closed in JarFileCreator > ------------------------------------------------------- > > Key: FLINK-4096 > URL: https://issues.apache.org/jira/browse/FLINK-4096 > Project: Flink > Issue Type: Bug > Reporter: Ted Yu > Assignee: Ivan Mushketyk > Priority: Minor > > {code} > final JarOutputStream jos = new JarOutputStream(new FileOutputStream(this.outputFile), new Manifest()); > {code} > When jos is closed, the FileOutputStream is not automatically closed. > FileOutputStream should be closed explicitly. -- This message was sent by Atlassian JIRA (v6.3.4#6332)