Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-13048

Collisions in HashCodeCacheKeyGenerator, leading to cache-corruption


    • Type: Bug
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s: 6.0.5 GA
    • Fix Version/s: 6.1.0 CE RC1
    • Component/s: ~[Archived] WCM
    • Labels:
    • Environment:
      Liferay 6.0.x on Tomcat 6.0.26
      Sun JDK
      MySQL 5.1.41
    • Liferay Contributor's Agreement:


      The key that is used to put entities into the FinderCaches (used by a.o. ExpandoValuePersistence) is not guaranteed to be unique per entity. Because the FinderCaches do not distinguish between colliding keys, this leads to wrong entities being fetched from these caches. A concrete example of such a collision can be found in the accompanying testcase.

      The testcase uses the id's from an actual cache-corruption that we encountered:

      • a Layout-ExpandoValue A is inserted in the cache.
      • another Layout-ExpandoValue B (differing in its columnId and its primaryKey) is requested from the cache
      • because B's key, generated by HashCodeCacheKeyGenerator, is the same as A's, A will be returned.

      Note that this happens highly frequently in our setup: I haven't done the math, but it's probable that the more ExpandoValues you define on a single Model, the likelier occurences of this issue will be. We've got 4 different expando's on Layout, and that seems to trigger the problem in approx. 1 out of 20 cases.

      Either the FinderCaches should take the key-collision possibility into account (seems quite a hassle), or the KeyGenerator used should guarantee unique keys.
      We'll implement the latter approach as a workaround: create a SimpleCacheKeyGenerator that concatenates all of its arguments into one big String and inject that Generator in util-spring.xml. However, I guess there must have been a reason to go through the complexities of generating a hashcode - memory-usage most likely ... Any caveats are most welcome.


          Issue Links



              support-lep@liferay.com SE Support
              bartrobeyns Bart Robeyns (Inactive)
              Participants of an Issue:
              Recent user:
              Esther Sanz
              1 Vote for this issue
              3 Start watching this issue


                Days since last comment:
                10 years, 16 weeks, 3 days ago


                  Version Package
                  6.1.0 CE RC1