Bug 449449 - Moxy - Cycle is detected in the object graph despite setting XmlInverseReference
Summary: Moxy - Cycle is detected in the object graph despite setting XmlInverseReference
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-31 06:38 EDT by Dirk Manske CLA
Modified: 2022-06-09 10:03 EDT (History)
0 users

See Also:


Attachments
Test case (6.46 KB, application/octet-stream)
2014-10-31 06:38 EDT, Dirk Manske CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Manske CLA 2014-10-31 06:38:07 EDT
Created attachment 248294 [details]
Test case

I experience a strange behavior while marshalling an object graph with bi-directional relationships. 

The error message is:

> Exception [EclipseLink-25037] (Eclipse Persistence Services -
> 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.XMLMarshalException
> 
> Exception Description: A cycle is detected in the object graph.  This
> will cause an infinite loop:
> com.moxytest.Cycle$Doc@27f723 ->
> com.moxytest.Cycle$Pub@670b40af -> com.moxytest.Cycle$Agree@4923ab24
> -> com.moxytest.Cycle$Agen@44c8afef -> com.moxytest.Cycle$Acc@7b69c6ba ->
> com.moxytest.Cycle$Med@46daef40 ->
> com.moxytest.Cycle$Pag@12f41634 -> com.moxytest.Cycle$Doc@27f723

The object graph in the exception message seems not in the order of processing. Debugging XPathObjectBuilder shows that on the cycleDetectionStack the objects are pushed in the following order:

    com.moxytest.Cycle$Doc
    com.moxytest.Cycle$Pag
    com.moxytest.Cycle$Med
    com.moxytest.Cycle$Acc
    com.moxytest.Cycle$Agen
    com.moxytest.Cycle$Agree
    com.moxytest.Cycle$Pub 

   

I do not understand why the exception is being thrown because I thought it would be sufficient to use @XmlInverseReference. The problem only occurs with a more complex object graph as attached in the test case. 

If I remove @XMLElement at setDocs() in class Pub it works. But then I loose the docs objects when marshalling Pub.
Comment 1 Eclipse Webmaster CLA 2022-06-09 10:03:37 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink