Return-Path: X-Original-To: apmail-lucene-dev-archive@www.apache.org Delivered-To: apmail-lucene-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A4D89780 for ; Mon, 17 Oct 2011 12:24:33 +0000 (UTC) Received: (qmail 4185 invoked by uid 500); 17 Oct 2011 12:24:32 -0000 Delivered-To: apmail-lucene-dev-archive@lucene.apache.org Received: (qmail 3956 invoked by uid 500); 17 Oct 2011 12:24:32 -0000 Mailing-List: contact dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list dev@lucene.apache.org Received: (qmail 3947 invoked by uid 99); 17 Oct 2011 12:24:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2011 12:24:31 +0000 X-ASF-Spam-Status: No, hits=-2000.5 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2011 12:24:30 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id B925E30214B for ; Mon, 17 Oct 2011 12:24:10 +0000 (UTC) Date: Mon, 17 Oct 2011 12:24:10 +0000 (UTC) From: "Shai Erera (Commented) (JIRA)" To: dev@lucene.apache.org Message-ID: <1565596479.138.1318854250759.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1269218970.19609.1318827492527.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (LUCENE-3522) TermsFilter.getDocIdSet(context) NPE on missing field MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LUCENE-3522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13128812#comment-13128812 ] Shai Erera commented on LUCENE-3522: ------------------------------------ Good catch Dan! Patch looks good, but I have some comments about the test: # You don't close the directories at the end of it, and the test fails due that. # I think it can be simplified to create just one Directory, with "f1:content" and request "f2:content". I actually tried it and the test still fails (NPE reproduced without your fix). Here is the modified, more compact, test: {code} public void testMissingField() throws Exception { // LUCENE-3522: if requested field does not exist in the index, TermsFilter threw NPE. Directory dir = newDirectory(); RandomIndexWriter writer = new RandomIndexWriter(random, dir); Document doc = new Document(); doc.add(newField("f1", "content", StringField.TYPE_STORED)); writer.addDocument(doc); IndexReader reader = writer.getReader(); writer.close(); TermsFilter tf = new TermsFilter(); tf.addTerm(new Term("f2", "content")); FixedBitSet bits = (FixedBitSet) tf.getDocIdSet(reader.getTopReaderContext().leaves()[0]); assertTrue("Must be >= 0", bits.cardinality() >= 0); reader.close(); dir.close(); } {code} Would you mind changing the test case to this compact one? Or did you want to demonstrate something else with the two readers? > TermsFilter.getDocIdSet(context) NPE on missing field > ----------------------------------------------------- > > Key: LUCENE-3522 > URL: https://issues.apache.org/jira/browse/LUCENE-3522 > Project: Lucene - Java > Issue Type: Bug > Components: modules/other > Affects Versions: 4.0 > Reporter: Dan Climan > Assignee: Michael McCandless > Priority: Minor > Attachments: LUCENE-3522.patch > > > If the context does not contain the field for a term when calling TermsFilter.getDocIdSet(AtomicReaderContext context) then a NullPointerException is thrown due to not checking for null Terms before getting iterator. -- 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