So this is the Java 7 syntax right? I know we must call it.close() in order
to avoid the warnings, it was my understanding that the try-with-resource
syntax you are using would do the trick?

Jody Garnett


On Thu, May 8, 2014 at 2:19 AM, Seragiotto Clovis <
clovis.seragio...@ait.ac.at> wrote:

> Hello (again),
>
> I have the following program:
>
> public class SmallerExample {
>     public static void main(String[] args) throws Exception {
>         org.geotools.data.shapefile.ShapefileDataStore shapefileDataStore
> = new org.geotools.data.shapefile.ShapefileDataStore(new
> java.net.URL(args[0]));
>
> shapefileDataStore.setCharset(java.nio.charset.StandardCharsets.UTF_8);
>
>         try (org.geotools.data.simple.SimpleFeatureIterator it =
> shapefileDataStore.getFeatureSource().getFeatures().features()) {
>             while (it.hasNext()) it.next();
>         }
>     }
> }
>
> When I run this program, the following messages are logged:
> . SEVERE: The following locker still has a lock: read on
> file:/A:/Streets.shp by org.geotools.data.shapefile.shp.ShapefileReader
> . SEVERE: The following locker still has a lock: read on
> file:/A:/Streets.shx by org.geotools.data.shapefile.shp.IndexFile
> . SEVERE: The following locker still has a lock: read on
> file:/A:/Streets.dbf by org.geotools.data.shapefile.dbf.DbaseFileReader
>
> And then the program finishes with an exception when the
> SimpleFeatureIterator is closed:
> Exception in thread "main" java.lang.IllegalArgumentException: Expected
> requestor org.geotools.data.shapefile.dbf.DbaseFileReader@2f478e10 to
> have locked the url but it does not hold the lock for the URL
>         at
> org.geotools.data.shapefile.files.ShpFiles.unlockRead(ShpFiles.java:429)
>         at
> org.geotools.data.shapefile.files.FileChannelDecorator.implCloseChannel(FileChannelDecorator.java:149)
>         at
> java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:115)
>         at
> org.geotools.data.shapefile.dbf.DbaseFileReader.close(DbaseFileReader.java:286)
>         at
> org.geotools.data.shapefile.ShapefileFeatureReader.close(ShapefileFeatureReader.java:251)
>         at
> org.geotools.data.store.ContentFeatureCollection$WrappingFeatureIterator.close(ContentFeatureCollection.java:154)
>         at SmallerExample.main(SmallerExample.java:8)
>
> Is it possible to avoid the SEVERE messages and the
> IllegalArgumentException (without configuring the logger to not show SEVERE
> messages and without catching the exception and ignoring it)?
>
> Thank you
> -- Clovis
>
>
> ------------------------------------------------------------------------------
> Is your legacy SCM system holding you back? Join Perforce May 7 to find
> out:
> &#149; 3 signs your SCM is hindering your productivity
> &#149; Requirements for releasing software faster
> &#149; Expert tips and advice for migrating your SCM now
> http://p.sf.net/sfu/perforce
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to