IndexedShapefileDatastore doesn't play nice with read-only Shapefiles
---------------------------------------------------------------------

                 Key: GEOT-3245
                 URL: http://jira.codehaus.org/browse/GEOT-3245
             Project: GeoTools
          Issue Type: Bug
          Components: data shapefile
    Affects Versions: 2.7-M2, 2.6.5
            Reporter: Stefan Alfons Tzeggai
            Assignee: Andrea Aime
             Fix For: 2.6.6, 2.7-M3
         Attachments: preventIndexShapefileDStoCreateWhenReadonly.patch, 
removeLocksWhenExceptionHappenedInStorageFile.patch

When using IndexedShapefileDatastor on a Shapefile that is read-only and 
doesn't have a .fix index file, this is that happens:
1. there is no exception thrown
2. access to that Shapefile doesn't work cleanly (in other works, AtlasStyler 
hangs shortly after when tryin to paint the layer)
3. Subsequent tests in IndexedShapefileDataStoreTest (if executed after the 
read-only access) log severe messages about a lock not being correctly removed.

 SCHWERWIEGEND: The following locker still has a lock write on 
file:.../geotools/2.6.x/modules/plugin/shapefile/target/test-classes/org/geotools/data/shapefile/test-
 data/shapes/statepop.shp by StorageFile: statepop5902879307908035242.fix
 it was created with the following stack trace
org.geotools.data.shapefile.ShpFilesLocker$Trace: Locking 
file:....geotools/2.6.x/modules/plugin/shapefile/target/test-classes/org/geotools/data/shapefile/test-data/shapes/statepop.shp
 for write by StorageFile: statepop5902879307908035242.fix in thread main
        at 
org.geotools.data.shapefile.ShpFilesLocker.setTraceException(ShpFilesLocker.java:72)
        at 
org.geotools.data.shapefile.ShpFilesLocker.<init>(ShpFilesLocker.java:56)
        at org.geotools.data.shapefile.ShpFiles.acquireWrite(ShpFiles.java:509)
        at 
org.geotools.data.shapefile.StorageFile.replaceOriginals(StorageFile.java:97)
        at 
org.geotools.data.shapefile.StorageFile.replaceOriginal(StorageFile.java:73)
        at 
org.geotools.data.shapefile.indexed.FidIndexer.generate(FidIndexer.java:74)
        at 
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.generateFidIndex(IndexedShapefileDataStore.java:385)
        at 
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.<init>(IndexedShapefileDataStore.java:204)
        at 
org.geotools.data.shapefile.indexed.IndexedShapefileDataStore.<init>(IndexedShapefileDataStore.java:170)

Now I have two patches: The first one prevents the IndexedShapefileDatastore to 
try and create a .fix if it doesn't have write access. (Similar to the checks 
already performed that the URL to the Shapefile is "file://" and not "http://";).

The second patch is probably (and no junit test comes with it) a fix to the 
problem, that the lock has not been removed after the permission-denied 
exception is thrown.

Please review and give your opinions. The first "preventive" patch is longer 
but I understand what's happening there. With the second patch I am not 100% 
sure what is going on there.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
This SF.net email is sponsored by 

Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev 
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to