Uploaded image for project: 'OpenAM'
  1. OpenAM
  2. OPENAM-6476

Initialization of a ServiceConfigImpl may block retrieval of already cached instances

    Details

    • Support Ticket IDs:

      Description

      The map "configImpls" is a concurrent hash map from ServiceConfigImpl.java

      What could happen is having severals threads waiting to access this map, due to one thread which locking it:

      This thread tries to add a ServiceConfigImpl into the cache via the function "getInstance" and needs to lock this map.

      ServiceConfigImpl.java
       // Add to cache
              synchronized (configImpls) {
                  // Check if already added by another thread
                  ServiceConfigImpl tmp = getFromCache(cacheName, null);
                  if (tmp == null) {
                      // Not in cache, construct service config impl
                      answer = new ServiceConfigImpl(scm, ss, entry, orgName,
                          groupName, compName, globalConfig, token);
                      configImpls.put(cacheName, answer);
                  } else {
                      answer = tmp;
                  }
              }
      

      The result is having a lot of threads blocked with the following stack:

      "http-bio-8080-exec-200" #883 daemon prio=5 os_prio=0 tid=0x00007fc50407e000 nid=0x838f waiting for monitor entry [0x00007fc48de66000]
         --java.lang.Thread.State: BLOCKED (on object monitor)
          at java.util.Collections$SynchronizedMap.get(Collections.java:2584)
          - waiting to lock <0x00000006c2785758> (a java.util.Collections$SynchronizedMap)
          at com.sun.identity.sm.ServiceConfigImpl.getFromCache(ServiceConfigImpl.java:600)
          at com.sun.identity.sm.ServiceConfigImpl.getInstance(ServiceConfigImpl.java:486)
          at com.sun.identity.sm.ServiceConfigImpl.getInstance(ServiceConfigImpl.java:464)
          at com.sun.identity.sm.ServiceConfigManagerImpl.getOrganizationConfig(ServiceConfigManagerI
      
      

      whereas one thread is locking the resource:

      "http-bio-8080-exec-66" #707 daemon prio=5 os_prio=0 tid=0x00007fc4e001d800 nid=0x827b runnable [0x00007fc4969f1000]
         java.lang.Thread.State: RUNNABLE
          at java.util.HashMap$TreeNode.find(HashMap.java:1865)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.find(HashMap.java:1861)
          at java.util.HashMap$TreeNode.putTreeVal(HashMap.java:1979)
          at java.util.HashMap.putVal(HashMap.java:637)
          at java.util.HashMap.put(HashMap.java:611)
          at java.util.HashSet.add(HashSet.java:219)
          at java.util.Collections$SynchronizedCollection.add(Collections.java:2035)
          - locked <0x00000006c49901f8> (a java.util.Collections$SynchronizedSet)
          at com.sun.identity.sm.CachedSMSEntry.addServiceListener(CachedSMSEntry.java:304)
          at com.sun.identity.sm.ServiceConfigImpl.<init>(ServiceConfigImpl.java:98)
          at com.sun.identity.sm.ServiceConfigImpl.getInstance(ServiceConfigImpl.java:552)
          - locked <0x00000006c2785758> (a java.util.Collections$SynchronizedMap)
          at com.sun.identity.sm.ServiceConfigImpl.getInstance(ServiceConfigImpl.java:464)
          at 
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                peter.major Peter Major [X] (Inactive)
                Reporter:
                quentin.castel Quentin CASTEL [X] (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: