directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Seelmann <>
Subject Should we use Java assert?
Date Sun, 09 Oct 2011 16:16:07 GMT
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.


Kind Regards,

View raw message