Uploaded image for project: 'Crowd Data Center'
  1. Crowd Data Center
  2. CWD-2181

CachingUserManager's implementation of checking whether a user exists or not given the username is not thread-safe and could return false if the cache is flushed in the meanwhile

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Medium
    • None
    • 2.0.5, 2.0.7
    • None
    • JIRA in JIRA Studio 2.3

    Description

      In CachingUserManager.isUser(String userName), the following two statements are not atomic:

      getAllUserNamesFromCacheOrServer();                 // makes sure the cache is loaded with all users.
      return (basicCache.getUser(userName) != null);

      If the cache is flushed after the first statement is executed but before the second statement is executed, this method will return false.
      As the result of this method is returned by CrowdCredentialsProvider and CrowdProfileProvider etc, this causes com.opensympony.user.User.getCredentialsProvider() and com.opensympony.user.User.getPropertySet() to return null, resulting in NullPointerException being thrown when constructing a new instance of com.opensympony.user.User or invoking getEmail() and getFullName() methods of an existing com.opensympony.user.User instance.

      Additionally, in CachingUserManager.getAllUserNamesFromCacheOrServer(), the following two statements are not atomic either:

      loadAllUsers();
      userNames = basicCache.getAllUserNames();

      If the cache is flushed after the first statement is executed but before the second statement is executed, this method will return null.
      So the first patch I supplied could fail in this scenario.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              awei Alex Wei (DE)
              Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: