Skip to content

DefaultTransactionalRepository find throws exception if EntityDecorator constructor used #1032

@dmccabe

Description

@dmccabe

DefaultTransactionalRepository has two constructors, one that takes a Class<T> and one that takes an EntityDecorator. When the EntityDecorator constructor is used, the type value is initialized to null by default.

However, in the find method of the repository, the type value is passed into operations.find:

@Override
public Cursor<T> find(Filter filter, FindOptions findOptions) {
    return operations.find(filter, findOptions, type);
}

This will eventually work its way down to NitriteMapper, which causes an NPE to be thrown in the Nitrite mapper. I was seeing it happen in SimpleNitriteMapper on Document.class.isAssignableFrom(type), but it would presumably affect the other mappers as well.

I believe the appropriate fix here is to update DefaultTransactionalRepository.find to see if it has a non-null entityDecorator and fetch the type from there if it's present.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions