In general, the assertion documentation at Sun says it: "As a rule, the expressions contained in assertions should be free of side effects: evaluating the expression should not affect any state that is visible after the evaluation is complete. One exception to this rule is that assertions can modify state that is used only from within other assertions. <http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html#complexpostcondi tions> An idiom that makes use of this exception is presented later in this document."
http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html#usage But you are right, any programmer will do this error only once J Uwe ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen <http://www.thetaphi.de/> http://www.thetaphi.de eMail: [email protected] From: Shai Erera [mailto:[email protected]] Sent: Saturday, June 12, 2010 1:12 PM To: [email protected] Subject: Re: svn commit: r953986 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java Yes .. we should just make it a code practice - never assert on is.read() / os.write() :). I hope this is the sort of bugs that you get to introduce only once :). Shai On Sat, Jun 12, 2010 at 2:03 PM, Uwe Schindler <[email protected]> wrote: This is hard to find! It only fails with disabled assertions, so the lucene test suite always passes - ugly :( Thanks! ----- Uwe Schindler H.-H.-Meier-Allee 63, D-28213 Bremen http://www.thetaphi.de eMail: [email protected] > -----Original Message----- > From: [email protected] [mailto:[email protected]] > Sent: Saturday, June 12, 2010 12:48 PM > To: [email protected] > Subject: svn commit: r953986 - > /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo. > java > > Author: shaie > Date: Sat Jun 12 10:47:35 2010 > New Revision: 953986 > > URL: http://svn.apache.org/viewvc?rev=953986 <http://svn.apache.org/viewvc?rev=953986&view=rev> &view=rev > Log: > LUCENE-2497: fix a bug that was introduced in LUCENE-2480 > > Modified: > > lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.j > ava > > Modified: > lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.j > ava > URL: > http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apach > e/lucene/index/SegmentInfo.java?rev=953986&r1=953985&r2=953986&view > =diff > ========================================================== > ==================== > --- > lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.j > ava (original) > +++ > lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.j > ava Sat Jun 12 10:47:35 2010 > @@ -154,7 +154,8 @@ public final class SegmentInfo { > } > if (format > SegmentInfos.FORMAT_4_0) { > // pre-4.0 indexes write a byte if there is a single norms file > - assert 1 == input.readByte(); > + byte b = input.readByte(); > + assert 1 == b; > } > int numNormGen = input.readInt(); > if (numNormGen == NO) { > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
