users@glassfish.java.net

[gf-users] [3.1.2.2] NameNotFound exception is wrapped

From: Pawel Veselov <pawel.veselov_at_gmail.com>
Date: Thu, 22 May 2014 10:35:17 -0700

Hi.

When looking things up in JNDI, GlassFish replaces any terminal instance of
NamingException with the NamingException instance (though it does chain).

Is there any particular reason to do that?

I'm looking at SerialContext.java:518, and it looks like it's done for
convenience. Any namingException is caught, and then wrapped into an
instance of NamingException, but with an altered message. IMHO, the
original naming exception could've been simply re-thrown.

I know that to alter/update a message of an exception is not something Java
deals with well, but changing the exception in that case makes it
troublesome for the application to deal with its own exception handling, in
such cases when it, say, catches NameNotFoundException, to filter out cases
when a looked up name is simply not found...

Thank you,
  Pawel.