[ 
https://issues.apache.org/jira/browse/LUCENE-4910?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13625022#comment-13625022
 ] 

Simon Willnauer commented on LUCENE-4910:
-----------------------------------------

Shuji, what uwe says is that this might have worked in Lucene 4.0 but given the 
contract this API has the behaviour undefined unless you call 
TokenStream#reset() before you consume it. The NullPointerException is a result 
of this undefined behaviour due to the missing reset call and should be fixed 
by simply calling reset(). 

happy searching.

simon
                
> JapaneseTokenizer NullPointerException
> --------------------------------------
>
>                 Key: LUCENE-4910
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4910
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: modules/analysis
>    Affects Versions: 4.2
>            Reporter: Shuji Umino
>
> I use lucene 4.2.1 upgrade from 4.0.
> RollingCharBuffer required Reader, 
> buffer.init(null) called in JapaneseTokenizer custructor.
> > Test code
> ----------------------------------------------------------------------
> public static void main(String[] args) throws Exception {
>       String text = "test abc";
>       JapaneseTokenizer tokenizer = new JapaneseTokenizer(
>                       new StringReader(text), null, false, Mode.NORMAL);
>       //tokenizer.reset();
>       
>       while (tokenizer.incrementToken()) {
>               CharTermAttribute termAtt = 
> tokenizer.getAttribute(CharTermAttribute.class);
>               System.out.println(termAtt);
>       }
> }
> > Exception
> ----------------------------------------------------------------------
> Exception in thread "main" java.lang.NullPointerException
>       at 
> org.apache.lucene.analysis.util.RollingCharBuffer.get(RollingCharBuffer.java:86)
>       at 
> org.apache.lucene.analysis.ja.JapaneseTokenizer.parse(JapaneseTokenizer.java:602)
>       at 
> org.apache.lucene.analysis.ja.JapaneseTokenizer.incrementToken(JapaneseTokenizer.java:452)
> ----------------------------------------------------------------------

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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

Reply via email to