You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Markus Jelsma <ma...@openindex.io> on 2018/04/24 11:13:47 UTC

ClassCastException: o.a.l.d.Field cannot be cast to o.a.l.d.StoredField

Hello,

We have a DocumentTransformer that gets a Field from the SolrDocument and casts it to StoredField (although aparently we don't need to cast). This works well in tests and fine in production, except for some curious, unknown and unreproducible, cases, throwing the ClassCastException.

I can, and will, just remove the cast to fix the rare exception, but in what cases could the exception get thrown?

Many thanks,
Markus

Re: ClassCastException: o.a.l.d.Field cannot be cast to o.a.l.d.StoredField

Posted by David Smiley <da...@gmail.com>.
I'm not sure but I wonder why you would want to cast it in the first
place.  Field is the base class; all it's subclasses are in one way or
another utilities/conveniences.  In other words, if you ever see code
casting Field to some subclass, there's a good chance it's fundamentally
wrong or making assumptions that aren't necessarily true.

If the problem you saw appears sporadic, there's a good chance it is in
some way related to updateLog replay.

On Tue, Apr 24, 2018 at 7:13 AM Markus Jelsma <ma...@openindex.io>
wrote:

> Hello,
>
> We have a DocumentTransformer that gets a Field from the SolrDocument and
> casts it to StoredField (although aparently we don't need to cast). This
> works well in tests and fine in production, except for some curious,
> unknown and unreproducible, cases, throwing the ClassCastException.
>
> I can, and will, just remove the cast to fix the rare exception, but in
> what cases could the exception get thrown?
>
> Many thanks,
> Markus
>
-- 
Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker
LinkedIn: http://linkedin.com/in/davidwsmiley | Book:
http://www.solrenterprisesearchserver.com