lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Muir <>
Subject Re: PayloadAttribute behavior change between Lucene 2.9/3.0 and the trunk
Date Sat, 04 Dec 2010 03:30:29 GMT
On Fri, Dec 3, 2010 at 10:15 PM, Teruhiko Kurosaka <> wrote:
> Hello,
> I have a Tokenizer that generates a Payload, and a TokenFilter that uses it.
> These work well with Solr 1.4.0 (therefore Lucene 2.9.1?), but when
> I switched to the trunk version (I rebuilt the Tokenizer and TokenFilter
> using the Lucene jar from the trunk and ran it), I encountered with
> this error:
> java.lang.IllegalArgumentException: This AttributeSource does not have the attribute
> This exception comes from this line in the TokenFilter code:
>        payloadAtt = (PayloadAttribute) getAttribute(PayloadAttribute.class);

I recommend you use addAttribute instead. Its buggy to use
getAttribute in this way because you cannot rely upon the fact that a
previous tokenstream has added the attribute[1]. I think your code was
only working before because of TokenWrapperAttributeFactory (the
backwards compatibility layer in 2.9 for the old Token API) being


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

View raw message