Skip to content

NullPointerException when trying to parse parseUnboundedValueObject of a Map<String, Object> #1099

@xytrams

Description

@xytrams

Clear description of my expectations versus reality
I am using Javers with SpringBoot and Mongo DB. The object I'm saving in the Mongo DB is not of a flat structure. In fact it is quite complex:
public class A { private final B b; private final C c; private final Map<String, List<E>> map; }
My repository class looks like this:
`
@JaversSpringDataAuditable
public interface ARepository extends MongoRepository<A, String>{

@Query(value = "{'b.id' : ?0 }")
public Optional<A> findById(String id);

}

`
I have simple service where I'd like to retrieve some info about object: who created/when etc

`
@service
@requiredargsconstructor
public class AService {
private final Javers javers;

public String getInitSnapshot(String id) {
	QueryBuilder query = QueryBuilder.byClass(A.class);
	List<CdoSnapshot> snapshots = javers.findSnapshots(query.build());

	return javers.getJsonConverter().toJson(snapshots);
}

}
`

And I have a tests to try it out:

`
@activeprofiles("test")
@SpringBootTest
@slf4j
class AServiceTest {
@Autowired
private ARepository repository;

@Autowired
private AService service;


@Test
void testJavers() {
	repository.save(buildEntity());
	
	String info = service.getInitSnapshot("id");
	
	log.info(info);
	
	assertNotNull(info);
}

}
`

Well, this doesn't work.
When Javers try to parse UnboundedValueObjectId of a Map<String, List> .

Steps To Reproduce
I have a **runnable test case ** which isolates the bug and allows Javers Core Team to easily reproduce it. I have pushed this test case to my fork of this repository:

Please feel free to fork out
https://github.com/xytrams/javers-error

Javers' Version
6.1.1

Additional context
...
Would be great if it could be fixed/dealt with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions