diff --git a/core/src/main/scala/org/apache/spark/util/logging/FileAppender.scala b/core/src/main/scala/org/apache/spark/util/logging/FileAppender.scala index fdb1495899bc3..a61aa938307cb 100644 --- a/core/src/main/scala/org/apache/spark/util/logging/FileAppender.scala +++ b/core/src/main/scala/org/apache/spark/util/logging/FileAppender.scala @@ -76,7 +76,11 @@ private[spark] class FileAppender(inputStream: InputStream, file: File, bufferSi } } } { - closeFile() + try { + inputStream.close() + } finally { + closeFile() + } } } catch { case e: Exception => diff --git a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala index 4ce143f18bbf1..7a977c0fb7526 100644 --- a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala +++ b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala @@ -212,7 +212,7 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging { Random.nextBytes(bytes) val os = new ByteArrayOutputStream() - Utils.copyStream(new ByteArrayInputStream(bytes), os) + Utils.copyStream(new ByteArrayInputStream(bytes), os, true) assert(os.toByteArray.toList.equals(bytes.toList)) } @@ -488,7 +488,7 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging { test("resolveURIs with multiple paths") { def assertResolves(before: String, after: String): Unit = { - assume(before.split(",").length > 1) + assume(before.split(",").length >= 1) def resolve(uri: String): String = Utils.resolveURIs(uri) assert(resolve(before) === after) assert(resolve(after) === after)