Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313766

Summary: StackOverflowError with a self-referential ElementCollection
Product: [WebTools] Dali JPA Tools Reporter: Paul Fullbright <paul.fullbright>
Component: GeneralAssignee: Karen Butzke <karenfbutzke>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: david_williams, kaloyan, neil.hauge
Version: 2.3Flags: 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+
Target Milestone: 2.3 RC3   
Hardware: PC   
OS: Windows Vista   
Whiteboard: PMC_approved
Attachments:
Description Flags
stack trace
none
proposed patch against head
none
proposed patch against head none

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