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

2018-06-06 Thread Ben Caradoc-Davies
Agreed, and Java generics are erased at compile time and offer no run time benefits. Kind regards, Ben. On 07/06/18 08:06, Nuno Oliveira wrote: Hi Ben, +1 for the NON generics option, my felling is that usually generics bring more harm than good in the long run :( On 06/06/2018 03:44 AM,

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

2018-06-06 Thread Nuno Oliveira
Hi Ben, +1 for the NON generics option, my felling is that usually generics bring more harm than good in the long run :( On 06/06/2018 03:44 AM, Ben Caradoc-Davies wrote: Or with generics: public interface ThrowingDisposable extends AutoCloseable {     /** * @see java.lang.AutoCloseab

Re: [Geoserver-devel] [Geotools-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: [Geoserver-devel] [Geotools-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: [Geoserver-devel] [Geotools-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: [Geoserver-devel] [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: [Geoserver-devel] [Geotools-devel] API changes to add AutoCloseable for try-with-resources

2018-06-05 Thread Christian Mueller
A big +1 one from my side, the auto closable feature increases code quality. Cheers On Tue, Jun 5, 2018 at 10:47 AM, Niels Charlier wrote: > No voting rights here, but just wanted to express my support for this! > > > On 05-06-18 10:02, Nuno Oliveira wrote: > >> I would add the AutoClose inte

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

2018-06-05 Thread Niels Charlier
No voting rights here, but just wanted to express my support for this! On 05-06-18 10:02, Nuno Oliveira wrote: 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

Re: [Geoserver-devel] [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: [Geoserver-devel] [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: [Geoserver-devel] [Geotools-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