You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Christian Huegel <ch...@stonebyte.de> on 2005/10/11 13:14:52 UTC

Search with "index out of range"

Hi list,

as initiating the search function as described here:
http://www.solprovider.com/lenya/searchdownload i get some errors when searching
for particular words in an publication. For example: the first 3 random words ar
found and dispalyed correctly but then, on the next search criteria i get an:

String index out of range: -961

org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.apache.cocoon.ProcessingException: Exception in
ServerPagesGenerator.generate(): java.lang.StringIndexOutOfBoundsException:
String index out of range: -961

The search string definitly exists on the publication.
Has enybody else seen this behaviour?

Thx,


regards,

Christian


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with "index out of range"

Posted by so...@gmail.com.
On 10/12/05, Olivier Lustenberger <ol...@adm.unige.ch> wrote:
> Le mardi 11 octobre 2005 à 16:17 -0400, solprovider@gmail.com a écrit :
> > It seems to break on the substring().  Please try adding the bounds
> > checking code.  The resulting excerpt might be wrong, but hopefully it
> > will not error.  Let me know what happens.  I'll do a more thorough
> > analysis tomorrow.
> the bounds checking code seems to work fine for me, no more
> StringIndexOutOfBoundsException.

My testing showed the error happened when end == -1, meaning no space
was found at the end, so bounds checking is all that was needed.  The
files on solprovider.com have this fix.  The bugzilla is here:
http://issues.apache.org/bugzilla/show_bug.cgi?id=37048

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with "index out of range"

Posted by Olivier Lustenberger <ol...@adm.unige.ch>.
Le mardi 11 octobre 2005 à 16:17 -0400, solprovider@gmail.com a écrit :
> It seems to break on the substring().  Please try adding the bounds
> checking code.  The resulting excerpt might be wrong, but hopefully it
> will not error.  Let me know what happens.  I'll do a more thorough
> analysis tomorrow.

Hi,

the bounds checking code seems to work fine for me, no more
StringIndexOutOfBoundsException.

Thank you very much solprovider !

-- Olivier


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with

Posted by Christian Huegel <ch...@stonebyte.de>.
 <solprovider <at> gmail.com> writes:

> 
> Hi Christian,
> 
>
> 
> It seems to break on the substring().  Please try adding the bounds
> checking code.  The resulting excerpt might be wrong, but hopefully it
> will not error.  Let me know what happens.  I'll do a more thorough
> analysis tomorrow.
> 
> solprovider
> 


Works like a charm. Thank you so much...

Christian




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with "index out of range"

Posted by so...@gmail.com.
Hi Christian,

I think the problem is in this code.  All the comments and the bounds
checking code are new.  The file is
{pub}/lenya/content/search/search-and-results.xsp

//first = indexOf(earliest search term found) or -1 if not found.
//excerptOffset = search parameter, default 100.
//slfield = String (text of BODY)
//tmphtmlbody = same as tmphtmlbody with '~' before and after each search term.

                         if(slfield.length() &gt; excerptOffset){
                             int start = 0;
                             int end = excerptOffset;
                             int half = excerptOffset/2;
                             if(first &lt; half){
                                end = tmphtmlbody.indexOf(' ', excerptOffset);
                             }else{
                                start = tmphtmlbody.indexOf(' ', first - half);
                                end = tmphtmlbody.indexOf(' ', start +
excerptOffset);
                             }
//start should be 0 or first - half
//end should be the first space after either excerptOffset or start +
excerptOffset
//BEGIN: Add bounds checking:
                             int tmphtmlbodylength = tmphtmlbody.length();
                             if(start &gt; tmphtmlbodylength) start =
tmphtmlbodylength - excerptOffset;
                             if(start &lt; 0) start = 0;
                             if(end &lt; start) end = start + excerptOffset;
                             if(end &gt; tmphtmlbodylength) end =
tmphtmlbodylength;
//END: bounds checking
                             tmphtmlbody = tmphtmlbody.substring(start, end);
                          }

