Program: 12074
Project: 12074
Buggy source:
public static List<GeneratingMethodInfo> getTestMethodsFromTarget(IFile javaFile) throws Exception {
  List<GeneratingMethodInfo> testMethods=new ArrayList<GeneratingMethodInfo>();
  IPreferenceStore store=Activator.getDefault().getPreferenceStore();
  boolean enabled=store.getBoolean(STR.Preference.TestMethodGen.ENABLE);
  boolean enabledArgs=store.getBoolean(STR.Preference.TestMethodGen.ARGS);
  boolean enabledReturn=store.getBoolean(STR.Preference.TestMethodGen.RETURN);
  boolean enabledNotBlankMethods=store.getBoolean(STR.Preference.TestMethodGen.METHOD_SAMPLE_IMPLEMENTATION);
  boolean enableExcludesAccessors=store.getBoolean(STR.Preference.TestMethodGen.EXLCUDES_ACCESSORS);
  String delimiter=store.getString(STR.Preference.TestMethodGen.DELIMITER);
  String argsPrefix=store.getString(STR.Preference.TestMethodGen.ARGS_PREFIX);
  String argsDelimiter=store.getString(STR.Preference.TestMethodGen.ARGS_DELIMITER);
  String returnPrefix=store.getString(STR.Preference.TestMethodGen.RETURN_PREFIX);
  String returnDelimiter=store.getString(STR.Preference.TestMethodGen.RETURN_DELIMITER);
  if (enabled) {
    InputStream is=null;
    InputStreamReader isr=null;
    BufferedReader br=null;
    try {
      is=javaFile.getContents();
      UniversalDetector detector=new UniversalDetector(null);
      byte[] buf=new byte[4096];
      int nread;
      while ((nread=is.read(buf)) > 0 && !detector.isDone())       detector.handleData(buf,0,nread);
      detector.dataEnd();
      String encoding=detector.getDetectedCharset();
      if (encoding == null)       encoding=Charset.defaultCharset().name();
      is=javaFile.getContents();
      isr=new InputStreamReader(is,encoding);
      br=new BufferedReader(isr);
      StringBuffer tmpsb=new StringBuffer();
      String line=null;
      while ((line=br.readLine()) != null)       tmpsb.append(line + "String_Node_Str");
      String allSrc=tmpsb.toString();
      String[] publics=allSrc.split("String_Node_Str");
      for (      String publicsEach : publics) {
        publicsEach=publicsEach.replaceAll("String_Node_Str" + STR.COMMA,STR.COMMA).replaceAll(STR.COMMA + "String_Node_Str",STR.COMMA);
        publicsEach=publicsEach.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
        if (publicsEach.matches(RXP_SEARCH_METHOD)) {
          Matcher matcher=PAT_SEARCH_GROUP_METHOD.matcher(publicsEach);
          if (matcher.find()) {
            GeneratingMethodInfo each=new GeneratingMethodInfo();
            if (enabledNotBlankMethods || enabledReturn) {
              each.returnTypeName=getType(matcher.group(1));
              each.returnTypeNameInMethodName=getTypeAvailableInMethodName(each.returnTypeName);
            }
            each.methodName=matcher.group(2);
            String args=matcher.group(3);
            String[] argArr=args.split("String_Node_Str");
            if (enabledNotBlankMethods || enabledArgs) {
              int argArrLen=argArr.length;
              for (int i=0; i < argArrLen; i++) {
                each.argTypeNames.add(getType(argArr[i]));
                each.argTypeNamesInMethodName.add(getTypeAvailableInMethodName(argArr[i]));
              }
            }
            if (enableExcludesAccessors) {
              String fieldName=null;
              String fieldType=null;
              if (each.methodName.matches("String_Node_Str")) {
                fieldName=each.methodName.substring(3);
                fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
                fieldType=each.argTypeNames.get(0);
              }
 else               if (each.methodName.matches("String_Node_Str")) {
                fieldName=each.methodName.substring(3);
                fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
                fieldType=each.returnTypeName;
              }
 else               if (each.methodName.matches("String_Node_Str")) {
                fieldName=each.methodName.substring(2);
                fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
                fieldType=each.returnTypeName;
              }
              if (fieldName != null) {
                String searchRegexp="String_Node_Str" + fieldType + "String_Node_Str"+ fieldName+ "String_Node_Str";
                if (allSrc.matches(searchRegexp))                 continue;
              }
            }
            each.testMethodName="String_Node_Str" + each.methodName;
            if (enabledArgs) {
              each.testMethodName+=delimiter + argsPrefix;
              if (each.argTypeNames.size() == 0)               each.testMethodName+=argsDelimiter;
              for (              String argType : each.argTypeNamesInMethodName)               each.testMethodName+=argsDelimiter + argType;
            }
            if (enabledReturn)             each.testMethodName+=delimiter + returnPrefix + returnDelimiter+ each.returnTypeNameInMethodName;
            if (publicsEach.matches(RXP_SEARCH_STATIC_METHOD))             each.isStatic=true;
            testMethods.add(each);
          }
        }
      }
      if (enabledNotBlankMethods) {
        if (testMethods.size() <= 0 || testMethods.get(0) == null)         testMethods.add(new GeneratingMethodInfo());
        String[] importStartLines=allSrc.split("String_Node_Str");
        for (        String importStartLine : importStartLines) {
          if (!importStartLine.matches("String_Node_Str")) {
            String importedPackage=importStartLine.split("String_Node_Str")[0];
            testMethods.get(0).importList.add(importedPackage);
          }
        }
      }
    }
  finally {
      FileResourceUtil.close(br);
      FileResourceUtil.close(isr);
      FileResourceUtil.close(is);
    }
  }
  return testMethods;
}

