directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@apache.org>
Subject Re: Should we use Java assert?
Date Sun, 09 Oct 2011 17:03:10 GMT
I agree with Stefan : Asserts where good back when we were coding in C, but
in Java, there are too many drawbacks.

Let's not use them at all.

Thanks Stefan !

On Sun, Oct 9, 2011 at 6:30 PM, Selcuk AYA <ayaselcuk@gmail.com> wrote:

>  On Sun, Oct 9, 2011 at 7:16 PM, Stefan Seelmann <seelmann@apache.org>
> wrote:
> > Hi guys,
> >
> > I just had a strange behaviour that the TestSnapshotBTree worked when
> > I started it with "mvn test" but not when started from within Eclipse.
> > I found out that in the test a Java "assert" is used but Java
> > assertions are used. Java assertions are disabled by default (the must
> > be enabled with -ea) but the maven surefire plugin enables them by
> > default so it worked with "mvn test". I just fixed it by using JUnit
> > assertTrue instead, not a big problem.
> >
> > But I also discovered that Java assertions are used within the JDBM
> > productive code. I'm not sure if it was always used or if it was
> > introduced during the recent refactorings. But I think we should not
> > use Java assert at all. They should not be used as guards to check
> > arguments or state because if disabled they don't fire an exception.
> > They are just not reliable. I think its better to throw something like
> > an IllegalArgumentException or IllegalStateException in such cases.
> >
> I had introduced the asserts with the jdbm refactoring changes
> thinking they are always enabled. I will change them to throw
> illegalstate exceptions as you suggested.
>
>
> > Thoughts?
> >
> > Kind Regards,
> > Stefan
> >
>
> regards,
> Selcuk
>



-- 
Regards,
Cordialement,
Emmanuel L├ęcharny
www.iktek.com

Mime
View raw message