Re: svn commit: r559282 - /xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/IndexManager.java

"Natalia Shilenkova" <[email protected]>
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
On 7/26/07, Vadim Gritsenko <[email protected]> wrote:
> [email protected] wrote:
> >          public void characters(char ch[], int start, int length) {
> > -            String val = new String(ch).trim();
> ...
> > +            String val = new String(ch);
> >              info.sb.append(val);
>
> Now, after I had a look at this piece, I realized that it was wrong then and it
> is still wrong now :)

Damn :)

> String must be constructed only from the relevant part of the character buffer:
>
>      String val = new String(ch, start, length);
>
> Otherwise it can contain junk / extra data. It is a pure coincidence that it
> worked at all. :)
>
> Even better would be to forgo string construction completely and use append method:
>
>      info.sb.append(ch, start, length);
>
> This would save one extra characters copying.

Thanks for spotting the problem.

Natalia
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.