Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313766 - StackOverflowError with a self-referential ElementCollection
Summary: StackOverflowError with a self-referential ElementCollection
Status: VERIFIED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: General (show other bugs)
Version: 2.3   Edit
Hardware: PC Windows Vista
: P3 major (vote)
Target Milestone: 2.3 RC3   Edit
Assignee: Karen Butzke CLA
QA Contact:
URL:
Whiteboard: PMC_approved
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-20 12:48 EDT by Paul Fullbright CLA
Modified: 2010-06-01 16:04 EDT (History)
3 users (show)

See Also:
david_williams: pmc_approved+
neil.hauge: pmc_approved? (raghunathan.srinivasan)
neil.hauge: pmc_approved? (naci.dai)
neil.hauge: pmc_approved? (deboer)
neil.hauge: pmc_approved? (neil.hauge)
kaloyan: pmc_approved+
neil.hauge: review+


Attachments
stack trace (2.50 KB, text/plain)
2010-05-20 12:48 EDT, Paul Fullbright CLA
no flags Details
proposed patch against head (20.70 KB, patch)
2010-05-24 12:17 EDT, Karen Butzke CLA
no flags Details | Diff
proposed patch against head (20.35 KB, patch)
2010-05-24 13:44 EDT, Karen Butzke CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Fullbright CLA 2010-05-20 12:48:54 EDT
Created attachment 169375 [details]
stack trace

The following example triggers a StackOverflowError (attached):

@Embeddable
public class Foo {
	@ElementCollection
	private List<Foo> elementCollection;
}


At this point the workbench becomes pretty much unusable.
Comment 1 Karen Butzke CLA 2010-05-21 14:21:30 EDT
Also need to handle larger cycles like:

@Embeddable
public class Foo {
    @ElementCollection
    private List<Bar> bars;
}

@Embeddable
public class Bar{
    @ElementCollection
    private List<Foo> foos;
}
Comment 2 Karen Butzke CLA 2010-05-24 12:17:23 EDT
Created attachment 169690 [details]
proposed patch against head

The attached patch fixes the first use case for element collection and embedded mappings in both java and orm.  I also added JUnit tests for these cases.
Comment 3 Karen Butzke CLA 2010-05-24 13:44:27 EDT
Created attachment 169703 [details]
proposed patch against head
Comment 4 Karen Butzke CLA 2010-05-24 13:49:09 EDT
I have entered bug 314150 for the second use case. We have decided that fixing this is too difficult and would involve too many changes this late in Helios. The fix for the first use case is simpler and we can at least handle that particular case that causes a StackOverflowError.  Neither of these cases is all that likely, but the outcome if it does happen is bad.
Comment 5 Neil Hauge CLA 2010-05-24 16:01:51 EDT
* Explain why you believe this is a stop-ship defect. Or, if it is a "hotbug" (requested by an adopter) please document it as such. 

Stack Overflow results in unstable workbench environment.

* Is there a work-around? If so, why do you believe the work-around is insufficient? 

Avoid error case.

* How has the fix been tested? Is there a test case attached to the bugzilla record? Has a JUnit Test been added? 

Manually tested and unit tests have been added to detect this case.

* Give a brief technical overview. Who has reviewed this fix? 

Change prevents stack overflow by checking for the condition where the target embeddable type and the owning type are the same.  I have reviewed the fix.

* What is the risk associated with this fix? 

Low risk.
Comment 6 Karen Butzke CLA 2010-05-25 10:12:02 EDT
checked in to head
Comment 7 Paul Fullbright CLA 2010-06-01 16:04:11 EDT
Verified fixed in RC3