lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <>
Subject [jira] Assigned: (LUCENE-1825) AttributeSource.getAttribute() should throw better IllegalArgumentException
Date Thu, 20 Aug 2009 20:42:15 GMT


Uwe Schindler reassigned LUCENE-1825:

    Assignee: Uwe Schindler

In principle you should always use addAttribute() when consuming a TokenStream, if the attribute
is unknown, it will be created empty - no problem. MostLucene-internal code uses it in that
way. getAttribute() is currently only used for very special cases (e.g. in tests, to check
if an attribute was really added). But there seems to be one relict of getAttribute in the
code. To fix this bug, I should replace the getAttribute() call in the indexer by addAttribute().
I will provide a patch for that.

If you have an unknown TokenStream instance you will never know, which of the attributes are
really used. If you want to optimize this, you could check before, if the attribute is really
used and e.g. exclude some code paths with very complicated calculations based on these missing

I will also add an JavaDoc comment for this. The "more helpful" error message is in my opinion
not needed, because you cannot find out which of the filter/stream in the chain is missing
the attribute, because all in the chain use the same Attribute instances.

> AttributeSource.getAttribute() should throw better IllegalArgumentException
> ---------------------------------------------------------------------------
>                 Key: LUCENE-1825
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Analysis
>    Affects Versions: 2.9
>            Reporter: Tim Smith
>            Assignee: Uwe Schindler
>            Priority: Minor
>             Fix For: 2.9
> when seting "use only new API" for TokenStream, i received the following exception:
> {code}
>    [junit] Caused by: java.lang.IllegalArgumentException: This AttributeSource does not
have the attribute 'interface org.apache.lucene.analysis.tokenattributes.TermAttribute'.
>     [junit] 	at org.apache.lucene.util.AttributeSource.getAttribute(
>     [junit] 	at org.apache.lucene.index.TermsHashPerField.start(
>     [junit] 	at org.apache.lucene.index.DocInverterPerField.processFields(
>     [junit] 	at org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(
>     [junit] 	at org.apache.lucene.index.DocumentsWriter.updateDocument(
>     [junit] 	at org.apache.lucene.index.DocumentsWriter.updateDocument(
>     [junit] 	at org.apache.lucene.index.IndexWriter.updateDocument(
> {code}
> However, i can't actually see the culprit that caused this exception
> suggest that the IllegalArgumentException include "getClass().getName()" in order to
be able to identify which TokenStream implementation actually caused this

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

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

View raw message