ZNAP reader not releasing file handles properly

The ZNAP reader does not release all handles of the input file when closing the product in SNAP.

I close it and want to overwrite it in a separate process.
But I get the exception below. Only if I close SNAP, I can overwrite the product.
Also, this exception happens late during the process (after 2:30 minutes). Maybe the writer can check earlier if it can write to the destination?

WARNING: org.esa.snap.dataio.znap.ZnapProductWriter: Unable to close the zarr product writer store.
java.nio.file.FileSystemException: D:\EOData\_projects\test\S2B_MSIL2A_20240515T101559_s2geom.znap.zip: The process cannot access the file because it is being used by another process.

	at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:92)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
	at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
	at java.base/sun.nio.fs.WindowsFileSystemProvider.implDelete(WindowsFileSystemProvider.java:274)
	at java.base/sun.nio.fs.AbstractFileSystemProvider.delete(AbstractFileSystemProvider.java:105)
	at java.base/java.nio.file.Files.delete(Files.java:1142)
	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.sync(ZipFileSystem.java:1380)
	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.lambda$close$2(ZipFileSystem.java:295)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at jdk.zipfs/jdk.nio.zipfs.ZipFileSystem.close(ZipFileSystem.java:294)
	at com.bc.zarr.storage.ZipStore.close(ZipStore.java:147)
	at org.esa.snap.dataio.znap.ZnapProductWriter.close(ZnapProductWriter.java:230)
	at org.esa.snap.core.dataio.ProductIO.writeProduct(ProductIO.java:457)
	at org.esa.snap.core.dataio.ProductIO.writeProduct(ProductIO.java:421)

EOMasters_icon_60 Marco from EOMasters - Mastering Earth Observation

2 Likes

JIRA ticket SNAP-3843 created

2 Likes