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

ModelListener Caching Bug at onBeforeAddAssociation

Details

    • Oracle Sun JDK 8
    • Apache Tomcat 7.0
    • HSQLDB 2
    • Desktop

    Description

      Use case:

      • Create a model listener for the user model
        public class BugDemoModelListener extends BaseModelListener<User>
      • Override onBeforeAddAssociation method
      • Access the old user roles (before the new one is added)

      Expected behaviour:

      • You can access the old user roles and perform some custom logic without any effects

      Current behaviour:

      • As soon as you call user.getRoles() from the onBeforeAddAssociation method the gui of the control panel -> edit user -> roles doesn't show the newly added role. You have to restart the server because the cache was cleared at the wrong time.

      Workaround:

      • If you want to access the user roles (even if it's just for System.outs) in the onBeforeAddAssociation method you have to manually clear the cache so that the control panel gui is showing the newly added role as expected:
      PortalCache<Long, long[]> portalCacheRTL = MultiVMPoolUtil.getCache(
           TableMapper.class.getName() + "-Users_Roles-RightToLeft");
      portalCacheRTL.remove(user.getUserId());
      

      This could also effect the caching of all other associations (not just for user roles)!

      Attachments

        Activity

          People

            support-lep@liferay.com SE Support
            oli_bayer Oliver Bayer
            Kiyoshi Lee Kiyoshi Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              22 weeks ago

              Packages

                Version Package