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

Tim Smith commented on LUCENE-1825:
-----------------------------------

Updated getAttribute() on AttributeSource as follows to find the source of my 
pain:
{code}
  /**
   * The caller must pass in a Class<? extends Attribute> value. 
   * Returns the instance of the passed in Attribute contained in this 
AttributeSource
   * 
   * @throws IllegalArgumentException if this AttributeSource does not contain 
the
   *         Attribute
   */
  public AttributeImpl getAttribute(Class attClass) {
    AttributeImpl att = (AttributeImpl) this.attributes.get(attClass);
    if (att == null) {
      throw new IllegalArgumentException(getClass().getName() + " does not have 
the attribute '" + attClass + "'.");
    }

    return att;
  }
{code}

I see that this could end up being an arbitrary 
"org.apache.lucene.util.AttributeSource" though if you aren't fully integrating 
the new api


> AttributeSource.getAttribute() should throw better IllegalArgumentException
> ---------------------------------------------------------------------------
>
>                 Key: LUCENE-1825
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1825
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: Analysis
>    Affects Versions: 2.9
>            Reporter: Tim Smith
>            Priority: Minor
>
> 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(AttributeSource.java:249)
>     [junit]   at 
> org.apache.lucene.index.TermsHashPerField.start(TermsHashPerField.java:252)
>     [junit]   at 
> org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:145)
>     [junit]   at 
> org.apache.lucene.index.DocFieldProcessorPerThread.processDocument(DocFieldProcessorPerThread.java:244)
>     [junit]   at 
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:772)
>     [junit]   at 
> org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:755)
>     [junit]   at 
> org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:2613)
> {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: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to