7056489: test/com/sun/jndi/ldap/ReadTimeoutTest.java loops or times out (original) (raw)

Vincent Ryan vincent.x.ryan at oracle.com
Tue Jun 21 08:34:52 UTC 2011


Apologies for overlooking the core-libs audience.

On 06/20/11 23:42, Joe Darcy wrote:

Vincent Ryan wrote:

On 06/20/11 16:08, Alan Bateman wrote:

Vincent Ryan wrote:

: Thanks Alan. JNDI applications are encouraged to call close() rather than rely on GC to free resources.

I guess we can support both behaviours: long-lived JNDI applications can continue to use try blocks and explicitly call close(), when finished. Short-lived JNDI applications can use try-with-resources blocks and benefit from the automatic resource management. It really is just a 1-line change: marino% diff old/javax/naming/Context.java new/javax/naming/Context.java 281c281 < public interface Context {_ _---_ _> public interface Context extends AutoCloseable { marino% That's all it should be. Even where try/finally it used today there is still the possibility of close failing and supplanting a more interesting exception. Overall it sounds like this is worth doing. -Alan. Right. I've filed an RFE and targeted it to jdk8. http://monaco.us.oracle.com/detail.jsf?cr=7057061 FYI NamingEnumeration also supports a close() method to explicitly release resources, for example when discarding the remainder of a search result. Under normal circumstances, the final iteration of NamingEnumeration will cause its resources to be released automatically. So close() is only used when exiting an iteration prematurely. I don't think NamingEnumeration is a suitable candidate for try-with-resources because the common case is to complete the iteration and not to call close(). Hello. Vinnie, please reply about this rfe and your assessment of it to the core-libs list. Thanks, -Joe



More information about the core-libs-dev mailing list