[github-911] close DataSource before deleting temp file

This commit is contained in:
PJ Fanning 2025-09-26 19:22:32 +01:00
parent 7a124135de
commit 03fc1ddea1

View File

@ -47,12 +47,15 @@ public class TempFilePOIFSFileSystem extends POIFSFileSystem {
@Override
public void close() throws IOException {
if (tempFile != null && tempFile.exists()) {
if (!tempFile.delete()) {
LOG.atDebug().log("temp file was already deleted (probably due to previous call to close this resource)");
try {
super.close();
} finally {
if (tempFile != null && tempFile.exists()) {
if (!tempFile.delete()) {
LOG.atDebug().log("temp file was already deleted (probably due to previous call to close this resource)");
}
}
}
super.close();
}
}