Program: 179574
Project: 179574
Buggy source:
/** 
 * @throws DroolsMonitoringException
 */
@Override public void discover() throws DroolsMonitoringException {
  discover=false;
  discoverResource(KBASE_RESOURCE_NAMESPACE,new ResourceScanner(){
    public void add(    ObjectName resource){
      String knowledgeBaseId=resource.getKeyProperty("String_Node_Str");
synchronized (resourceScanners) {
        if (!resourceScanners.containsKey(knowledgeBaseId)) {
          KnowledgeBaseInfo kbaseInfo=new KnowledgeBaseInfo();
          kbaseInfo.setKnowledgeBaseId(knowledgeBaseId);
          kbaseInfo.setAgentId(agentId);
          knowledgeBaseInfos.add(kbaseInfo);
          KnowledgeBaseScanner scanner=new KnowledgeBaseScanner(agentId,resource,connector);
          resourceScanners.put(knowledgeBaseId,scanner);
          logger.info("String_Node_Str" + resource.getCanonicalName());
          discover=true;
        }
      }
    }
  }
);
  discoverResource(KSESSION_RESOURCE_NAMESPACE,new ResourceScanner(){
    public void add(    ObjectName resource){
      String knowledgeSessionId=String.valueOf(resource.getKeyProperty("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      String knowledgeBaseId;
      try {
        knowledgeBaseId=(String)connector.getConnection().getAttribute(resource,"String_Node_Str");
      }
 catch (      Exception e1) {
        logger.error("String_Node_Str" + agentId);
        return;
      }
      String scannerId=knowledgeBaseId.concat(knowledgeSessionId);
synchronized (resourceScanners) {
        if (!resourceScanners.containsKey(scannerId)) {
          KnowledgeSessionInfo ksessionInfo=new KnowledgeSessionInfo();
          ksessionInfo.setKnowledgeSessionId(Integer.valueOf(knowledgeSessionId));
          ksessionInfo.setAgentId(agentId);
          ksessionInfo.setKnowledgeBaseId(knowledgeBaseId);
          knowledgeSessionInfos.add(ksessionInfo);
          KnowledgeSessionScanner scanner=new KnowledgeSessionScanner(agentId,resource,connector);
          resourceScanners.put(scannerId,scanner);
          logger.info("String_Node_Str" + resource.getCanonicalName());
          discover=true;
        }
      }
    }
  }
);
  if (discoveredListener != null && discover) {
    discoveredListener.discovered(agentId);
  }
}

Fixed version (ground truth):
/** 
 * @throws DroolsMonitoringException
 */
@Override public void discover() throws DroolsMonitoringException {
  discover=false;
  discoverResource(KBASE_RESOURCE_NAMESPACE,new ResourceScanner(){
    public void add(    ObjectName resource){
      String knowledgeBaseId=resource.getKeyProperty("String_Node_Str");
synchronized (resourceScanners) {
        if (!resourceScanners.containsKey(knowledgeBaseId)) {
          KnowledgeBaseInfo kbaseInfo=new KnowledgeBaseInfo();
          kbaseInfo.setKnowledgeBaseId(knowledgeBaseId);
          kbaseInfo.setAgentId(agentId);
synchronized (knowledgeBaseInfos) {
            knowledgeBaseInfos.add(kbaseInfo);
          }
          KnowledgeBaseScanner scanner=new KnowledgeBaseScanner(agentId,resource,connector);
          resourceScanners.put(knowledgeBaseId,scanner);
          logger.info("String_Node_Str" + resource.getCanonicalName());
          discover=true;
        }
      }
    }
  }
);
  discoverResource(KSESSION_RESOURCE_NAMESPACE,new ResourceScanner(){
    public void add(    ObjectName resource){
      String knowledgeSessionId=String.valueOf(resource.getKeyProperty("String_Node_Str").replace("String_Node_Str","String_Node_Str"));
      String knowledgeBaseId;
      try {
        knowledgeBaseId=(String)connector.getConnection().getAttribute(resource,"String_Node_Str");
      }
 catch (      Exception e1) {
        logger.error("String_Node_Str" + agentId);
        return;
      }
      String scannerId=knowledgeBaseId.concat(knowledgeSessionId);
synchronized (resourceScanners) {
        if (!resourceScanners.containsKey(scannerId)) {
          KnowledgeSessionInfo ksessionInfo=new KnowledgeSessionInfo();
          ksessionInfo.setKnowledgeSessionId(Integer.valueOf(knowledgeSessionId));
          ksessionInfo.setAgentId(agentId);
          ksessionInfo.setKnowledgeBaseId(knowledgeBaseId);
synchronized (knowledgeSessionInfos) {
            knowledgeSessionInfos.add(ksessionInfo);
          }
          KnowledgeSessionScanner scanner=new KnowledgeSessionScanner(agentId,resource,connector);
          resourceScanners.put(scannerId,scanner);
          logger.info("String_Node_Str" + resource.getCanonicalName());
          discover=true;
        }
      }
    }
  }
);
  if (discoveredListener != null && discover) {
    discoveredListener.discovered(agentId);
  }
}