[jax-rs-spec users] [jsr339-experts] Re: Re: Replacing IllegalStateException in UriBuilder API with NPE?

From: Sergey Beryozkin <>
Date: Fri, 15 Jun 2012 12:21:19 +0100

On 15/06/12 11:55, Marek Potociar wrote:
> On Jun 11, 2012, at 12:31 PM, Sergey Beryozkin wrote:
>> Hi
>> On 05/06/12 16:59, Bill Burke wrote:
>>> Isn't there TCK tests that test that ISE is thrown when null is passed in?
>> In some cases 'null' is valid (resetting some of the previous state), so it would be good to get some further clarifications on the issue
>> NPE is associated with a code bug to me, I often see people saying NPE is always a bug in the code, so I wonder if such a replacement is really necessary
> The point is that in this case the NPE really indicates a code bug. In fact, the exception thrown now (and declared in API) is IllegalArgumentException (sorry for the confusion) and it' s only purpose is to indicate a code bug too. It's just that by convention, NPE should be used for the null pointer related issues.
OK, agreed about the convention.

However I can see a lot of tests in our code, some of them derived from
TCK based tests, where IllegalArgumentException is checked.
Replacing it with NPE would not be a big issue I guess, though I find
IllegalArgumentException being good enough in this case (null is not a
legal argument in this case - but can be a legal one in cases like
uriBuilder.replacePath(null)) though it's not as precise as NPE in cases
when null is passed but only initialized values are expected.

Cheers, Sergey

> Marek
>> Cheers, Sergey
>>> On 6/5/12 11:05 AM, Marek Potociar wrote:
>>>> Hello Experts,
>>>> please provide your feedback:
>>>> Thanks,
>>>> Marek

Sergey Beryozkin
Talend Community Coders