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

LocalCache in EntityCacheImpl and FinderCacheImpl isn't consistent

    Details

      Description

      Entity/Finder cache implementation strives in two underlying caches: localCache and portalCache. Every time a thread modifies the entity/finder cache the results are immediately visible in the portalCache, but not in the localCache. So if a record was cached in the local cache and changed afterwards in a new one, changes won't be visible in the current thread.

       

      Steps to Reproduce:

      1. Create a user.
      2. Retrieve its userId and execute the following script replacing #REPLACE_USERID with the userId value.
      import com.liferay.portal.kernel.model.User;
      import com.liferay.portal.kernel.service.UserLocalServiceUtil;
      import java.util.Date;
      
      User user = UserLocalServiceUtil.getUser(#REPLACE_USERID);
      
      Date newModifiedDate = null;
      
      Thread thread = new Thread() {
          public void run() {
      	user = UserLocalServiceUtil.getUser(#REPLACE_USERID);
              UserLocalServiceUtil.updateUser(user);
              newModifiedDate = user.getModifiedDate();
          }
      };
      
      thread.start();
      thread.join();
      
      user = UserLocalServiceUtil.getUser(#REPLACE_USERID);
      out.println("Is same updated user? " + user.getModifiedDate().equals(newModifiedDate));

       

      Actual Results:

      The script prints Is same updated user? false which means that both threads aren't handling the same information.

       

      Expected Results:

      The script should print: Is same updated user? true

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                2 weeks, 1 day ago

                Packages

                Version Package