spring-projects / spring-projects/spring-data-mongodb

CyclicPropertyReferenceException: Found cycle for field... [DATAMONGO-1255]

Open
#2,173 1 comment 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Dec 30, 2020.

in: mapping type: bug
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Bilguun Bayarmagnai opened DATAMONGO-1255 and commented

Two types of scenarios are printing CyclicPropertyReferenceException log in our application similiar to the https://jira.spring.io/browse/DATAMONGO-962.
We have created tiny demo app using spring boot to illustrate these scenarios.

  1. When domain class contains itself(I guess in this case exception makes sense because there's a cycle, but if we can just ignore that.):
@Document
public class Foo {
	@Id
	private String id;
	private Bar bar;
}

public class Bar {
	private Bar previous;
}
  1. Next case is tricky. If property class(Partner) contains same field on same name(job) it throws exception. Plus Job class has to have a non-primitive field(Salary) to throw this exception.
@Document
public class Worker {
	@Id
	private String id;
	private Job job;
	private Partner partner;
}

public class Partner {
	private Job job;
}

public class Job {
	private Salary salary;
}

I'm not sure if the case #1 is intentional, but we will keep the structure as it is. But it would be great if this just a bug and can be fixed, or at least there's a way to ignore it. Case #2 can be avoided by naming differently, but still not an ideal solution.

p.s this is not causing serious issues, other than showering our console with ugly exceptions


Affects: 1.6.3 (Evans SR3)

Reference URL: https://github.com/Migakun/demo-mongo/tree/master/demo-mongo

1 votes, 4 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.