Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2749

Incorrect behavior of getIfExists in EntityApplicationStatePersistenceStrategy

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.5.0, 5.8.2
    • 5.8.3
    • tapestry-jpa
    • 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

          Activity

            People

              vlamp Volker Lamp
              vbychkov Vladimir V. Bychkov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m