Skip to content

Neo4jTemplate.saveAs throws StackOverflowError when given recursive projection #2591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cberes opened this issue Sep 12, 2022 · 1 comment
Closed
Assignees
Labels
type: bug A general bug

Comments

@cberes
Copy link
Contributor

cberes commented Sep 12, 2022

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 12, 2022
@meistermeier meistermeier self-assigned this Sep 13, 2022
@meistermeier
Copy link
Collaborator

Thanks for reporting this and the reproducer. Yes, you are completely right. This is definitely a bug and now -thanks to your work- already solved. Just need to add some internal testing and it will get fixed in the next 6.3. patch version.

@meistermeier meistermeier added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 14, 2022
@meistermeier meistermeier added this to the 6.3.3 (2021.2.3) milestone Sep 14, 2022
@michael-simons michael-simons mentioned this issue Jan 4, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants