I am still investigating this change. I think I have found a use-case where deprecation of dispose() and third-party migration to close() might introduce a resource leak. I will report back when I have finished my investigation.

Kind regards,
Ben.

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