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

Reply via email to