Program: 28868
Project: 28868
Buggy source:
private String constructJsonForCustomMapping(Object eventObj,TemplateBuilder payloadTemplateBuilder){
  StringBuilder sb=new StringBuilder();
  int numberOfOuterObjects=0;
  if (enclosingElement != null) {
    String[] nodeNames=enclosingElement.split("String_Node_Str");
    if (DEFAULT_ENCLOSING_ELEMENT.equals(nodeNames[0])) {
      numberOfOuterObjects=nodeNames.length - 1;
    }
 else {
      numberOfOuterObjects=nodeNames.length;
    }
    for (    String nodeName : nodeNames) {
      if (!DEFAULT_ENCLOSING_ELEMENT.equals(nodeName)) {
        sb.append(JSON_EVENT_START_SYMBOL).append("String_Node_Str").append(nodeName).append("String_Node_Str").append(JSON_KEYVALUE_SEPERATOR);
      }
    }
    if (eventObj.getClass() == Event.class) {
      Event event=doPartialProcessing((Event)eventObj);
      sb.append(payloadTemplateBuilder.build(event));
    }
 else     if (eventObj.getClass() == Event[].class) {
      String jsonEvent;
      sb.append(JSON_ARRAY_START_SYMBOL);
      for (      Event e : (Event[])eventObj) {
        jsonEvent=payloadTemplateBuilder.build(doPartialProcessing(e));
        if (jsonEvent != null) {
          sb.append(jsonEvent).append(JSON_EVENT_SEPERATOR).append("String_Node_Str");
        }
      }
      sb.delete(sb.length() - 2,sb.length());
      sb.append(JSON_ARRAY_END_SYMBOL);
    }
 else {
      log.error("String_Node_Str" + eventObj.toString() + "String_Node_Str");
      return null;
    }
    for (int i=0; i < numberOfOuterObjects; i++) {
      sb.append(JSON_EVENT_END_SYMBOL);
    }
    return sb.toString();
  }
 else {
    if (eventObj.getClass() == Event.class) {
      return payloadTemplateBuilder.build(doPartialProcessing((Event)eventObj));
    }
 else     if (eventObj.getClass() == Event[].class) {
      String jsonEvent;
      sb.append(JSON_ARRAY_START_SYMBOL);
      for (      Event event : (Event[])eventObj) {
        jsonEvent=payloadTemplateBuilder.build(doPartialProcessing(event));
        if (jsonEvent != null) {
          sb.append(jsonEvent).append(JSON_EVENT_SEPERATOR).append("String_Node_Str");
        }
      }
      sb.delete(sb.length() - 2,sb.length());
      sb.append(JSON_ARRAY_END_SYMBOL);
      return sb.toString();
    }
 else {
      log.error("String_Node_Str" + eventObj.toString() + "String_Node_Str");
      return null;
    }
  }
}

Fixed version (ground truth):
private String constructJsonForCustomMapping(Object eventObj,TemplateBuilder payloadTemplateBuilder){
  StringBuilder sb=new StringBuilder();
  int numberOfOuterObjects=0;
  if (enclosingElement != null) {
    String[] nodeNames=enclosingElement.split("String_Node_Str");
    if (DEFAULT_ENCLOSING_ELEMENT.equals(nodeNames[0])) {
      numberOfOuterObjects=nodeNames.length - 1;
    }
 else {
      numberOfOuterObjects=nodeNames.length;
    }
    for (    String nodeName : nodeNames) {
      if (!DEFAULT_ENCLOSING_ELEMENT.equals(nodeName)) {
        sb.append(JSON_EVENT_START_SYMBOL).append("String_Node_Str").append(nodeName).append("String_Node_Str").append(JSON_KEYVALUE_SEPERATOR);
      }
    }
    if (eventObj instanceof Event) {
      Event event=doPartialProcessing((Event)eventObj);
      sb.append(payloadTemplateBuilder.build(event));
    }
 else     if (eventObj instanceof Event[]) {
      String jsonEvent;
      sb.append(JSON_ARRAY_START_SYMBOL);
      for (      Event e : (Event[])eventObj) {
        jsonEvent=payloadTemplateBuilder.build(doPartialProcessing(e));
        if (jsonEvent != null) {
          sb.append(jsonEvent).append(JSON_EVENT_SEPERATOR).append("String_Node_Str");
        }
      }
      sb.delete(sb.length() - 2,sb.length());
      sb.append(JSON_ARRAY_END_SYMBOL);
    }
 else {
      log.error("String_Node_Str" + eventObj.toString() + "String_Node_Str");
      return null;
    }
    for (int i=0; i < numberOfOuterObjects; i++) {
      sb.append(JSON_EVENT_END_SYMBOL);
    }
    return sb.toString();
  }
 else {
    if (eventObj.getClass() == Event.class) {
      return payloadTemplateBuilder.build(doPartialProcessing((Event)eventObj));
    }
 else     if (eventObj.getClass() == Event[].class) {
      String jsonEvent;
      sb.append(JSON_ARRAY_START_SYMBOL);
      for (      Event event : (Event[])eventObj) {
        jsonEvent=payloadTemplateBuilder.build(doPartialProcessing(event));
        if (jsonEvent != null) {
          sb.append(jsonEvent).append(JSON_EVENT_SEPERATOR).append("String_Node_Str");
        }
      }
      sb.delete(sb.length() - 2,sb.length());
      sb.append(JSON_ARRAY_END_SYMBOL);
      return sb.toString();
    }
 else {
      log.error("String_Node_Str" + eventObj.toString() + "String_Node_Str");
      return null;
    }
  }
}