VPF not closing files on FeatureReader.close()

Description

When running through multiple feature types and getting all the features VPF opens lots of files and never closes them (even after a FeatureReader.close() call). For large data sets this can result in IOExceptions indicating that too many files are open.

Attached is a simple program that causes this problem when run against VMap0 data.

Environment

None

Activity

Show:
codehaus
April 10, 2015, 3:06 PM

CodeHaus Comment From: jmeagher - Time: Fri, 4 Mar 2005 10:51:43 -0600
---------------------
I was unable to attache the program so here it is:

import java.io.File;

import org.geotools.data.DataStore;

import org.geotools.data.FeatureReader;

import org.geotools.data.FeatureResults;

import org.geotools.data.FeatureSource;

import org.geotools.feature.Feature;

import com.vividsolutions.jts.geom.Geometry;

public class VPFRunThrough

{

  public static void main( String[] args )

    throws Exception

  {

    if ( args.length != 1 )

    {

      System.err.println( "Usage: java " + VPFRunThrough.class.getName() + " <VPF directory containing lht file>" );

      System.exit( 1 );

    }

    DataStore ds = new org.geotools.data.vpf.VPFLibrary( new File( args[0] ) );

    String[] types = ds.getTypeNames();

    for ( int i = 0; i < types.length; i++ )

      runThrough( ds, types[i] );

  }

  static void runThrough( DataStore ds, String feature )

    throws Exception

  {

    FeatureReader fr = null;

    try

    {

      FeatureSource fs = ds.getFeatureSource( feature );

      FeatureResults res = fs.getFeatures();

      fr = res.reader();

      while ( fr.hasNext() )

      {

        Feature f = fr.next();

        Geometry g = f.getDefaultGeometry();

        if ( g == null )

          System.out.println( "Default Geometry is null for: " + f );

      }

    }

    finally

    {

      if ( fr != null ) fr.close();

    }

  }

}

  

Assignee

Unassigned

Reporter

codehaus

Triage

None

Components

Fix versions

Affects versions

Priority

High
Configure