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

Bug 401413

Summary: CascadeDeletesJUnitTestSuite fails occasionally with ArrayIndexOutOfBoundsException
Product: z_Archived Reporter: Sabine Heider <sabine.heider>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 383862    

Description Sabine Heider CLA 2013-02-21 06:08:23 EST
The JPA test CascadeDeletesJUnitTestSuite.testDeletePrivateOwned fails occasionally with an ArrayIndexOutOfBoundsException:

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 0
	at java.util.Vector.get(Vector.java:694)
	at org.eclipse.persistence.indirection.IndirectList.get(IndirectList.java:410)
	at org.eclipse.persistence.testing.tests.jpa.cascadedeletes.CascadeDeletesJUnitTestSuite.testDeletePrivateOwned(CascadeDeletesJUnitTestSuite.java:141)
	at org.eclipse.persistence.testing.framework.junit.JUnitTestCase.runBare(JUnitTestCase.java:600)
	at org.eclipse.persistence.testing.framework.TestExecutor.execute(TestExecutor.java:248)
	at org.eclipse.persistence.testing.framework.TestModel.execute(TestModel.java:211)
	at org.eclipse.persistence.testing.framework.TestCollection.run(TestCollection.java:313)


This problem is caused by an error in the test itself. The test builds up a tree structure (simplified to relevant part):

               rootA
                 |
               branchB
               /    \
       subbranchB1   subbranchB2
          |
        leafB

The test later accesses the first element in the list of subbranchBs that are related to branchB and implicitly assumes that always subbranchB1 is returned. Since the list is not sorted, this assumption is not always true.

As a fix to this issue I would suggest to add an @OrderBy(id) annotation to the relationship between branchB and subbranchB.

I'll upload a corresponding change to github.
Comment 1 Sabine Heider CLA 2013-02-21 06:55:32 EST
Here is the github change (pull request created as well):
https://github.com/sabineheider/eclipselink.runtime/commit/6b0d36a178244a6c43954ce4cca7d353cd94f55f
Comment 2 Sabine Heider CLA 2013-02-27 10:41:14 EST
I assert that I:
- authored 100% the content I am contributing
- have the rights to donate the content to Eclipse
- contribute the content under the EPL
Comment 3 Tom Ware CLA 2013-02-27 14:09:43 EST
Checked fix into master.

Reviewed by: Tom Ware reviewed user submitted fix

Tested with JPA and Core LRG
HANA testing done by contributor
Comment 4 Sabine Heider CLA 2013-02-28 04:51:32 EST
Commit 8e15437c4268aef22ce136aeceb0fa996296d392
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:29:33 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink