You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Jianfei Wang (JIRA)" <ji...@apache.org> on 2016/09/17 12:04:21 UTC
[jira] [Reopened] (SPARK-17573) The FileInputStream may be
uncloseed when some exceptions occurs
[ https://issues.apache.org/jira/browse/SPARK-17573?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jianfei Wang reopened SPARK-17573:
----------------------------------
the issue has been changed
> The FileInputStream may be uncloseed when some exceptions occurs
> ----------------------------------------------------------------
>
> Key: SPARK-17573
> URL: https://issues.apache.org/jira/browse/SPARK-17573
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 2.0.0
> Reporter: Jianfei Wang
> Labels: performance
>
> I think that the InputStream may never be closed when some exceptions occur, we should surround this with try catch.
> {code}
> private def addFilesToZipStream(parent: String, source: File, output: ZipOutputStream): Unit = {
> if (source.isDirectory()) {
> output.putNextEntry(new ZipEntry(parent + source.getName()))
> for (file <- source.listFiles()) {
> addFilesToZipStream(parent + source.getName() + File.separator, file, output)
> }
> } else {
> val in = new FileInputStream(source)
> output.putNextEntry(new ZipEntry(parent + source.getName()))
> val buf = new Array[Byte](8192)
> var n = 0
> while (n != -1) {
> n = in.read(buf)
> if (n != -1) {
> output.write(buf, 0, n)
> }
> }
> output.closeEntry()
> in.close()
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org