I have been trying to create a method to read in a shpfile parse it then return the nodes contained within. This works fine with a valid shape file. the issue occurs when using an invalid shapefile. When attempting to parse a corrupted shp file the datastore locks the file with a read lock, this prevents me from then deleting the file from the server. When trying to delete i get the exception "The process cannot access the file because it is being used by another process."
I have attached the corrupt shp file (which is just a text file renamed) and some sample java code to load and parse the file with comments on where it crashes.
here is a brief extract of the locking process
try{
dataStore = (ShapefileDataStore)
DataStoreFinder.getDataStore(connect);
String[] typeNames = dataStore.getTypeNames();
String typeName = typeNames[0];
featureSource = dataStore.getFeatureSource(typeName)
catch (Exception e) {
e.printStackTrace();
} finally {
try {
dataStore.dispose();
Files.delete(Paths.get(debugString)); } catch (IOException e) {
e.getMessage();
}
}
This is my first time using Geotools and my first bug report on here so any help is appreciated.
|