This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
For a simple test case, I created a model with two classes, Container and Contained, with a 1:n composition assocation between them. The classes are tagged with org.netbeans.mdr.transient=true. A test case creates an instance of each class and links them, and then exports them via XMI. The result is an infinite loop, as the export for Contained walks back up to Container, then back down to Contained, etc. The complete testcase is attached; the README has instructions. Note that if the transient tag is removed, the export works correctly.
Created attachment 10552 [details] test case source files for issue 34081
Evaluation: The infinite loop is caused by a bug related to transient objects. The call container.getContained().add(contained); should add link between 'container' and 'contained', however, container.getContained(); returns a collection storing 'container' (instead of 'contained'). This does not happen if transient objects are not used. The other thing is that transient objects should not be serialized into xmi at all ...
Hi Dan, so are you going to do anything about this?
Thanks for looking at it so quickly. Is there a reason transient objects shouldn't be acceptable to XMI export/import? I'm using it for readable serialization of command-pattern objects, for which it seems quite useful. Maybe I should be using an in-memory repository instead.
I have fixed the bug related to transient objects. As a consequence, xmi writer does not loop and a correct xmi document is produced (including transient objects - regarding them, I have not made any changes in xmi writer).
Thanks! I verified the fix and XMI export works fine. After re-enabling transient support in my application, I ran into another problem which is easy to reproduce. If you make the Contained end of the association ordered, and then attempt System.out.println(container.getContained().indexOf(contained)); you'll get a ClassCastException: [java] Exception in thread "main" java.lang.ClassCastException [java] at org.netbeans.mdr.storagemodel.transientimpl.TransientMultivaluedOrderedIndex.getItemsOrdered(TransientMultivaluedOrderedIndex.java:325) [java] at org.netbeans.mdr.storagemodel.AssocEndIndexUList.getItemsList(AssocEndIndexUList.java:38) [java] at org.netbeans.mdr.storagemodel.AssocEndIndexUList.indexOf(AssocEndIndexUList.java:66) [java] at org.netbeans.mdr.handlers.AEIndexUListWrapper.indexOf(AEIndexUListWrapper.java:162) [java] at Test.main(Test.java:42) Probably the superclass slipped in a SlotCollection which should have been an OrderedSlotCollection. Should I reopen this issue or open a new one?
OK, the reason why the exception occured was exactly as you described. It is fixed. If you encounter another bug related to transient objects, open a new issue, please.