Program: 113861
Project: 113861
Buggy source:
@Override public void setACLEntries(StorageManager sMan,FileMetadata file,long parentId,String userId,List<String> groupIds,Map<String,Object> entries,AtomicDBUpdate update) throws MRCException, UserException {
  try {
    if (!sMan.getACL(file.getId()).hasNext()) {
      Map<String,Object> tmp=convertToACL(file.getPerms());
      entries.putAll(tmp);
    }
    for (    Entry<String,Object> entry : entries.entrySet())     sMan.setACLEntry(file.getId(),entry.getKey(),(Short)entry.getValue(),update);
    ACLEntry owner=sMan.getACLEntry(file.getId(),OWNER);
    ACLEntry group=sMan.getACLEntry(file.getId(),MASK);
    if (group == null)     group=sMan.getACLEntry(file.getId(),OWNER_GROUP);
    ACLEntry other=sMan.getACLEntry(file.getId(),OTHER);
    assert(group != null);
    assert(other != null);
    ACLEntry sticky=sMan.getACLEntry(file.getId(),STICKY_BIT);
    file.setPerms((short)((short)((owner.getRights() & PERM_SUID_SGID) > 0 ? POSIX_SUID : 0) | ((group.getRights() & PERM_SUID_SGID) > 0 ? POSIX_SGID : 0) | ((sticky != null && sticky.getRights() == 1) ? POSIX_STICKY : 0)| ((owner.getRights() & PERM_READ) > 0 ? POSIX_OWNER_READ : 0)| ((owner.getRights() & PERM_WRITE) > 0 ? POSIX_OWNER_WRITE : 0)| ((owner.getRights() & PERM_EXECUTE) > 0 ? POSIX_OWNER_EXEC : 0)| ((group.getRights() & PERM_READ) > 0 ? POSIX_GROUP_READ : 0)| ((group.getRights() & PERM_WRITE) > 0 ? POSIX_GROUP_WRITE : 0)| ((group.getRights() & PERM_EXECUTE) > 0 ? POSIX_GROUP_EXEC : 0)| ((other.getRights() & PERM_READ) > 0 ? POSIX_OTHER_READ : 0)| ((other.getRights() & PERM_WRITE) > 0 ? POSIX_OTHER_WRITE : 0)| ((other.getRights() & PERM_EXECUTE) > 0 ? POSIX_OTHER_EXEC : 0)));
    sMan.setMetadata(file,FileMetadata.RC_METADATA,update);
  }
 catch (  Exception exc) {
    throw new MRCException(exc);
  }
}

Fixed version (ground truth):
@Override public void setACLEntries(StorageManager sMan,FileMetadata file,long parentId,String userId,List<String> groupIds,Map<String,Object> entries,AtomicDBUpdate update) throws MRCException, UserException {
  try {
    Map<String,Object> aclMap=null;
    Iterator<ACLEntry> acl=sMan.getACL(file.getId());
    if (!acl.hasNext())     aclMap=convertToACL(file.getPerms());
 else {
      aclMap=new HashMap<String,Object>();
      while (acl.hasNext()) {
        ACLEntry next=acl.next();
        aclMap.put(next.getEntity(),next.getRights());
      }
    }
    aclMap.putAll(entries);
    for (    Entry<String,Object> entry : aclMap.entrySet()) {
      Number rights=(Number)entry.getValue();
      sMan.setACLEntry(file.getId(),entry.getKey(),rights == null ? null : rights.shortValue(),update);
    }
    short owner=((Number)aclMap.get(OWNER)).shortValue();
    Short group=aclMap.get(MASK) != null ? ((Number)aclMap.get(MASK)).shortValue() : null;
    if (group == null)     group=((Number)aclMap.get(OWNER_GROUP)).shortValue();
    short other=((Number)aclMap.get(OTHER)).shortValue();
    file.setPerms((short)((short)((owner & PERM_SUID_SGID) > 0 ? POSIX_SUID : 0) | ((group & PERM_SUID_SGID) > 0 ? POSIX_SGID : 0) | (file.getPerms() & POSIX_STICKY)| ((owner & PERM_READ) > 0 ? POSIX_OWNER_READ : 0)| ((owner & PERM_WRITE) > 0 ? POSIX_OWNER_WRITE : 0)| ((owner & PERM_EXECUTE) > 0 ? POSIX_OWNER_EXEC : 0)| ((group & PERM_READ) > 0 ? POSIX_GROUP_READ : 0)| ((group & PERM_WRITE) > 0 ? POSIX_GROUP_WRITE : 0)| ((group & PERM_EXECUTE) > 0 ? POSIX_GROUP_EXEC : 0)| ((other & PERM_READ) > 0 ? POSIX_OTHER_READ : 0)| ((other & PERM_WRITE) > 0 ? POSIX_OTHER_WRITE : 0)| ((other & PERM_EXECUTE) > 0 ? POSIX_OTHER_EXEC : 0)));
    sMan.setMetadata(file,FileMetadata.RC_METADATA,update);
  }
 catch (  Exception exc) {
    throw new MRCException(exc);
  }
}