lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <>
Subject Re: DocSlide.DocIterator.nextDoc()
Date Sat, 28 Aug 2010 00:46:13 GMT
2010/8/27 Gérard Dupont <>:
> 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$1.nextDoc(
> at
> org.apache.solr.highlight.DefaultSolrHighlighter.doHighlighting(
> at
> org.apache.solr.handler.component.HighlightComponent.process(
> at
> org.apache.solr.handler.component.SearchHandler.handleRequestBody(
> at
> org.apache.solr.handler.RequestHandlerBase.handleRequest(
> at org.apache.solr.core.SolrCore.execute(
> at
> org.apache.solr.client.solrj.embedded.EmbeddedSolrServer.request(
> ... 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

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.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message