| Summary: | Concurrency issue in ObjectBuilder.getPrimaryKeyClassifications | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Andrei Ilitchev <andrei.ilitchev> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | eclipselink.foundation-inbox |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
Checked the patch into trunk, 2.1.2 is pending. Checked the patch into 2.1.2. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Caused by an obvious oversight (really a typo): public List<Class> getPrimaryKeyClassifications() { if (primaryKeyClassifications == null) { List primaryKeyFields = this.descriptor.getPrimaryKeyFields(); List<Class> classifications = new ArrayList(primaryKeyFields.size()); for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseMapping mapping = getPrimaryKeyMappings().get(index); DatabaseField field = (DatabaseField)primaryKeyFields.get(index); if (mapping != null) { classifications.add(Helper.getObjectClass(mapping.getFieldClassification(field))); } else { classifications.add(null); } primaryKeyClassifications = classifications; } } return primaryKeyClassifications; } Assignment to primaryKeyClassifications done inside the loop causes it to be possibly altered by thread 2 while thread 1 is working on it - that causes IndexOutOfBounds exception. Of course the assignment should be done outside of the loop: public List<Class> getPrimaryKeyClassifications() { if (primaryKeyClassifications == null) { List primaryKeyFields = this.descriptor.getPrimaryKeyFields(); List<Class> classifications = new ArrayList(primaryKeyFields.size()); for (int index = 0; index < primaryKeyFields.size(); index++) { DatabaseMapping mapping = getPrimaryKeyMappings().get(index); DatabaseField field = (DatabaseField)primaryKeyFields.get(index); if (mapping != null) { classifications.add(Helper.getObjectClass(mapping.getFieldClassification(field))); } else { classifications.add(null); } } primaryKeyClassifications = classifications; } return primaryKeyClassifications; }