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

Blocking cache never released in some circumstances

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.2.3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Liferay SE 5.2.3 revision 30246
      Java 1.6
      MySQL 5.0.45
      Windows XP
    • Branch Version/s:
      5.1.x
    • Backported to Branch:
      Committed

      Description

      I came across a problem with how the EHCache BlockingCache (see LPS-2700) is being used in the finder cache when testing adding a new User.

      In most of the finder implementations, the following occurs:

      1) Lookup the result in the finder cache using the supplied parameters
      result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_C_N,
      finderArgs, this);

      2) If the result is null then perform the actual find against the database

      3) If the DB query returns nothing then add SOMETHING to the finder cache to unblock the BlockingCache

      4) If the DB DID return something then call cacheResult passing the returned object.

      if (list.isEmpty())

      { FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N, finderArgs, list); }

      else

      { role = list.get(0); cacheResult(role); }

      The problem occurs when the arguments passed to the finder function are different from the values in the object returned by the DB and subsequently used to put the result into the cache. When this happens the next time step 1 above occurs it hangs.

      In my case it was the function com.liferay.portal.service.persistence.RolePersistenceImpl.fetchByC_N(long, String, boolean).

      The arguments passed to the function were 10108 and "Power User ". Importantly the role has a trailing space. The hibernate query using these arguments returns the correct Role object ( I guess the value is being trimmed somewhere). That object is then passed to cacheResult which has the following line of code:

      FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_C_N,
      new Object[]

      { new Long(role.getCompanyId()), role.getName() }

      , role);

      This line of code insert the role object into the cache using a different key from the initial getResult, i.e. the role name used to set the object in the cache doesn't have a trailing space. Therefore the next time getResult is called it hangs.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  10 years, 49 weeks, 5 days ago

                  Packages

                  Version Package
                  5.2.3