lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <yo...@lucidimagination.com>
Subject Re: DocSlide.DocIterator.nextDoc()
Date Sat, 28 Aug 2010 00:46:13 GMT
2010/8/27 Gérard Dupont <ger.dupont@gmail.com>:
> Hi all,
> I recently came across a strange exception while using SolR. In fact I have
> an ArrayOutOfBoundsException while using the server and making "normal"
> query (I mean not different from before). The trace is he following :
> Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
> at org.apache.solr.search.DocSlice$1.nextDoc(DocSlice.java:117)
> at
> org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(DefaultSolrHighlighter.java:273)
> at
> org.apache.solr.handler.component.HighlightComponent.process(HighlightComponent.java:89)
> at
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:195)
> at
> org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:131)
> at org.apache.solr.core.SolrCore.execute(SolrCore.java:1316)
> at
> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(EmbeddedSolrServer.java:139)
> ... 37 more
> It seems to be linked to the highlighting module but as I had a look on the
> code I think I could understand why it fails :
>       public int nextDoc() {
>         return docs[pos++];
>       }
> So my basic reading tells me that one may eventually come in a case where
> the system will do one too much "++" ;-) . Iguess one should prevent this
> call checking the "hasNext()" but it not done everywhere apparently so I
> suggest just to implement it in the nextDoc() it self...
> What do you think ? Any one faced this problem yet ?

nextDoc() may be called millions of times for a single request (during
faceting), so we shouldn't add extra logic to it.  And even if we
could... what would we do?  If we return a bogus number, that just
pushes the error somewhere else.  We should fix the root cause of the
problem.

What version if Solr are you using?
A quick look at trunk tells me there is only one call to nextDoc() in
DefaultSolrHighlighter, and it looks fine:

    DocIterator iterator = docs.iterator();
    for (int i = 0; i < docs.size(); i++) {
      int docId = iterator.nextDoc();

It doesn't check hasNext(), but it does check the size, so it should be fine.

-Yonik
http://www.lucidimagination.com

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


Mime
View raw message