Fixed version (ground truth):
public static List<GeneratingMethodInfo> getTestMethodsFromTarget(IFile javaFile) throws Exception {
  List<GeneratingMethodInfo> testMethods=new ArrayList<GeneratingMethodInfo>();
  IPreferenceStore store=Activator.getDefault().getPreferenceStore();
  boolean enabled=store.getBoolean(STR.Preference.TestMethodGen.ENABLE);
  boolean enabledArgs=store.getBoolean(STR.Preference.TestMethodGen.ARGS);
  boolean enabledReturn=store.getBoolean(STR.Preference.TestMethodGen.RETURN);
  boolean enabledNotBlankMethods=store.getBoolean(STR.Preference.TestMethodGen.METHOD_SAMPLE_IMPLEMENTATION);
  boolean enableExcludesAccessors=store.getBoolean(STR.Preference.TestMethodGen.EXLCUDES_ACCESSORS);
  String delimiter=store.getString(STR.Preference.TestMethodGen.DELIMITER);
  String argsPrefix=store.getString(STR.Preference.TestMethodGen.ARGS_PREFIX);
  String argsDelimiter=store.getString(STR.Preference.TestMethodGen.ARGS_DELIMITER);
  String returnPrefix=store.getString(STR.Preference.TestMethodGen.RETURN_PREFIX);
  String returnDelimiter=store.getString(STR.Preference.TestMethodGen.RETURN_DELIMITER);
  if (enabled) {
    InputStream is=null;
    InputStreamReader isr=null;
    BufferedReader br=null;
    try {
      String encoding=FileResourceUtil.detectEncoding(javaFile);
      is=javaFile.getContents();
      isr=new InputStreamReader(is,encoding);
      br=new BufferedReader(isr);
      StringBuffer tmpsb=new StringBuffer();
      String line=null;
      while ((line=br.readLine()) != null)       tmpsb.append(line + "String_Node_Str");
      String allSrc=tmpsb.toString();
      String[] publics=allSrc.split("String_Node_Str");
      for (      String publicsEach : publics) {
        publicsEach=publicsEach.replaceAll("String_Node_Str" + STR.COMMA,STR.COMMA).replaceAll(STR.COMMA + "String_Node_Str",STR.COMMA);
        publicsEach=publicsEach.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
        if (publicsEach.matches(RXP_SEARCH_METHOD)) {
          Matcher matcher=PAT_SEARCH_GROUP_METHOD.matcher(publicsEach);
          if (matcher.find()) {
            GeneratingMethodInfo each=new GeneratingMethodInfo();
            if (enabledNotBlankMethods || enabledReturn) {
              each.returnTypeName=getType(matcher.group(1));
              each.returnTypeNameInMethodName=getTypeAvailableInMethodName(each.returnTypeName);
            }
            each.methodName=matcher.group(2);
            String args=matcher.group(3);
            String[] argArr=args.split("String_Node_Str");
            if (enabledNotBlankMethods || enabledArgs) {
              int argArrLen=argArr.length;
              for (int i=0; i < argArrLen; i++) {
                each.argTypeNames.add(getType(argArr[i]));
                each.argTypeNamesInMethodName.add(getTypeAvailableInMethodName(argArr[i]));
              }
            }
            if (enableExcludesAccessors) {
              String fieldName=null;
              String fieldType=null;
              if (each.methodName.matches("String_Node_Str")) {
                fieldName=each.methodName.substring(3);
                fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
                fieldType=each.argTypeNames.get(0);
              }
 else               if (each.methodName.matches("String_Node_Str")) {
                fieldName=each.methodName.substring(3);
                fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
                fieldType=each.returnTypeName;
              }
 else               if (each.methodName.matches("String_Node_Str")) {
                fieldName=each.methodName.substring(2);
                fieldName=fieldName.substring(0,1).toLowerCase() + fieldName.substring(1);
                fieldType=each.returnTypeName;
              }
              if (fieldName != null) {
                String searchRegexp="String_Node_Str" + fieldType + "String_Node_Str"+ fieldName+ "String_Node_Str";
                if (allSrc.matches(searchRegexp))                 continue;
              }
            }
            each.testMethodName="String_Node_Str" + each.methodName;
            if (enabledArgs) {
              each.testMethodName+=delimiter + argsPrefix;
              if (each.argTypeNames.size() == 0)               each.testMethodName+=argsDelimiter;
              for (              String argType : each.argTypeNamesInMethodName)               each.testMethodName+=argsDelimiter + argType;
            }
            if (enabledReturn)             each.testMethodName+=delimiter + returnPrefix + returnDelimiter+ each.returnTypeNameInMethodName;
            if (publicsEach.matches(RXP_SEARCH_STATIC_METHOD))             each.isStatic=true;
            testMethods.add(each);
          }
        }
      }
      if (enabledNotBlankMethods) {
        if (testMethods.size() <= 0 || testMethods.get(0) == null)         testMethods.add(new GeneratingMethodInfo());
        String[] importStartLines=allSrc.split("String_Node_Str");
        for (        String importStartLine : importStartLines) {
          if (!importStartLine.matches("String_Node_Str")) {
            String importedPackage=importStartLine.split("String_Node_Str")[0];
            testMethods.get(0).importList.add(importedPackage);
          }
        }
      }
    }
  finally {
      FileResourceUtil.close(br);
      FileResourceUtil.close(isr);
      FileResourceUtil.close(is);
    }
  }
  return testMethods;
}