Replace NameNotFoundException etc with 'unchecked' exceptions

Project:JNode Core
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

The JNode InitialNaming and Namespace APIs use subtypes of javax.naming.NamingException to indicate problems; e.g. name not found, name already bound and so on. While reuse of standard exceptions is generally a good idea, exceptions from the InitialNaming API are rare, and would be an indication that something is seriously broken in the JNode runtime. Therefore, I think we should change (at least) the InitialNaming API to use unchecked exceptions.

If you think this proposed change is a good (or bad) idea, add a comment.

#1

Assigned to:Anonymous» Stephen Crawley

I guess nobody thinks this is a bad idea. I'll implement it later this week.

#2

I think the checked exception is OK in this case and there is no need to change it.
In a modular system like JNode there can be situations when there is no guaranty that a component or service will be available at runtime or that it was not already registered. Therefor enforcing the developer to handle this case in some way will make JNode as a whole a more robust system. With unchecked exceptions such failures will have unpredictable consequences.

#3

Assigned to:Stephen Crawley» Anonymous
Status:active» won't fix

Hmmm ... you've convinced me.

The argument that using a checked exception will improve robustness is highly optimistic in this case. If a 'bind' or 'lookup' fails for InitialNaming, the service / command that made the call is doomed. It is simply not possible for a service or application to recover from this kind of failure.

However, the checked exception encourages the developer to wrap the NamingException in some other exception (e.g. PluginException, IOException, RuntimeException !?!) that could be handled further up the stack. With a bit of luck, the stacktrace for wrapped exception will get logged or written to the console. So I suppose that is a plus for using a checked exception.