We're updating the issue view to help you get more done. 

CSVDataStore doesn't clean up temp file when writing out

Description

If you create a new CSVFileDataStore and add a featureCollection to it the output file is correctly created but it leaves a temp file behind too.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 CSVDataStore csvStore = null; File states = new File("/home/ian/Data/states/states.shp"); try { FileDataStore s = FileDataStoreFinder.getDataStore(states); SimpleFeatureCollection coll = s.getFeatureSource().getFeatures(); String geometryPropertyName; geometryPropertyName = coll.getSchema().getGeometryDescriptor().getLocalName(); File fileToSave = new File("export.csv"); Map<String, Object> cvsParams = new HashMap<>(); cvsParams.put(CSVDataStoreFactory.FILE_PARAM.key, fileToSave.getAbsolutePath()); cvsParams.put(CSVDataStoreFactory.STRATEGYP.key, CSVDataStoreFactory.WKT_STRATEGY); cvsParams.put(CSVDataStoreFactory.WKTP.key, geometryPropertyName); csvStore = (CSVDataStore) DataStoreFinder.getDataStore(cvsParams); csvStore.createSchema(coll.getSchema()); CSVFeatureStore csvFeatureStore = (CSVFeatureStore) csvStore .getFeatureSource(csvStore.getTypeName().getLocalPart()); csvFeatureStore.addFeatures(coll); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (csvStore != null) csvStore.dispose(); }

Initially reported at GIS Stackexchange

Environment

None

Status

Assignee

Ian Turton

Reporter

Ian Turton

Triage

Components

Fix versions

Affects versions

20.0
21-RC

Priority

Medium