Uploaded image for project: 'GeoTools'
  1. GEOT-6175

CSVDataStore doesn't clean up temp file when writing out

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Fixed
    • Affects versions: 20.0, 21-RC
    • Fix versions: 19.4, 20.2, 21-M0
    • Components: csv
    • Labels:
      None

      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.

       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

        Attachments

          Activity

            People

            • Assignee:
              ianturton Ian Turton
              Reporter:
              ianturton Ian Turton
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: