lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 20196] New: - NPE when using searcher, 1.3RC1
Date Fri, 23 May 2003 18:32:46 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20196>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20196

NPE when using searcher, 1.3RC1

           Summary: NPE when using searcher, 1.3RC1
           Product: Lucene
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Search
        AssignedTo: lucene-dev@jakarta.apache.org
        ReportedBy: doug@dougandalli.com


Using an IndexSearcher as below results in an NPE at line 90 of Hits.java called from 
line 80 of Hits.java called from line 71 of Searcher.java. Downgrading to v1.2 fixes the 
bug.

The error occurred on Win2000 running JRE 1.3.0-C + Tomcat 4.1.18, but does not occur 
in JRE 1.4.1_02-b06 + Tomcat 4.1.24.


    public Collection search(String query, String[] fields, int[] flags, Filter filter, Class

targetClass) throws Exception
    {
        if (fields == null) {
            fields = new String[1];
            fields[0] = getDefaultSearchField();
        }

        Log log = LogFactory.getLog(SearchEngine.class);
        log.debug("Query is '" + query + "'; target Class=" + targetClass.getName());

        Query luceneQuery = QueryParser.parse(query, "", new StandardAnalyzer());
        Searcher searcher = null;

        try {
            searcher = new IndexSearcher(getIndexPath());
            Hits hits = (filter == null? searcher.search(luceneQuery) : 
searcher.search(luceneQuery, filter));

            log.debug("Query hits: " + hits.length());

            ArrayList results = new ArrayList();
            HashMap props = new HashMap();
            for (int i = 0; i < hits.length(); i++) {
                Object bean = createObject(hits.doc(i), targetClass);
                if (bean != null) {
                    results.add(bean);
                }
            }

            return (results.isEmpty()? null : results);
        }
        finally {
            if (searcher != null) {
                searcher.close();
            }
        }
    }

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


Mime
View raw message