File tree Expand file tree Collapse file tree 1 file changed +25
-15
lines changed
core/src/main/scala/org/apache/spark/serializer Expand file tree Collapse file tree 1 file changed +25
-15
lines changed Original file line number Diff line number Diff line change 1717
1818package org .apache .spark .serializer
1919
20- import java .io .{EOFException , InputStream , OutputStream }
20+ import java .io .{EOFException , IOException , InputStream , OutputStream }
2121import java .nio .ByteBuffer
2222
2323import scala .reflect .ClassTag
@@ -148,14 +148,22 @@ class KryoSerializationStream(
148148 this
149149 }
150150
151- override def flush () { output.flush() }
151+ override def flush () {
152+ if (output == null ) {
153+ throw new IOException (" Stream is closed" )
154+ }
155+ output.flush()
156+ }
157+
152158 override def close () {
153- try {
154- output.close()
155- } finally {
156- serInstance.releaseKryo(kryo)
157- kryo = null
158- output = null
159+ if (output != null ) {
160+ try {
161+ output.close()
162+ } finally {
163+ serInstance.releaseKryo(kryo)
164+ kryo = null
165+ output = null
166+ }
159167 }
160168 }
161169}
@@ -179,13 +187,15 @@ class KryoDeserializationStream(
179187 }
180188
181189 override def close () {
182- try {
183- // Kryo's Input automatically closes the input stream it is using.
184- input.close()
185- } finally {
186- serInstance.releaseKryo(kryo)
187- kryo = null
188- input = null
190+ if (input != null ) {
191+ try {
192+ // Kryo's Input automatically closes the input stream it is using.
193+ input.close()
194+ } finally {
195+ serInstance.releaseKryo(kryo)
196+ kryo = null
197+ input = null
198+ }
189199 }
190200 }
191201}
You can’t perform that action at this time.
0 commit comments