you need to dispose of all your objects otherwise streams will not be
closed (until the finalize kicks in).

Regards,
Simone Giannecchini
==
Online training classes for GeoNode, GeoServer and MapStore from the
experts!
Visit https://www.geosolutionsgroup.com/professional-training/ for more
information.
==
Ing. Simone Giannecchini
Founder/Director GeoSolutions Italy
President GeoSolutions USA

phone: +39 0584 962313
fax:     +39 0584 1660272
mob:   +39  333 8128928
US: +1 (845) 547-7905

https://www.geosolutionsgroup.com
https://www.linkedin.com/company/geosolutionsgroup/
https://x.com/geosolutions_it

-------------------------------------------------------
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

Reply via email to