lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Dillard (JIRA)" <j...@apache.org>
Subject [jira] Created: (LUCENE-1247) Unnecessary assert in org.apache.lucene.index.DocumentsWriterThreadState.trimFields()
Date Thu, 27 Mar 2008 19:31:24 GMT
Unnecessary assert in org.apache.lucene.index.DocumentsWriterThreadState.trimFields()
-------------------------------------------------------------------------------------

                 Key: LUCENE-1247
                 URL: https://issues.apache.org/jira/browse/LUCENE-1247
             Project: Lucene - Java
          Issue Type: Improvement
          Components: Index
    Affects Versions: 2.3.1, 2.3.2
            Reporter: David Dillard


In org.apache.lucene.index.DocumentsWriterThreadState.trimFields() is the following code:

      if (fp.lastGen == -1) {
        // This field was not seen since the previous
        // flush, so, free up its resources now

        // Unhash
        final int hashPos = fp.fieldInfo.name.hashCode() & fieldDataHashMask;
        DocumentsWriterFieldData last = null;
        DocumentsWriterFieldData fp0 = fieldDataHash[hashPos];
        while(fp0 != fp) {
          last = fp0;
          fp0 = fp0.next;
        }
        assert fp0 != null;

The assert at the end is not necessary as fp0 cannot be null.  The first line in the above
code guarantees that fp is not null by the time the while loop is hit.  The while loop is
exited when fp0 and fp are equal.  Since fp is not null then fp0 cannot be null when the while
loop is exited, thus the assert is guaranteed to never occur.

This was detected by FindBugs.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message