| Summary: | testRead() in LOB test model failed on WebSphere with NPE | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Yiping Zhao <yiping.zhao> | ||||
| Component: | Eclipselink | Assignee: | Project Inbox <eclipselink.orm-inbox> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P2 | CC: | andrei.ilitchev, tom.ware | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
|
Description
Yiping Zhao
The test started to fail due to the change of the test code - it used to NOT close the entity manager before triggering the fetch group. That means it's not a regression - to fix the test it should be just rolled back to its previous state (rev. 6213). The test was altered to expose the bug, which happened when a fetch group is triggered on a detached object. That bug was fixed as part of work on nested fetch groups (see bug 244124). However this is still happening on WebSphere. Investigation showed that on WebSphere after the entity manager is closed the object is still registered in the entity manager's unitOfWork (and the uow is not dead). That is caused by fix to Bug 259993 - em.find() hangs up in some situations on WebSphere 7.0.0.1. WebSphere apparently caches EntityNamagerImpls - instead of closing them it calls em.clear and then return to a cache for future reuse. The problem was the timing of the clear call - it came when Eclipselink has not yet merged uow (in afterComplete). Fix for Bug 259993 cured this problem but not allowing em.clear() called while uow is merging to do anything but to clear the cache. There are several drawbacks to this solution: 1) Objects read in by ValueHolders triggered on detached objects may loose identity (uow has no cache); 2) uow is never released - map of clones, etc is held until the uow is garbage collected. This second point is also the reason for the test failure - the fetch group code verifies if the object is registered in the uow, and if it is assumes that the object is also present in uow's cache. But currently on WebSphere using jta after em.close() the object is still registered, but is not in the uow's cache. The suggested solution: if em.clear is called on synchronized uow, and if the uow is merging (WebSphere's case) then don't clear the cache, but set the flag that will cause uow to be released after the merge in afterCompletion is complete. That would cure both problems listed above. Created attachment 171977 [details]
Suggested patch.
Checked into trunk. Reviewed by James. Will be backported to 2.1.1 when it's unfrozen. Checked into 2.1.1 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |