Github user HyukjinKwon commented on the issue:
https://github.com/apache/spark/pull/16451
> Utils.deleteRecursively does seem to delete the contents first, so I
don't know why it fails on Windows.
Maybe, I misunderstood this comment and also I might be wrong but let me
try to explain at my best.
On Windows, if we have a folder below and call
`Utils.deleteRecursively(".\\tmp")`,
```
tmp
âââ resource1.txt
```
It will try to remove `resource1.txt` first. If anything opened
`resource1.txt` without closing, Windows does not seem allowing to delete
`resource1.txt` and also the folder `tmp` unless the object referencing
`resource1.txt` closes it or is garbage-collected.
For example,
- Windows
```scala
scala> new java.io.FileInputStream("resource1.txt")
res2: java.io.FileInputStream = java.io.FileInputStream@4980d3
scala> new java.io.File("resource1.txt").delete()
res3: Boolean = false
scala> new java.io.File("resource1.txt").exists()
res4: Boolean = true
```
- Mac
```scala
scala> new java.io.FileInputStream("resource1.txt")
res6: java.io.FileInputStream = java.io.FileInputStream@13805618
scala> new java.io.File("resource1.txt").delete()
res7: Boolean = true
scala> new java.io.File("resource1.txt").exists()
res8: Boolean = false
```
So, if deleting `resource1.txt` throws an exception in `finally` block by
`true` from `!file.delete()` and `true` from `file.exists()`. Afterwords,
another exception is thrown by the failure of removing `tmp` because the
directory is not empty in `finally` block.
This suppresses the original exception message from the failure of removing
the contents but throws a new exception that says the failure of removing the
parent directory.
---
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.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]