[jira] Created: (LUCENE-1247) Unnecessary assert in org.apache.lucene.index.DocumentsWriterThreadState.trimFields()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (LUCENE-1247) Unnecessary assert in org.apache.lucene.index.DocumentsWriterThreadState.trimFields()

JIRA jira@apache.org
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (LUCENE-1247) Unnecessary assert in org.apache.lucene.index.DocumentsWriterThreadState.trimFields()

JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/LUCENE-1247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Dillard updated LUCENE-1247:
----------------------------------

    Priority: Trivial  (was: Major)

> 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
>            Priority: Trivial
>
> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[jira] Resolved: (LUCENE-1247) Unnecessary assert in org.apache.lucene.index.DocumentsWriterThreadState.trimFields()

JIRA jira@apache.org
In reply to this post by JIRA jira@apache.org

     [ https://issues.apache.org/jira/browse/LUCENE-1247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-1247.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.4

Thanks David, I just removed this.

> 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
>            Priority: Trivial
>             Fix For: 2.4
>
>
> 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: [hidden email]
For additional commands, e-mail: [hidden email]