Program: 12068
Project: 12068
Buggy source:
/** 
 * Get the information on the methods.
 * @param javaFile
 * @return the information on the methods
 * @throws Exception
 */
public static ClassInfo getMethodNamesAlreadyExists(IFile javaFile) throws Exception {
  ClassInfo classInfo=new ClassInfo();
  List<MethodInfo> methodStringInfos=new ArrayList<MethodInfo>();
  boolean enabled=Activator.getDefault().getPreferenceStore().getBoolean(Preference.TestMethodGen.ENABLE);
  boolean enabledNotBlankMethods=Activator.getDefault().getPreferenceStore().getBoolean(Preference.TestMethodGen.METHOD_SAMPLE_IMPLEMENTATION);
  if (enabled) {
    InputStream is=null;
    InputStreamReader isr=null;
    BufferedReader br=null;
    try {
      is=javaFile.getContents();
      String encoding=FileResourceUtil.detectEncoding(javaFile);
      is=javaFile.getContents();
      isr=new InputStreamReader(is,encoding);
      br=new BufferedReader(isr);
      StringBuilder tmpsb=new StringBuilder();
      String line=null;
      while ((line=br.readLine()) != null)       tmpsb.append(line + "String_Node_Str");
      String targetClassSourceStr=tmpsb.toString();
      String[] targets=targetClassSourceStr.split("String_Node_Str");
      for (      String target : targets) {
        target=target.replaceAll("String_Node_Str" + STR.COMMA,STR.COMMA).replaceAll(STR.COMMA + "String_Node_Str",STR.COMMA);
        target=target.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
        if (target.matches(RXP_SEARCH_METHOD)) {
          Matcher matcher=PAT_SEARCH_GROUP_METHOD.matcher(target);
          if (matcher.find()) {
            MethodInfo each=new MethodInfo();
            each.returnType.name=getType(matcher.group(1));
            each.returnType.nameInMethodName=getTypeAvailableInMethodName(matcher.group(1));
            each.methodName=matcher.group(2);
            each.testMethodName=each.methodName;
            String args=matcher.group(3);
            String[] argArr=args.split("String_Node_Str");
            int argArrLen=argArr.length;
            for (int i=0; i < argArrLen; i++) {
              ArgType argType=new ArgType();
              argType.name=getType(argArr[i]);
              argType.nameInMethodName=getTypeAvailableInMethodName(argArr[i]);
              each.argTypes.add(argType);
            }
            methodStringInfos.add(each);
          }
        }
      }
      if (enabledNotBlankMethods) {
        if (methodStringInfos.size() <= 0 || methodStringInfos.get(0) == null)         methodStringInfos.add(new MethodInfo());
        String[] importStartLines=targetClassSourceStr.split("String_Node_Str");
        for (        String importStartLine : importStartLines) {
          if (!importStartLine.matches("String_Node_Str")) {
            String importedPackage=importStartLine.split("String_Node_Str")[0];
            classInfo.importList.add(importedPackage);
          }
        }
      }
    }
  finally {
      FileResourceUtil.close(br);
      FileResourceUtil.close(isr);
      FileResourceUtil.close(is);
    }
  }
  classInfo.methods=methodStringInfos;
  return classInfo;
}

Fixed version (ground truth):
/** 
 * Get the information on the methods.
 * @param javaFile
 * @return the information on the methods
 * @throws Exception
 */
public static ClassInfo getMethodNamesAlreadyExists(IFile javaFile) throws Exception {
  ClassInfo classInfo=new ClassInfo();
  List<MethodInfo> methodStringInfos=new ArrayList<MethodInfo>();
  boolean enabled=Activator.getDefault().getPreferenceStore().getBoolean(Preference.TestMethodGen.ENABLE);
  boolean enabledNotBlankMethods=Activator.getDefault().getPreferenceStore().getBoolean(Preference.TestMethodGen.METHOD_SAMPLE_IMPL);
  if (enabled) {
    InputStream is=null;
    InputStreamReader isr=null;
    BufferedReader br=null;
    try {
      is=javaFile.getContents();
      String encoding=FileResourceUtil.detectEncoding(javaFile);
      is=javaFile.getContents();
      isr=new InputStreamReader(is,encoding);
      br=new BufferedReader(isr);
      StringBuilder tmpsb=new StringBuilder();
      String line=null;
      while ((line=br.readLine()) != null)       tmpsb.append(line + "String_Node_Str");
      String targetClassSourceStr=tmpsb.toString();
      String[] targets=targetClassSourceStr.split("String_Node_Str");
      for (      String target : targets) {
        target=target.replaceAll("String_Node_Str" + STR.COMMA,STR.COMMA).replaceAll(STR.COMMA + "String_Node_Str",STR.COMMA);
        target=target.replaceAll("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str");
        if (target.matches(RXP_SEARCH_METHOD)) {
          Matcher matcher=PAT_SEARCH_GROUP_METHOD.matcher(target);
          if (matcher.find()) {
            MethodInfo each=new MethodInfo();
            each.returnType.name=getType(matcher.group(1));
            each.returnType.nameInMethodName=getTypeAvailableInMethodName(matcher.group(1));
            each.methodName=matcher.group(2);
            each.testMethodName=each.methodName;
            String args=matcher.group(3);
            String[] argArr=args.split("String_Node_Str");
            int argArrLen=argArr.length;
            for (int i=0; i < argArrLen; i++) {
              ArgType argType=new ArgType();
              argType.name=getType(argArr[i]);
              argType.nameInMethodName=getTypeAvailableInMethodName(argArr[i]);
              each.argTypes.add(argType);
            }
            methodStringInfos.add(each);
          }
        }
      }
      if (enabledNotBlankMethods) {
        if (methodStringInfos.size() <= 0 || methodStringInfos.get(0) == null)         methodStringInfos.add(new MethodInfo());
        String[] importStartLines=targetClassSourceStr.split("String_Node_Str");
        for (        String importStartLine : importStartLines) {
          if (!importStartLine.matches("String_Node_Str")) {
            String importedPackage=importStartLine.split("String_Node_Str")[0];
            classInfo.importList.add(importedPackage);
          }
        }
      }
    }
  finally {
      FileResourceUtil.close(br);
      FileResourceUtil.close(isr);
      FileResourceUtil.close(is);
    }
  }
  classInfo.methods=methodStringInfos;
  return classInfo;
}