Skip to content
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

One more case of false-positive cycles detection [DATAMONGO-1652] #2558

spring-projects-issues opened this issue Mar 29, 2017 · 1 comment
in: mapping status: duplicate type: bug


Copy link

@spring-projects-issues spring-projects-issues commented Mar 29, 2017

Sergey Bykov opened DATAMONGO-1652 and commented

The cycles detector gives false warnings under some conditions. The issue occurs when there are multiple similar 'branches' in the tree of the included objects.

Example reproducing the issue

Full working example can be seen here:

Main entity A includes two value objects B and C:

@Document(collection = "ROOT_ENTITY")
public class A {

    public String id;

     * Workaround to fix the issue: just swap this.b and this.c here in this class :)
    public B b;

    public C c;


Class B is not highly interesting, the only note is it must include some fields not of simple types, for example D (the contents of D doesn’t matter):

public class B {

    public D d;


Class C also includes B (it is crucial that B is included both in A and C):

public class C implements Serializable {

    public B b;


When the application with such a class structure boots, it gives a false warning:$CyclicPropertyReferenceException: Found cycle for field 'd' in type 'B' for path 'b' which was probably intended to fix such cases but still fails under some rare conditions.

Source of the problem

When MongoPersistentEntityIndexResolver searches for the cycles, it records the possible inclusion paths as a set of the strings, and then tries to match the current stringified path with the previously found paths. In this example ".b" is found to be a substring of "c.b", so it gives a false positive warning.

Note that C must include some non-simple fields (class D in the example), otherwise it would be outfiltered by the conditional logic in

Quick workaround

Simply swap the lines public B b; and public C c; in the definition of the class A. In this case, traverse order changes, and the cycle detector will try to check whether "c.b" is a substring of ".b", which is not, and no warning will be issued :)

Affects: 1.10.1 (Ingalls SR1)

Reference URL:

Issue Links:

  • DATAMONGO-1782 CyclicPropertyReferenceException on index resolution
    ("is duplicated by")
Copy link

@spring-projects-issues spring-projects-issues commented Sep 15, 2017

Mark Paluch commented

Will be fixed with DATAMONGO-1782

@spring-projects-issues spring-projects-issues added type: bug status: duplicate in: mapping labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: mapping status: duplicate type: bug
None yet

No branches or pull requests

2 participants