Proposal: javax.naming.spi.NamingManager.clearInitialContextFactoryBuilder()

Andrew Guibert aguibert at
Thu May 11 21:25:13 UTC 2017

Alan, could you please commit this patch for me?  We've tested it locally
and all of the jdk_other tests pass with this change on jdk9.

<      * Once installed, the builder cannot be replaced.
<      * @exception IllegalStateException If a factory has already been
<         if (object_factory_builder != null)
<             throw new IllegalStateException("ObjectFactoryBuilder already
<      * the security manager to do so. Once installed, the builder cannot
<      * be replaced.
>      * the security manager to do so.
<      * @exception IllegalStateException If a builder was previous
<             if (initctx_factory_builder != null)
<                 throw new IllegalStateException(
<                     "InitialContextFactoryBuilder already set");

Alan Bateman <Alan.Bateman at> wrote on 05/10/2017 07:32:47 AM:

> From: Alan Bateman <Alan.Bateman at>
> To: Andrew Guibert <aguibert at>, core-libs-dev at
> Date: 05/10/2017 07:32 AM
> Subject: Re: Proposal:
> javax.naming.spi.NamingManager.clearInitialContextFactoryBuilder()
> On 08/05/2017 23:27, Andrew Guibert wrote:
> > :
> >
> > I am not sure why the "no resetting" restriction is on the
> > API in the first place.  Is anyone aware why the API has this
> > In any case, the solution outlined above seems rather messy (as it only
> > solves the problem by mitigating a classloader leak), so I would like
> > propose the following addition to the NamingManager API:
> >
> >
> I checked with one of the engineers that worked on the JNDI API a long
> time ago and there doesn't seem to be any significant reason to disallow
> it be changed.
> Looking at it now then it might be simpler to change
> setInitialContextFactoryBuilder to allow a new builder to be set rather
> than introducing a clearXXX method. I can't imagine anything but tests
> relying on IllegalStateException to be thrown if already set. A variant
> to explore is setting the builder to a placeholder InitialContextFactory
> rather than null.
> So is your plan to proposal a patch and tests for this?
> -Alan

More information about the core-libs-dev mailing list