You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2010/06/12 12:47:35 UTC

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&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.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=953986&r1=953985&r2=953986&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java 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) {



RE: svn commit: r953986 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java

Posted by Uwe Schindler <uw...@thetaphi.de>.
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: uwe@thetaphi.de

 

From: Shai Erera [mailto:serera@gmail.com] 
Sent: Saturday, June 12, 2010 1:12 PM
To: dev@lucene.apache.org
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 <uw...@thetaphi.de> 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: uwe@thetaphi.de


> -----Original Message-----
> From: shaie@apache.org [mailto:shaie@apache.org]
> Sent: Saturday, June 12, 2010 12:48 PM
> To: commits@lucene.apache.org
> 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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org

 


Re: svn commit: r953986 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java

Posted by Shai Erera <se...@gmail.com>.
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 <uw...@thetaphi.de> 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: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: shaie@apache.org [mailto:shaie@apache.org]
> > Sent: Saturday, June 12, 2010 12:48 PM
> > To: commits@lucene.apache.org
> > 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&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: dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: dev-help@lucene.apache.org
>
>

RE: svn commit: r953986 - /lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/SegmentInfo.java

Posted by Uwe Schindler <uw...@thetaphi.de>.
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: uwe@thetaphi.de

> -----Original Message-----
> From: shaie@apache.org [mailto:shaie@apache.org]
> Sent: Saturday, June 12, 2010 12:48 PM
> To: commits@lucene.apache.org
> 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&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: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org