mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
29.59.2025 e96dc1eae5f6bd4d4669e4327a6b038b543fe21d
[#545] Fix deadlock in StaticGroup.updateMembers by reducing writeLock scope
1 files modified
65 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java 65 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
@@ -549,44 +549,58 @@
    Reject.ifNull(nestedGroups);
    reloadIfNeeded();
    lock.writeLock().lock();
    try
    for (Modification mod : modifications)
    {
      for (Modification mod : modifications)
      Attribute attribute = mod.getAttribute();
      if (attribute.getAttributeDescription().getAttributeType().equals(memberAttributeType))
      {
        Attribute attribute = mod.getAttribute();
        if (attribute.getAttributeDescription().getAttributeType().equals(memberAttributeType))
        switch (mod.getModificationType().asEnum())
        {
          switch (mod.getModificationType().asEnum())
          {
            case ADD:
              for (ByteString v : attribute)
              {
                DN member = DN.valueOf(v);
          case ADD:
            for (ByteString v : attribute)
            {
              DN member = DN.valueOf(v);
              lock.writeLock().lock();
              try {
                memberDNs.add(new CompactDn(member));
                if (DirectoryServer.getGroupManager().getGroupInstance(member) != null)
                {
                  nestedGroups.add(member);
                }
              } finally {
                lock.writeLock().unlock();
              }
              break;
            case DELETE:
              if (attribute.isEmpty())
              {
            }
            break;
          case DELETE:
            if (attribute.isEmpty())
            {
              lock.writeLock().lock();
              try {
                memberDNs.clear();
                nestedGroups.clear();
              } finally {
                lock.writeLock().unlock();
              }
              else
            }
            else
            {
              for (ByteString v : attribute)
              {
                for (ByteString v : attribute)
                {
                  DN member = DN.valueOf(v);
                DN member = DN.valueOf(v);
                lock.writeLock().lock();
                try {
                  memberDNs.remove(new CompactDn(member));
                  nestedGroups.remove(member);
                } finally {
                  lock.writeLock().unlock();
                }
              }
              break;
            case REPLACE:
            }
            break;
          case REPLACE:
            lock.writeLock().lock();
            try {
              memberDNs.clear();
              nestedGroups.clear();
              for (ByteString v : attribute)
@@ -598,14 +612,13 @@
                  nestedGroups.add(member);
                }
              }
              break;
          }
            } finally {
              lock.writeLock().unlock();
            }
            break;
        }
      }
    }
    finally {
      lock.writeLock().unlock();
    }
  }
  @Override