You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Alan Woodward (Created) (JIRA)" <ji...@apache.org> on 2012/02/28 12:31:48 UTC

[jira] [Created] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
--------------------------------------------------------------------------

                 Key: LUCENE-3831
                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
             Project: Lucene - Java
          Issue Type: Bug
          Components: core/index
    Affects Versions: 4.0
            Reporter: Alan Woodward
            Priority: Minor


I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Updated] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Posted by "Michael McCandless (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless updated LUCENE-3831:
---------------------------------------

    Attachment: LUCENE-3831.patch

Thanks for the test cases Alan!

I folded those into a patch, added a few {{assert field != null}},
and then fixed SpanWeight to detect when its .getField() is
null and return a null scorer in that case.

I'd like to avoid the API break (changing Span*Query API to force
up-front providing of the field) if we can...

                
> Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-3831
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.0
>            Reporter: Alan Woodward
>            Assignee: Michael McCandless
>            Priority: Minor
>         Attachments: LUCENE-3831.patch, TestNullFieldAfterRegexpRewrite.java, mindex-null-field.patch
>
>
> I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Updated] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Posted by "Alan Woodward (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alan Woodward updated LUCENE-3831:
----------------------------------

    Attachment: TestNullFieldAfterRegexpRewrite.java

Here's a test case.  The error is thrown in SpanQuery.createWeight() when it's called on a bare SpanMultiTermQueryWrapper.

It looks as though a simple workaround is to always wrap SpanMultiTermQueryWrapper in a SpanOrQuery.  

Maybe SpanOrQuery should not have a default constructor, but should require a fieldname if no clauses are supplied?
                
> Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-3831
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.0
>            Reporter: Alan Woodward
>            Assignee: Michael McCandless
>            Priority: Minor
>         Attachments: TestNullFieldAfterRegexpRewrite.java, mindex-null-field.patch
>
>
> I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Resolved] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Posted by "Michael McCandless (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless resolved LUCENE-3831.
----------------------------------------

       Resolution: Fixed
    Fix Version/s: 4.0
                   3.6

Thanks Alan.

I couldn't provoke an NPE on 3.x but I still fixed SpanWeight to not pass on a null field to IR.norms.
                
> Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-3831
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.0
>            Reporter: Alan Woodward
>            Assignee: Michael McCandless
>            Priority: Minor
>             Fix For: 3.6, 4.0
>
>         Attachments: LUCENE-3831.patch, TestNullFieldAfterRegexpRewrite.java, mindex-null-field.patch
>
>
> I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Assigned] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Posted by "Michael McCandless (Assigned) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael McCandless reassigned LUCENE-3831:
------------------------------------------

    Assignee: Michael McCandless
    
> Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-3831
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.0
>            Reporter: Alan Woodward
>            Assignee: Michael McCandless
>            Priority: Minor
>         Attachments: mindex-null-field.patch
>
>
> I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Updated] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Posted by "Alan Woodward (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LUCENE-3831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alan Woodward updated LUCENE-3831:
----------------------------------

    Attachment: mindex-null-field.patch

Trivial fix - we just check if the passed in fieldname is null, and if it is, return null.
                
> Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-3831
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.0
>            Reporter: Alan Woodward
>            Priority: Minor
>         Attachments: mindex-null-field.patch
>
>
> I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] [Commented] (LUCENE-3831) Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE

Posted by "Michael McCandless (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LUCENE-3831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13218171#comment-13218171 ] 

Michael McCandless commented on LUCENE-3831:
--------------------------------------------

Hmm I don't think the Fields.terms API should be expected to accept null (eg I don't know if the other codecs will NPE).

I'd rather fix span queries to not pass the null field.  Is this happening in SpanTermQuery.getSpans()?
                
> Passing a null fieldname to MemoryFields#terms in MemoryIndex throws a NPE
> --------------------------------------------------------------------------
>
>                 Key: LUCENE-3831
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3831
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 4.0
>            Reporter: Alan Woodward
>            Assignee: Michael McCandless
>            Priority: Minor
>         Attachments: mindex-null-field.patch
>
>
> I found this when querying a MemoryIndex using a RegexpQuery wrapped by a SpanMultiTermQueryWrapper.  If the regexp doesn't match anything in the index, it gets rewritten to an empty SpanOrQuery with a null field value, which then triggers the NPE.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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