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.

Bug 34081 - XMI export of transient objects yields infinite loop
Summary: XMI export of transient objects yields infinite loop
Status: VERIFIED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Linux
: P3 blocker (vote)
Assignee: issues@java
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-06-02 06:27 UTC by _ jsichi
Modified: 2003-06-05 10:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
test case source files for issue 34081 (6.97 KB, application/octet-stream)
2003-06-02 06:30 UTC, _ jsichi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ jsichi 2003-06-02 06:27:18 UTC
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.
Comment 1 _ jsichi 2003-06-02 06:30:43 UTC
Created attachment 10552 [details]
test case source files for issue 34081
Comment 2 Daniel Prusa 2003-06-02 15:09:03 UTC
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 ...

Comment 3 Martin Matula 2003-06-02 18:33:36 UTC
Hi Dan, so are you going to do anything about this?
Comment 4 _ jsichi 2003-06-02 21:30:54 UTC
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.
Comment 5 Daniel Prusa 2003-06-04 15:49:43 UTC
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).
Comment 6 _ jsichi 2003-06-04 20:24:26 UTC
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?
Comment 7 Daniel Prusa 2003-06-05 10:16:53 UTC
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.