The one thing I am still thinking about is the impact of checked exceptions. Our interfaces that include dispose() without throws should probably end up with close() without throws after stage two and keep dispose() without throws during stage one to maintain backwards compatibility (so client code using the interface does not get a compile failure with an unhandled exception during the transition). We might need two interfaces because we have dispose() without throws and dispose() with throws.

I hate checked exceptions so much.

On 07/06/18 14:29, Ben Caradoc-Davies wrote:
Jody,

the problem is that doing it this way will break any third-party code that already implements an interface with dispose(). Their implementation will override dispose() and fail to implement close().

What we could do is provide default implementations for *both* close() and @Deprecated dispose() that call each other. All implementations with dispose() will work fine, and will work just the same when dispose() is renamed to close().

I think we need a deprecation cycle:

Stage one (GeoTools 20): introduce @Deprecated interface Disposable (extends AutoCloseable) with @Deprecated default dispose() that calls close() and default close() that calls dispose(). All implementations have dispose() marked @Deprecated. All implementations can now have their dispose() renamed to close() as convenient, with @Deprecated removed. The default dispose() will provide backwards compatibility.

Stage two (GeoTools 21): remove Disposable entirely, replacing it with AutoClosable. Any remaining dispose() methods renamed to close(). Third-party code that ignored the deprecation warnings is now broken.

Is one release cycle enough deprecation before removal?

Kind regards,
Ben.

On 07/06/18 10:41, Jody Garnett wrote:
You could swap this around, rename the dispose implementations to close,
and provide a deprecated default implementation of dispose that calls
close.
This way you can manage eventually remove dispose() from the API.


--
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <https://transient.nz/>
New Zealand

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
GeoTools-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to