Program: 90906
Project: 90906
Buggy source:
private Object createPluginObject(PluginType type,Node node,LogEvent event){
  Class clazz=type.getPluginClass();
  if (Map.class.isAssignableFrom(clazz)) {
    try {
      Map<String,Object> map=(Map<String,Object>)clazz.newInstance();
      for (      Node child : node.getChildren()) {
        map.put(child.getName(),child.getObject());
      }
      return map;
    }
 catch (    Exception ex) {
      LOGGER.warn("String_Node_Str" + type.getElementName() + "String_Node_Str"+ clazz);
    }
  }
  if (List.class.isAssignableFrom(clazz)) {
    try {
      List<Object> list=(List<Object>)clazz.newInstance();
      for (      Node child : node.getChildren()) {
        list.add(child.getObject());
      }
      return list;
    }
 catch (    Exception ex) {
      LOGGER.warn("String_Node_Str" + type.getElementName() + "String_Node_Str"+ clazz);
    }
  }
  Method factoryMethod=null;
  for (  Method method : clazz.getMethods()) {
    if (method.isAnnotationPresent(PluginFactory.class)) {
      factoryMethod=method;
      break;
    }
  }
  if (factoryMethod == null) {
    return null;
  }
  Annotation[][] parmArray=factoryMethod.getParameterAnnotations();
  Class[] parmClasses=factoryMethod.getParameterTypes();
  if (parmArray.length != parmClasses.length) {
    LOGGER.error("String_Node_Str");
  }
  Object[] parms=new Object[parmClasses.length];
  int index=0;
  Map<String,String> attrs=node.getAttributes();
  List<Node> children=node.getChildren();
  StringBuilder sb=new StringBuilder();
  List<Node> used=new ArrayList<Node>();
  for (  Annotation[] parmTypes : parmArray) {
    for (    Annotation a : parmTypes) {
      if (sb.length() == 0) {
        sb.append("String_Node_Str");
      }
 else {
        sb.append("String_Node_Str");
      }
      if (a instanceof PluginNode) {
        parms[index]=node;
        sb.append("String_Node_Str").append(node.getName());
      }
 else       if (a instanceof PluginConfiguration) {
        parms[index]=this;
        if (this.name != null) {
          sb.append("String_Node_Str").append(name).append("String_Node_Str");
        }
 else {
          sb.append("String_Node_Str");
        }
      }
 else       if (a instanceof PluginValue) {
        String name=((PluginValue)a).value();
        String v=node.getValue();
        if (v == null) {
          v=getAttrValue("String_Node_Str",attrs);
        }
        String value=subst.replace(event,v);
        sb.append(name + "String_Node_Str" + "String_Node_Str"+ value+ "String_Node_Str");
        parms[index]=value;
      }
 else       if (a instanceof PluginAttr) {
        String name=((PluginAttr)a).value();
        String value=subst.replace(event,getAttrValue(name,attrs));
        sb.append(name + "String_Node_Str" + "String_Node_Str"+ value+ "String_Node_Str");
        parms[index]=value;
      }
 else       if (a instanceof PluginElement) {
        PluginElement elem=(PluginElement)a;
        String name=elem.value();
        if (parmClasses[index].isArray()) {
          Class parmClass=parmClasses[index].getComponentType();
          List<Object> list=new ArrayList<Object>();
          sb.append(name).append("String_Node_Str");
          boolean first=true;
          for (          Node child : children) {
            PluginType childType=child.getType();
            if (elem.value().equalsIgnoreCase(childType.getElementName()) || parmClass.isAssignableFrom(childType.getPluginClass())) {
              used.add(child);
              if (!first) {
                sb.append("String_Node_Str");
              }
              first=false;
              Object obj=child.getObject();
              if (obj == null) {
                System.out.println("String_Node_Str" + child.getName());
              }
              if (obj.getClass().isArray()) {
                printArray(sb,(Object[])obj);
                parms[index]=obj;
                break;
              }
              sb.append(child.toString());
              list.add(obj);
            }
          }
          sb.append("String_Node_Str");
          if (parms[index] != null) {
            break;
          }
          Object[] array=(Object[])Array.newInstance(parmClass,list.size());
          int i=0;
          for (          Object obj : list) {
            array[i]=obj;
            ++i;
          }
          parms[index]=array;
        }
 else {
          Class parmClass=parmClasses[index];
          boolean present=false;
          for (          Node child : children) {
            PluginType childType=child.getType();
            if (elem.value().equals(childType.getElementName()) || parmClass.isAssignableFrom(childType.getPluginClass())) {
              sb.append(child.getName()).append("String_Node_Str").append(child.toString()).append("String_Node_Str");
              present=true;
              used.add(child);
              parms[index]=child.getObject();
              break;
            }
          }
          if (!present) {
            sb.append("String_Node_Str");
          }
        }
      }
    }
    ++index;
  }
  if (sb.length() > 0) {
    sb.append("String_Node_Str");
  }
  if (attrs.size() > 0) {
    StringBuilder eb=new StringBuilder();
    for (    String key : attrs.keySet()) {
      if (eb.length() == 0) {
        eb.append(node.getName());
        eb.append("String_Node_Str");
        if (attrs.size() == 1) {
          eb.append("String_Node_Str");
        }
 else {
          eb.append("String_Node_Str");
        }
      }
 else {
        eb.append("String_Node_Str");
      }
      eb.append("String_Node_Str");
      eb.append(key);
      eb.append("String_Node_Str");
    }
    LOGGER.error(eb.toString());
  }
  if (!type.isDeferChildren() && used.size() != children.size()) {
    for (    Node child : children) {
      if (used.contains(child)) {
        continue;
      }
      String nodeType=node.getType().getElementName();
      String start=nodeType.equals(node.getName()) ? node.getName() : nodeType + "String_Node_Str" + node.getName();
      LOGGER.error(start + "String_Node_Str" + child.getName());
    }
  }
  try {
    int mod=factoryMethod.getModifiers();
    if (!Modifier.isStatic(mod)) {
      LOGGER.error(factoryMethod.getName() + "String_Node_Str" + clazz.getName()+ "String_Node_Str"+ node.getName());
      return null;
    }
    LOGGER.debug("String_Node_Str" + factoryMethod.getName() + "String_Node_Str"+ clazz.getName()+ "String_Node_Str"+ node.getName()+ sb.toString());
    return factoryMethod.invoke(null,parms);
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str" + factoryMethod.getName() + "String_Node_Str"+ clazz.getName()+ "String_Node_Str"+ node.getName(),e);
  }
  return null;
}

