The format uses deferred loading, meaning it pulls tiles from the file as needed. Please dispose the coverage when you're done using it:
myCoverage.dispose(true) Regards, Andrea Aime == GeoServer Professional Services from the experts! Visit http://bit.ly/gs-services-us for more information. == Ing. Andrea Aime @geowolf Technical Lead GeoSolutions Group phone: +39 0584 962313 fax: +39 0584 1660272 mob: +39 339 8844549 https://www.geosolutionsgroup.com/ http://twitter.com/geosolutions_it ------------------------------------------------------- Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE 2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si precisa che ogni circostanza inerente alla presente email (il suo contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra operazione è illecita. Le sarei comunque grato se potesse darmene notizia. This email is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. We remind that - as provided by European Regulation 2016/679 “GDPR” - copying, dissemination or use of this e-mail or the information herein by anyone other than the intended recipient is prohibited. If you have received this email by mistake, please notify us immediately by telephone or e-mail On Thu, Dec 11, 2025 at 3:23 PM Viatcheslav Sysoltsev < [email protected]> wrote: > 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]> 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] > 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 >
_______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
