Program: 116657
Project: 116657
Buggy source:
public Set<Cluster> getClusters(int tenantId,String cartridgeType){
  Set<CartridgeTypeContext> cartridgeTypeContextSet=null;
  Set<SubscriptionAliasContext> subscriptionAliasContextSet=null;
  Set<Cluster> clusterSet=new HashSet<Cluster>();
  readLock.lock();
  try {
    cartridgeTypeContextSet=tenantIdToCartridgeTypeContextMap.get(tenantId);
    if (cartridgeTypeContextSet != null) {
      Iterator<CartridgeTypeContext> typeCtxIterator=cartridgeTypeContextSet.iterator();
      while (typeCtxIterator.hasNext()) {
        CartridgeTypeContext cartridgeTypeContext=typeCtxIterator.next();
        if (cartridgeType != null) {
          if (cartridgeTypeContext.equals(new CartridgeTypeContext(cartridgeType))) {
            subscriptionAliasContextSet=cartridgeTypeContext.getSubscriptionAliasContextSet();
            if (subscriptionAliasContextSet != null) {
              Iterator<SubscriptionAliasContext> aliasCtxIterator=subscriptionAliasContextSet.iterator();
              while (aliasCtxIterator.hasNext()) {
                Cluster cluster=aliasCtxIterator.next().getCluster();
                clusterSet.add(cluster);
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + tenantId + "String_Node_Str"+ cluster.toString());
                  Collection<Member> members=cluster.getMembers();
                  if (members != null && !members.isEmpty()) {
                    for (                    Member member : members) {
                      log.debug("String_Node_Str" + member.getServiceName() + "String_Node_Str"+ member.getClusterId()+ "String_Node_Str"+ member.getMemberId()+ "String_Node_Str");
                    }
                  }
                }
              }
            }
          }
        }
 else {
          subscriptionAliasContextSet=cartridgeTypeContext.getSubscriptionAliasContextSet();
          if (subscriptionAliasContextSet != null) {
            Iterator<SubscriptionAliasContext> aliasCtxIterator=subscriptionAliasContextSet.iterator();
            clusterSet=new HashSet<Cluster>();
            while (aliasCtxIterator.hasNext()) {
              Cluster cluster=aliasCtxIterator.next().getCluster();
              clusterSet.add(cluster);
              if (log.isDebugEnabled()) {
                log.debug("String_Node_Str" + tenantId + "String_Node_Str"+ cartridgeType+ "String_Node_Str"+ cluster.toString());
                Collection<Member> members=cluster.getMembers();
                if (members != null && !members.isEmpty()) {
                  for (                  Member member : members) {
                    log.debug("String_Node_Str" + member.getServiceName() + "String_Node_Str"+ member.getClusterId()+ "String_Node_Str"+ member.getMemberId()+ "String_Node_Str");
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  finally {
    readLock.unlock();
  }
  return clusterSet;
}

Fixed version (ground truth):
public Set<Cluster> getClusters(int tenantId,String cartridgeType){
  Set<CartridgeTypeContext> cartridgeTypeContextSet=null;
  Set<SubscriptionAliasContext> subscriptionAliasContextSet=null;
  Set<Cluster> clusterSet=new HashSet<Cluster>();
  readLock.lock();
  try {
    cartridgeTypeContextSet=tenantIdToCartridgeTypeContextMap.get(tenantId);
    if (cartridgeTypeContextSet != null) {
      Iterator<CartridgeTypeContext> typeCtxIterator=cartridgeTypeContextSet.iterator();
      while (typeCtxIterator.hasNext()) {
        CartridgeTypeContext cartridgeTypeContext=typeCtxIterator.next();
        if (cartridgeType != null) {
          if (cartridgeTypeContext.equals(new CartridgeTypeContext(cartridgeType))) {
            subscriptionAliasContextSet=cartridgeTypeContext.getSubscriptionAliasContextSet();
            if (subscriptionAliasContextSet != null) {
              Iterator<SubscriptionAliasContext> aliasCtxIterator=subscriptionAliasContextSet.iterator();
              while (aliasCtxIterator.hasNext()) {
                Cluster cluster=aliasCtxIterator.next().getCluster();
                clusterSet.add(cluster);
                if (log.isDebugEnabled()) {
                  log.debug("String_Node_Str" + tenantId + "String_Node_Str"+ cluster.toString());
                  Collection<Member> members=cluster.getMembers();
                  if (members != null && !members.isEmpty()) {
                    for (                    Member member : members) {
                      log.debug("String_Node_Str" + member.getServiceName() + "String_Node_Str"+ member.getClusterId()+ "String_Node_Str"+ member.getMemberId()+ "String_Node_Str");
                    }
                  }
                }
              }
            }
          }
        }
 else {
          subscriptionAliasContextSet=cartridgeTypeContext.getSubscriptionAliasContextSet();
          if (subscriptionAliasContextSet != null) {
            Iterator<SubscriptionAliasContext> aliasCtxIterator=subscriptionAliasContextSet.iterator();
            while (aliasCtxIterator.hasNext()) {
              Cluster cluster=aliasCtxIterator.next().getCluster();
              clusterSet.add(cluster);
              if (log.isDebugEnabled()) {
                log.debug("String_Node_Str" + tenantId + "String_Node_Str"+ cartridgeType+ "String_Node_Str"+ cluster.toString());
                Collection<Member> members=cluster.getMembers();
                if (members != null && !members.isEmpty()) {
                  for (                  Member member : members) {
                    log.debug("String_Node_Str" + member.getServiceName() + "String_Node_Str"+ member.getClusterId()+ "String_Node_Str"+ member.getMemberId()+ "String_Node_Str");
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  finally {
    readLock.unlock();
  }
  return clusterSet;
}