[ https://issues.apache.org/jira/browse/TAP5-2749?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17715537#comment-17715537 ]
Hudson commented on TAP5-2749: ------------------------------ FAILURE: Integrated in Jenkins build Tapestry ยป tapestry-trunk-freestyle #169 (See [https://ci-builds.apache.org/job/Tapestry/job/tapestry-trunk-freestyle/169/]) TAP5-2749: Incorrect behavior of getIfExists in EntityApplicationStatePersistenceStrategy (#36) (github: rev dca4fd046fc222ed27af9f599c8149908c9f7657) * (edit) tapestry-jpa/src/test/java/org/example/app6/pages/SSOEntity.java * (edit) tapestry-hibernate/src/main/java/org/apache/tapestry5/hibernate/web/internal/EntityApplicationStatePersistenceStrategy.java * (edit) tapestry-jpa/src/test/app6/SSOEntity.tml * (edit) tapestry-jpa/build.gradle * (edit) tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityApplicationStatePersistenceStrategy.java * (edit) tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategy.java > Incorrect behavior of getIfExists in EntityApplicationStatePersistenceStrategy > ------------------------------------------------------------------------------ > > Key: TAP5-2749 > URL: https://issues.apache.org/jira/browse/TAP5-2749 > Project: Tapestry 5 > Issue Type: Bug > Components: tapestry-jpa > Affects Versions: 5.5.0, 5.8.2 > Reporter: Vladimir V. Bychkov > Assignee: Volker Lamp > Priority: Major > Fix For: 5.8.3 > > Time Spent: 40m > Remaining Estimate: 0h > > +Error description+ > Test [project > demonstrates|https://github.com/bvfalcon/tapestry-entity-state-test] an error > which was added during optimization TAP5-2478. > Methods > [get|https://github.com/apache/tapestry-5/blob/5.8.2/tapestry-core/src/main/java/org/apache/tapestry5/services/ApplicationStateManager.java#L57] > and > [getIfExists|https://github.com/apache/tapestry-5/blob/5.8.2/tapestry-core/src/main/java/org/apache/tapestry5/services/ApplicationStateManager.java#L67] > in ApplicationStateManager work different for JPA-Entities: first works > correct, second gives ClassCastException. > +Reason+ > By invoking > [ApplicationStateManager.set|https://github.com/apache/tapestry-5/blob/5.8.2/tapestry-core/src/main/java/org/apache/tapestry5/services/ApplicationStateManager.java#L87] > method EntityApplicationStatePersistenceStrategy.set is used, which > [*transforms*|https://github.com/apache/tapestry-5/blob/5.8.2/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityApplicationStatePersistenceStrategy.java#L70] > instanceof Entity-class to instance of PersistedEntity Class. > By Invoking ApplicationStateManager.get method > EntityApplicationStatePersistenceStrategy.get is used, which > [*transforms*|https://github.com/apache/tapestry-5/blob/5.8.2/tapestry-jpa/src/main/java/org/apache/tapestry5/internal/jpa/EntityApplicationStatePersistenceStrategy.java#L44] > instanceof PersistedEntity Class back to Entity-class. Therefore [this > code|https://github.com/bvfalcon/tapestry-entity-state-test/blob/master/src/main/java/org/apache/tapestry/components/Layout.java#L14] > works correct. > By Invoking ApplicationStateManager.getIfExists method > SessionApplicationStatePersistenceStrategy.getIfExists is used > (SessionApplicationStatePersistenceStrategy is a superclass for > EntityApplicationStatePersistenceStrategy), which > [*casts*|https://github.com/apache/tapestry-5/blob/5.8.2/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/SessionApplicationStatePersistenceStrategy.java#L75] > instanceof PersistedEntity Class to Entity-class. This is incorrect and > gives ClassCastException in [this > code|https://github.com/bvfalcon/tapestry-entity-state-test/blob/master/src/main/java/org/apache/tapestry/components/Layout.java#L15]. > 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|https://github.com/apache/tapestry-5/blob/5.5.0/tapestry-core/src/main/java/org/apache/tapestry5/services/ApplicationStatePersistenceStrategy.java#L57] > in EntityApplicationStatePersistenceStrategy, may be with some optimizations > from TAP5-2478. -- This message was sent by Atlassian Jira (v8.20.10#820010)