Fixed version (ground truth):
private Object createPluginObject(PluginType type,Node node,LogEvent event){
  Class clazz=type.getPluginClass();
  if (Map.class.isAssignableFrom(clazz)) {
    try {
      Map<String,Object> map=(Map<String,Object>)clazz.newInstance();
      for (      Node child : node.getChildren()) {
        map.put(child.getName(),child.getObject());
      }
      return map;
    }
 catch (    Exception ex) {
      LOGGER.warn("String_Node_Str" + type.getElementName() + "String_Node_Str"+ clazz);
    }
  }
  if (List.class.isAssignableFrom(clazz)) {
    try {
      List<Object> list=(List<Object>)clazz.newInstance();
      for (      Node child : node.getChildren()) {
        list.add(child.getObject());
      }
      return list;
    }
 catch (    Exception ex) {
      LOGGER.warn("String_Node_Str" + type.getElementName() + "String_Node_Str"+ clazz);
    }
  }
  Method factoryMethod=null;
  for (  Method method : clazz.getMethods()) {
    if (method.isAnnotationPresent(PluginFactory.class)) {
      factoryMethod=method;
      break;
    }
  }
  if (factoryMethod == null) {
    return null;
  }
  Annotation[][] parmArray=factoryMethod.getParameterAnnotations();
  Class[] parmClasses=factoryMethod.getParameterTypes();
  if (parmArray.length != parmClasses.length) {
    LOGGER.error("String_Node_Str");
  }
  Object[] parms=new Object[parmClasses.length];
  int index=0;
  Map<String,String> attrs=node.getAttributes();
  List<Node> children=node.getChildren();
  StringBuilder sb=new StringBuilder();
  List<Node> used=new ArrayList<Node>();
  for (  Annotation[] parmTypes : parmArray) {
    for (    Annotation a : parmTypes) {
      if (sb.length() == 0) {
        sb.append("String_Node_Str");
      }
 else {
        sb.append("String_Node_Str");
      }
      if (a instanceof PluginNode) {
        parms[index]=node;
        sb.append("String_Node_Str").append(node.getName());
      }
 else       if (a instanceof PluginConfiguration) {
        parms[index]=this;
        if (this.name != null) {
          sb.append("String_Node_Str").append(name).append("String_Node_Str");
        }
 else {
          sb.append("String_Node_Str");
        }
      }
 else       if (a instanceof PluginValue) {
        String name=((PluginValue)a).value();
        String v=node.getValue();
        if (v == null) {
          v=getAttrValue("String_Node_Str",attrs);
        }
        String value=subst.replace(event,v);
        sb.append(name).append("String_Node_Str").append(value).append("String_Node_Str");
        parms[index]=value;
      }
 else       if (a instanceof PluginAttr) {
        String name=((PluginAttr)a).value();
        String value=subst.replace(event,getAttrValue(name,attrs));
        sb.append(name).append("String_Node_Str").append(value).append("String_Node_Str");
        parms[index]=value;
      }
 else       if (a instanceof PluginElement) {
        PluginElement elem=(PluginElement)a;
        String name=elem.value();
        if (parmClasses[index].isArray()) {
          Class parmClass=parmClasses[index].getComponentType();
          List<Object> list=new ArrayList<Object>();
          sb.append(name).append("String_Node_Str");
          boolean first=true;
          for (          Node child : children) {
            PluginType childType=child.getType();
            if (elem.value().equalsIgnoreCase(childType.getElementName()) || parmClass.isAssignableFrom(childType.getPluginClass())) {
              used.add(child);
              if (!first) {
                sb.append("String_Node_Str");
              }
              first=false;
              Object obj=child.getObject();
              if (obj == null) {
                System.out.println("String_Node_Str" + child.getName());
              }
              if (obj.getClass().isArray()) {
                printArray(sb,(Object[])obj);
                parms[index]=obj;
                break;
              }
              sb.append(child.toString());
              list.add(obj);
            }
          }
          sb.append("String_Node_Str");
          if (parms[index] != null) {
            break;
          }
          Object[] array=(Object[])Array.newInstance(parmClass,list.size());
          int i=0;
          for (          Object obj : list) {
            array[i]=obj;
            ++i;
          }
          parms[index]=array;
        }
 else {
          Class parmClass=parmClasses[index];
          boolean present=false;
          for (          Node child : children) {
            PluginType childType=child.getType();
            if (elem.value().equals(childType.getElementName()) || parmClass.isAssignableFrom(childType.getPluginClass())) {
              sb.append(child.getName()).append("String_Node_Str").append(child.toString()).append("String_Node_Str");
              present=true;
              used.add(child);
              parms[index]=child.getObject();
              break;
            }
          }
          if (!present) {
            sb.append("String_Node_Str");
          }
        }
      }
    }
    ++index;
  }
  if (sb.length() > 0) {
    sb.append("String_Node_Str");
  }
  if (attrs.size() > 0) {
    StringBuilder eb=new StringBuilder();
    for (    String key : attrs.keySet()) {
      if (eb.length() == 0) {
        eb.append(node.getName());
        eb.append("String_Node_Str");
        if (attrs.size() == 1) {
          eb.append("String_Node_Str");
        }
 else {
          eb.append("String_Node_Str");
        }
      }
 else {
        eb.append("String_Node_Str");
      }
      eb.append("String_Node_Str");
      eb.append(key);
      eb.append("String_Node_Str");
    }
    LOGGER.error(eb.toString());
  }
  if (!type.isDeferChildren() && used.size() != children.size()) {
    for (    Node child : children) {
      if (used.contains(child)) {
        continue;
      }
      String nodeType=node.getType().getElementName();
      String start=nodeType.equals(node.getName()) ? node.getName() : nodeType + "String_Node_Str" + node.getName();
      LOGGER.error(start + "String_Node_Str" + child.getName());
    }
  }
  try {
    int mod=factoryMethod.getModifiers();
    if (!Modifier.isStatic(mod)) {
      LOGGER.error(factoryMethod.getName() + "String_Node_Str" + clazz.getName()+ "String_Node_Str"+ node.getName());
      return null;
    }
    LOGGER.debug("String_Node_Str",factoryMethod.getName(),clazz.getName(),node.getName(),sb.toString());
    return factoryMethod.invoke(null,parms);
  }
 catch (  Exception e) {
    LOGGER.error("String_Node_Str" + factoryMethod.getName() + "String_Node_Str"+ clazz.getName()+ "String_Node_Str"+ node.getName(),e);
  }
  return null;
}