Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
5.5.0, 5.8.2
-
None
Description
Error description
Test project demonstrates an error which was added during optimization TAP5-2478.
Methods get and getIfExists in ApplicationStateManager work different for JPA-Entities: first works correct, second gives ClassCastException.
Reason
By invoking ApplicationStateManager.set method EntityApplicationStatePersistenceStrategy.set is used, which transforms instanceof Entity-class to instance of PersistedEntity Class.
By Invoking ApplicationStateManager.get method EntityApplicationStatePersistenceStrategy.get is used, which transforms instanceof PersistedEntity Class back to Entity-class. Therefore this code works correct.
By Invoking ApplicationStateManager.getIfExists method SessionApplicationStatePersistenceStrategy.getIfExists is used (SessionApplicationStatePersistenceStrategy is a superclass for EntityApplicationStatePersistenceStrategy), which casts instanceof PersistedEntity Class to Entity-class. This is incorrect and gives ClassCastException in this code.
In other words, get makes back transformation, getIfExists - not. This is the root of problem.
Fix proposal
The best solution IMHO will be restore getIfExists in EntityApplicationStatePersistenceStrategy, may be with some optimizations from TAP5-2478.
Attachments
Issue Links
- is caused by
-
TAP5-2478 Create getIfExists in SessionApplicationStatePersistenceStrategy
- Closed