Re: [Geotools-devel] [Geoserver-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Ben Caradoc-Davies
Or with generics: public interface ThrowingDisposable extends AutoCloseable { /** * @see java.lang.AutoCloseable#close() */ @Deprecated @Override default void close() throws T { dispose(); } void dispose() throws T; } public interface Disposable extend

Re: [Geotools-devel] [Geoserver-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Ben Caradoc-Davies
On 06/06/18 13:48, Ben Caradoc-Davies wrote: I would also remove the exception specification because it can never be thrown, and for consistency with dispose(). Although I should note that there are several classes with a dispose() that throws. While this is ugly, it can be a necessary guard r

Re: [Geotools-devel] [Geoserver-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Ben Caradoc-Davies
Nuno, I think you are right. The problem with deprecating dispose is that the default method uses it and we will never be rid of it. What we really want is for implementers to use dispose() and for only try-with-resources to use close(). Java does not permit final on default methods

Re: [Geotools-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Ben Caradoc-Davies
Thanks, Nuno. How did you make the list? I have been using things like: find . -name "*.java" -exec grep -l 'void dispose()' {} \; | sort Instead of editing your list, I would like to make a change proposal on the wiki. Kind regards, Ben. On 05/06/18 22:17, Nuno Oliveira wrote: You can count

Re: [Geotools-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Ben Caradoc-Davies
On 05/06/18 20:05, Ian Turton wrote: On Tue, 5 Jun 2018 at 00:25, Ben Caradoc-Davies wrote: - Should we add AutoCloseable to interfaces, and if so which ones? We could make a list. This is an obvious first step, is there an easy way to do it? grep for dispose? I found many interfaces and cla

Re: [Geotools-devel] Backporting GEOT-5988, GEOT-5980, GEOT-5993 to 19.x

2018-06-05 Thread Daniele Romagnoli
More on this topic. Tomorrow, 30 days are elapsed after GEOT-6008 has been committed to master. Therefore I will backport that too on 19.x if no objections. No API-changes. It allows for supporting ImageMosaic multilevel sidecar files (basically a separate file containing footprint for each granule

Re: [Geotools-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Nuno Oliveira
You can count on me, I can dedicate some spare during WE to this. I guess before deciding on an attack plan, it would be good to have a list of the concerned interfaces, I have started to put a list together here: https://docs.google.com/spreadsheets/d/1u3488JvSs34IMZ1TLjJ5FYQBAFHhQ4QHqfHfULH_

Re: [Geotools-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Andrea Aime
On Tue, Jun 5, 2018 at 10:05 AM, Ian Turton wrote: > >> - Who is interested in participating in this work? >> >> > I'd be up to do some of it. > Same here. As spare time contribution, if we are a group, we do the deprecation, and attack one interface at a time. As a code sprint if we want to do

Re: [Geotools-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Ian Turton
On Tue, 5 Jun 2018 at 00:25, Ben Caradoc-Davies wrote: > Many interfaces in GeoTools and GeoServer use the Dispose pattern, often > with a dispose() method, but do not implement AutoCloseable, preventing > their use in a try-with-resources statement. Examples range from > ImageReader to DataStore

Re: [Geotools-devel] [Geoserver-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Nuno Oliveira
I would add the AutoClose interface to all interfaces that have the dispose method or a similar one. Then I would provide a default implementation for the close method that invokes the dispose method: default void close() throws Exception {   dispose(); } This would make the interfaces fully b