[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] Patch: replace NullPointerException with ClassCastExcep
From: |
Mark Wielaard |
Subject: |
Re: [cp-patches] Patch: replace NullPointerException with ClassCastException |
Date: |
Sun, 18 Sep 2005 12:13:44 +0200 |
On Sat, 2005-09-17 at 18:25 -0700, Anthony Green wrote:
> On Sun, 2005-09-18 at 00:51 +0200, Mark Wielaard wrote:
> > On Wed, 2005-09-14 at 17:56 -0700, Anthony Green wrote:
> > > This doesn't really fix a bug. FindBugs was complaining about a
> > > potential null dereference. This patch essentially turns a potential
> > > NullPointerException into a ClassCastException, which is no worse - and
> > > quiets FindBugs on this issue.
> >
> > Both are wrong. If result is null (both conditions fail) the method
> > should throw a NoSuchAlgorithmException.
>
> The way I read it is if both conditions fail then our library is busted
> and we should throw a runtime exception, and not the expected
> NoSuchAlgorithmException. That would just mask a problem.
Our library or the given Provider. I would still throw the
NoSuchAlgorithmException either with a chained exception cause or an
appropriate message. But I don't feel too strongly about it. The
NullPointerException was the worst thing we could throw since that
doesn't really give the user any information what went wrong. So fixing
that is a good thing whatever way it is solved.
Cheers,
Mark
signature.asc
Description: This is a digitally signed message part