org.nuxeo.ecm.core.versioning.DefaultVersionRemovalPolicy triggers an event "orphan_versions_to_remove" (async, postCommit=true).
It instanciates an event context and put a document and some versions inside.
The document is explicitely wrapped in a ShallowDocumentModel.
=> Shoud be removed. ShallowDocumentModel has too many custom technical behaviour to be used in business code (put a doc ref in the context for example).
Then, the event is send to the cluster.
The events bundle find a ShallowDocumentModel in the context. When it's unmarshalled to be relayed to the event listener, it's unmarshalled as a ShallowDocumentModel if it exists and as a DocumentModelImpl if not.
The "invalidation" does not occur fast enough. The event listener which expects a ShallowDocumentModel (to remove as well) throws a ClassCastException.
So, there's 2 fixes to apply:
- Do not use ShallowDocumentModel in business code.
- fix the doc removal invalidation.