Skip to content

Neo4jTemplate.saveAs throws StackOverflowError when given recursive projection #2591

@cberes

Description

@cberes

SDN is unable to save nodes using a projection that recursively references itself.

For example, say you have a node entity that recursively references itself

@Getter
@Node
public class Person {
  private String name;

  private List<Person> children = new LinkedList<>();
}

And a corresponding projection that references itself as well

public interface PersonWithChildrenRecursive {
  String getName();

  List<PersonWithChildrenRecursive> getChildren();
}

You cannot save a node using this projection

Person alice = new Person();
alice.setName("Alice");
neo4jTemplate.saveAs(alice, PersonWithChildrenRecursive.class); // throws StackOverflowError

Note that other ways to save will succeed, such as CrudRepository.save or Neo4jTemplate.saveAs with a projection that is not recursive.

I have an example app that reproduces the bug.

I don't know if this a new bug or a regression. I noticed it first while using 6.3.3-SNAPSHOT but the bug is present in 6.3.2 as well.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions