You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Jung, Eric" <Er...@Arbella.com> on 2004/10/01 19:03:06 UTC

[configuration] JNDIConfiguration should close() its NamingEnumer ation on exception

Hi,

Great job on RC2! I love it. I do have one suggestion, however, with regards
to JNDIConfiguration. Three methods (recursiveGetKeys(), getContext(), and
isEmpty()) use NamingEnumeration but do not call NamingEnumeration.close()
if an exception is thrown while using that enumeration. All of these methods
call context.lookup() while enumerating, which can throw an exception. 

According to the javadoc on NamingEnumeration.close():

"This method is intended for aborting an enumeration to free up resources.
If an enumeration proceeds to the end--that is, until hasMoreElements() or
hasMore() returns false-- resources will be freed up automatically and there
is no need to explicitly call close()."

With this in mind, I'd like to see NamingEnumerations wrapped in try/catch
blocks with NamingEnumeration.close() called in the catch.

Any thoughts? Thanks for listening.

Sincerely,
Eric Jung

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: [configuration] JNDIConfiguration should close() its NamingEnumeration on exception

Posted by Emmanuel Bourg <sm...@lfjr.net>.
Jung, Eric wrote:

> With this in mind, I'd like to see NamingEnumerations wrapped in try/catch
> blocks with NamingEnumeration.close() called in the catch.
> 
> Any thoughts? Thanks for listening.

Good point, however according to the javadoc calling close() is not 
mandatory, it gives just a hint to the underlying implementation to free 
the resources, but if it helps we can do it :) I checked in a fix to 
close the NamingEnumerations in a finally block, let me know if it looks 
good for you.

Emmanuel Bourg


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org