Yes, it was Java 7 syntax. I can also invoke the close method explicitly, but I 
still get the SEVERE messages and the exception:

public class SmallerExample {
    public static void main(String[] args) throws Exception {
        org.geotools.data.simple.SimpleFeatureIterator it = newStore(new 
java.net.URL(args[0])).getFeatureSource().getFeatures().features();
        try {
            while (it.hasNext()) it.next();
        }
        finally {
            it.close();
        }
    }
    
    static org.geotools.data.shapefile.ShapefileDataStore newStore(java.net.URL 
url) {
        org.geotools.data.shapefile.ShapefileDataStore shapefileDataStore = new 
org.geotools.data.shapefile.ShapefileDataStore(url);
        shapefileDataStore.setCharset(java.nio.charset.StandardCharsets.UTF_8);
        return shapefileDataStore;
    }
}

Output:

May 09, 2014 11:25:41 AM org.geotools.data.shapefile.files.ShpFiles 
logCurrentLockers
SEVERE: The following locker still has a lock: read on file://A:/ Streets.shp 
by org.geotools.data.shapefile.shp.ShapefileReader
May 09, 2014 11:25:41 AM org.geotools.data.shapefile.files.ShpFiles 
logCurrentLockers
SEVERE: The following locker still has a lock: read on file://A:/ Streets.shx 
by org.geotools.data.shapefile.shp.IndexFile
May 09, 2014 11:25:41 AM org.geotools.data.shapefile.files.ShpFiles 
logCurrentLockers
SEVERE: The following locker still has a lock: read on file://A:/ Streets.dbf 
by org.geotools.data.shapefile.dbf.DbaseFileReader
Exception in thread "main" java.lang.IllegalArgumentException: Expected 
requestor org.geotools.data.shapefile.dbf.DbaseFileReader@255fcb67 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:9)
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• 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