It seems to break on the substring().  Please try adding the bounds
checking code.  The resulting excerpt might be wrong, but hopefully it
will not error.  Let me know what happens.  I'll do a more thorough
analysis tomorrow.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with "index out of range"

Posted by Christian Huegel <ch...@stonebyte.de>.
 <solprovider <at> gmail.com> writes:

> Does this happen with the latest version of search-and-results.xsp
> from 2005-09-25?  Does it ever happen during the first search?  (If
> not, there is probably a variable that is not reset properly.)
> 
> solprovider
> 


Hi solprovider,

yes, the file was last modified on the 2005-09-25 and the first search was a
hit. I encountered the problem only after the third try and only specific words.

Here is an example: http://www.stonebyte.de/index_de.html and search for the
word "metus"


Have a good day,


Christian


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with "index out of range"

Posted by so...@gmail.com.
On 10/11/05, Olivier Lustenberger <ol...@adm.unige.ch> wrote:
> Le mardi 11 octobre 2005 à 11:14 +0000, Christian Huegel a écrit :
> > as initiating the search function as described here:
> > http://www.solprovider.com/lenya/searchdownload i get some errors when searching
> > for particular words in an publication. For example: the first 3 random words ar
> > found and dispalyed correctly but then, on the next search criteria i get an:
> > String index out of range: -961
> >
> > org.apache.cocoon.ProcessingException: Error executing pipeline.:
> > org.apache.cocoon.ProcessingException: Error executing pipeline.:
> > org.apache.cocoon.ProcessingException: Exception in
> > ServerPagesGenerator.generate(): java.lang.StringIndexOutOfBoundsException:
> > String index out of range: -961
> >
> > The search string definitly exists on the publication.
> > Has enybody else seen this behaviour?
>
> Same problem, only with some words (french/english content).
> org.apache.cocoon.ProcessingException: Error executing pipeline.:
> org.apache.cocoon.ProcessingException: Error executing pipeline.:
> org.apache.cocoon.ProcessingException: Exception in
> ServerPagesGenerator.generate():
> java.lang.StringIndexOutOfBoundsException:
> String index out of range: -209

It is either a bug in search-and-results.xsp, or a bug in the XSP
processor.  From the error, something is doing very poor math.  I
remember fixng a similar StringIndexOutOfBounds error, but I cannot
find it in my dev logs.  I fixed some obvious bugs when I first
revised search-and-results.xsp, but I was trying to keep the changes
minimal during development so I could provide easy instructions or a
diff.  Now everyone just downloads the whole file, so I can do more
extensive changes.  I'll do a full code review of
search-and-results.xsp later this week, and make certain every string
operation checks bounds.

Does this happen with the latest version of search-and-results.xsp
from 2005-09-25?  Does it ever happen during the first search?  (If
not, there is probably a variable that is not reset properly.)

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Search with "index out of range"

Posted by Olivier Lustenberger <ol...@adm.unige.ch>.
Le mardi 11 octobre 2005 à 11:14 +0000, Christian Huegel a écrit :
> Hi list,
> 
> as initiating the search function as described here:
> http://www.solprovider.com/lenya/searchdownload i get some errors when searching
> for particular words in an publication. For example: the first 3 random words ar
> found and dispalyed correctly but then, on the next search criteria i get an:
> 
> String index out of range: -961
> 
> org.apache.cocoon.ProcessingException: Error executing pipeline.:
> org.apache.cocoon.ProcessingException: Error executing pipeline.:
> org.apache.cocoon.ProcessingException: Exception in
> ServerPagesGenerator.generate(): java.lang.StringIndexOutOfBoundsException:
> String index out of range: -961
> 
> The search string definitly exists on the publication.
> Has enybody else seen this behaviour?

Same problem, only with some words (french/english content).

org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.apache.cocoon.ProcessingException: Error executing pipeline.:
org.apache.cocoon.ProcessingException: Exception in
ServerPagesGenerator.generate():
java.lang.StringIndexOutOfBoundsException:
String index out of range: -209

-- Olivier


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org