On Wed, Dec 17, 2025 at 4:38 PM Mark Thomas <[email protected]> wrote:
>
> On 17/12/2025 15:14, Christopher Schultz wrote:
> > All,
> >
> > I had occasion to write some code to traverse the JNDI tree for JDBC
> > resources and list them. My code looks something like this:
> >
> > InitialContext ictx = null;
> > Context ctx = null;
> >
> > try {
> >    ictx = new InitialContext();
> >
> >    ctx = ictx.lookup("java:comp/env/jdbc");
> >
> >    ...
> > } finally {
> >      if(null != ctx) try { ctx.close(); } catch () ...
> >      if(null != ictx) try { ictx.close(); } catch () ...
> > }
> >
> > This code is throwing an exception:
> >
> > javax.naming.OperationNotSupportedException: Context is read only
> >      at
> > org.apache.naming.NamingContext.checkWritable(NamingContext.java:637)
> >      at org.apache.naming.NamingContext.close(NamingContext.java:430)
> >          at [... my code ...]
> >
> > Examples online from Sun/Oracle seem to indicate that calling
> > Context.close() when code is finished with a Context resource is
> > appropriate.
> >
> > Should this method be throwing an exception?
>
> It looks like the call to checkWritable() is unnecessary in close().

You said that about it before:
https://bz.apache.org/bugzilla/show_bug.cgi?id=51744#c1

Rémy

> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to