Github user mateiz commented on a diff in the pull request:
https://github.com/apache/spark/pull/577#discussion_r12303524
--- Diff:
core/src/main/scala/org/apache/spark/broadcast/HttpBroadcast.scala ---
@@ -159,18 +159,24 @@ private[spark] object HttpBroadcast extends Logging {
def write(id: Long, value: Any) {
val file = getFile(id)
- val out: OutputStream = {
- if (compress) {
- compressionCodec.compressedOutputStream(new FileOutputStream(file))
- } else {
- new BufferedOutputStream(new FileOutputStream(file), bufferSize)
+ val fileOutputStream = new FileOutputStream(file)
+ try {
+ val out: OutputStream = {
+ if (compress) {
+ compressionCodec.compressedOutputStream(fileOutputStream)
+ } else {
+ new BufferedOutputStream(fileOutputStream, bufferSize)
+ }
}
+ val ser = SparkEnv.get.serializer.newInstance()
+ val serOut = ser.serializeStream(out)
+ serOut.writeObject(value)
+ serOut.close()
+ files += file.getAbsolutePath
+ }
+ finally {
+ fileOutputStream.close
--- End diff --
Also, add parentheses to close: `close()`. The convention is that things
with side effects have parentheses, while things that are just field getters or
conversions (e.g. toString) can skip them.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---