Hi Ian, Been debugging, the stream (of type it.geosolutions.imageio.stream.eraf.EnhancedRandomAccessFile) remains not closed after call at org.geotools.gce.geotiff.GeoTiffReader#read():737 > pbjRead.add(maskOvrProvider.getSourceSpiProvider().getStream()); ... where it is passed to JaI/ImageN
With best regards, Slava ________________________________ Von: Ian Turton <[email protected]> Gesendet: Donnerstag, 11. Dezember 2025 12:16 An: Viatcheslav Sysoltsev <[email protected]> Cc: [email protected] <[email protected]> Betreff: Re: [Geotools-gt2-users] GeoTiffReader locks the file indefinitely? Sie erhalten nicht häufig E-Mails von [email protected]. Erfahren Sie, warum dies wichtig ist<https://aka.ms/LearnAboutSenderIdentification> I think that's the expected behaviour on a windows machine for any file opened in a program. The code clearly closes the input stream created from the file that is passed in so I don't think there is any reason GeoTools would be locking the file. Ian On Wed, 10 Dec 2025 at 17:31, Viatcheslav Sysoltsev <[email protected]<mailto:[email protected]>> wrote: Hi everyone, I'd like to ask if it is an intended behavior, that GeoTiffReader locks the file indefinitely? If yes, is there a way to read the file completely and "dispose" the reader and the lock? A simple program to demonstrate: import org.geotools.coverage.grid.GridCoverage2D; import org.geotools.gce.geotiff.GeoTiffReader; import org.junit.jupiter.api.Test; import java.io.File; import java.time.Duration; class GeotiffReaderTest { @Test public void read() throws Exception { File file = new File("C:\\Projects\\tmp\\tmp2\\qwf 2_TH.tif"); GeoTiffReader reader = new GeoTiffReader(file); GridCoverage2D grid = reader.read(null); Thread.sleep(Duration.ofSeconds(60)); } } when run, it reads the file and sleeps for a minute. Until JVM exits, the tif file cannot be moved or deleted: C:\Projects\tmp\tmp2>mv "qwf 2_TH.tif" "qwf 2_TH.tif2" /usr/bin/mv: cannot move 'qwf 2_TH.tif' to 'qwf 2_TH.tif2': Device or resource busy // the problem is reproducible with geotools 34.1 and 33.0 With best regards, Viatcheslav Sysoltsev / Slava _______________________________________________ GeoTools-GT2-Users mailing list [email protected]<mailto:[email protected]> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users -- Ian Turton
_______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
