java 7 try with resource compatibility - STEMLab/geotools GitHub Wiki
- 
Contact: Jody Garnett 
- 
Tagline: try-with-resource 
Description
Reading the Java 7 planned try-with-resource syntax I am convinced that supporting the Closable interface is necessary change for GeoTools 9.x.
Reading:
Status
This proposal is shaping up, ask question on the email list or vote below:
- Andrea Aime +1
- Ben Caradoc-Davies
- Christian Mueller +1
- Ian Turton +1
- Justin Deoliveira +1
- Jody Garnett +1
- Simone Giannecchini
Tasks
- 
:white_check_mark: Coordinate API Change (above patches should be tested / applied together) 
- 
Implement Closable\ - :white_check_mark: FeatureIterator
- :white_check_mark: FeatureReader
- :white_check_mark: FeatureWriter
 
- 
:white_check_mark: A lot of this work got rolled into the FeatureCollection clean up 
- 
Warn / Patch downstream applications (Combined with FeatureCollection cleanup)\ - :white_check_mark: Patch for GeoServer
- :warning: Patch for uDig (patch ready held up waiting for 1.3.3 release)
 
- 
Check the code examples in user guide\ - :white_check_mark: Feature Collection try-with-resource code example
- :white_check_mark: Geometry CRS Tutorial
- :white_check_mark: Query Tutorial
 
API Changes
FeatureIterator
BEFORE:
public interface FeatureIterator<F extends Feature> {
    public boolean hasNext();
    public F next() throws java.util.NoSuchElementException;
    public void close();
}
AFTER:
import java.lang.Closable;
public interface FeatureIterator<F extends Feature> extends Closable {
    public boolean hasNext();
    public F next() throws java.util.NoSuchElementException;
    public void close() throws IOException;
}
FeatureReader
BEFORE:
public interface FeatureReader<T extends FeatureType, F extends Feature> {
    T getFeatureType();
    F next() throws IOException, IllegalArgumentException, NoSuchElementException;
    boolean hasNext() throws IOException;
    void close() throws IOException;
}
AFTER:
import java.lang.Closable;
public interface FeatureReader<T extends FeatureType, F extends Feature> extends Closable {
    T getFeatureType();
    F next() throws IOException, IllegalArgumentException, NoSuchElementException;
    boolean hasNext() throws IOException;
    void close() throws IOException;
}
FeatureWriter
BEFORE:
public interface FeatureWriter<T extends FeatureType, F extends Feature> {
    T getFeatureType();
    F next() throws IOException;
    void remove() throws IOException;
    void write() throws IOException;
    boolean hasNext() throws IOException;
    void close() throws IOException;
}
AFTER:
import java.lang.Closable;
public interface FeatureWriter<T extends FeatureType, F extends Feature> extends Closable {
    T getFeatureType();
    F next() throws IOException;
    void remove() throws IOException;
    void write() throws IOException;
    boolean hasNext() throws IOException;
    void close() throws IOException;
}