| Summary: | Tuple.get(int) does not throw IllegalArgumentException when int exceeds length of result tuple | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Stephen DiMilla <stephen.dimilla> | ||||||
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | blocker | ||||||||
| Priority: | P3 | CC: | lance.andersen, stephen.dimilla, tom.ware | ||||||
| Version: | unspecified | ||||||||
| Target Milestone: | --- | ||||||||
| Hardware: | Macintosh | ||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Updating target milestone. Created attachment 223053 [details]
proposed fix and test cases
Proposed fix also includes minor fixes to resolve 366104 366112 366179 366182 as they all touch on the same issue.
Created attachment 223094 [details] fix and tests cases latest patch has a minor change to the validation logic. This also fixes problems described in bugs 366112, 366179 and 366182 Validation tests added to JUnitCriteriaSimpleTestSuite checked into main(2.5) reviewed by Gordon Yorke *** Bug 366182 has been marked as a duplicate of this bug. *** fixed *** Bug 366112 has been marked as a duplicate of this bug. *** *** Bug 366179 has been marked as a duplicate of this bug. *** The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: eclipselink-2.3.0.v20110604-r9504 Problem Using Tuple.get(99) should have thrown IllegalArgumentException when only 2 values exist in the Tuple ---------------------- Using the entity: @Entity @Table(name="CUSTOMER_TABLE") public class Customer implements java.io.Serializable { // Instance variables private String id; private String name; public Customer() { } public Customer (String id, String name) { this.id = id; this.name = name; } @Id @Column(name="ID") public String getId() { return id; } public void setId(String v) { this.id = v; } @Column(name="NAME") public String getName() { return name; } public void setName(String v) { this.name = v; } } ---------------------- Using the client code: CriteriaBuilder cbuilder = getEntityManager().getCriteriaBuilder(); et.begin(); CriteriaQuery<Tuple> cquery = cbuilder.createTupleQuery(); Root<Customer> customer = cquery.from(Customer.class); System.out.println("Use Tuple Query"); cquery.multiselect(customer.get("id"), customer.get("name")); TypedQuery<Tuple> tq = getEntityManager().createQuery(cquery); List<Tuple> result = tq.getResultList(); Tuple t = result.get(0); System.out.println("Testing valid index"); System.out.println("value:" + t.get(1, String.class)); System.out.println("Testing invalid index"); try { t.get(99, String.class); System.out.println("Did not get expected IllegalArgumentException for invalid index:" + t.get(99, String.class)); } catch (IllegalArgumentException iae) { System.out.println("Got expected IllegalArgumentException"); } catch (Exception e) { System.out.println("Received unexpected exception", e); } ---------------------- The output is: Testing valid index value:Alan E. Frechette Testing invalid index Received unexpected exception java.lang.IndexOutOfBoundsException: Index: 99, Size: 2 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at org.eclipse.persistence.queries.ReportQueryResult.getByIndex(ReportQueryResult.java:474) at org.eclipse.persistence.internal.jpa.querydef.TupleImpl.get(TupleImpl.java:82) at org.eclipse.persistence.internal.jpa.querydef.TupleImpl.get(TupleImpl.java:69) Reproducible: Always