mridulm commented on code in PR #46131:
URL: https://github.com/apache/spark/pull/46131#discussion_r1575703116
##########
core/src/main/scala/org/apache/spark/storage/DiskBlockObjectWriter.scala:
##########
@@ -174,23 +174,46 @@ private[spark] class DiskBlockObjectWriter(
* Should call after committing or reverting partial writes.
*/
private def closeResources(): Unit = {
- if (initialized) {
- Utils.tryWithSafeFinally {
- mcs.manualClose()
- } {
- channel = null
- mcs = null
- bs = null
- fos = null
- ts = null
- objOut = null
- initialized = false
- streamOpen = false
- hasBeenClosed = true
+ try {
+ if (streamOpen) {
+ Utils.tryWithSafeFinally {
+ objOut = closeIfNonNull(objOut)
+ bs = null
+ } {
+ bs = closeIfNonNull(bs)
Review Comment:
```suggestion
if (null != objOut) objOut.close()
bs = null
} {
if (null != bs) bs.close()
bs = null
```
And remove `closeIfNonNull`
##########
core/src/main/scala/org/apache/spark/storage/DiskBlockObjectWriter.scala:
##########
@@ -174,23 +174,46 @@ private[spark] class DiskBlockObjectWriter(
* Should call after committing or reverting partial writes.
*/
private def closeResources(): Unit = {
- if (initialized) {
- Utils.tryWithSafeFinally {
- mcs.manualClose()
- } {
- channel = null
- mcs = null
- bs = null
- fos = null
- ts = null
- objOut = null
- initialized = false
- streamOpen = false
- hasBeenClosed = true
+ try {
+ if (streamOpen) {
+ Utils.tryWithSafeFinally {
+ objOut = closeIfNonNull(objOut)
+ bs = null
+ } {
+ bs = closeIfNonNull(bs)
+ }
+ }
+ } catch {
+ case e: IOException =>
+ logError(log"Exception occurred while closing the output stream" +
+ log"${MDC(ERROR, e.getMessage)}")
Review Comment:
error -> info
and the exception stack trace would be useful
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]