Program: 72568
Project: 72568
Buggy source:
/** 
 * A test driver for the indexer. <p>Usage:</p> <pre> java -classpath $PTII doc.doclets.PtIndexer [-c] [target] </pre> <p>If called with no arguments, create the dictionary PtIndexer.ser The standard input is read and assumed to be file names.  Each file is read and the dictionary is updated with words and locations.  The location is determined by substituting "." for "/" in the file name.  </p> <p>Typically, the PtDoclet creates the dictionary, but this driver can be used for testing. To create the .xml file to be read:</p> <pre> cd $PTII/doc; make docs </pre> <p>To run the tool on the .xml files and create the dictionary again:</p> <pre> cd codeDoc find . -name "*.xml" | java -classpath $PTII doc.doclets.PtIndexer </pre> <p>If called with <code>-c</code> then use compression.</p> <p> If called with one argument that is not <code>-c</code>, then the argument is assumed to be a target and the collection of places where target is found is returned.</p>
 * @param args The arguments, if any
 * @exception IOException If thrown while reading the input files or dictionary.
 * @exception ClassNotFoundException If the file does not contain thedictionary class.
 */
public static void main(String args[]) throws IOException, ClassNotFoundException {
  String usage="String_Node_Str";
  String dictionaryFile="String_Node_Str";
  if (args.length > 2) {
    System.err.println(usage);
    return;
  }
  String target=null;
  if (args.length >= 1) {
    if (args[0].equals("String_Node_Str")) {
      _useCompression=true;
      if (args.length == 2) {
        target=args[1];
      }
    }
 else {
      target=args[0];
    }
  }
  if (_useCompression) {
    dictionaryFile="String_Node_Str";
  }
  PtIndexer ptIndexer=new PtIndexer();
  if (target == null) {
    BufferedReader stdin=null;
    BufferedReader fileInput=null;
    int numberOfFiles=0;
    int numberOfLines=0;
    try {
      stdin=new BufferedReader(new InputStreamReader(System.in));
      String fileName=null;
      String line=null;
      while ((fileName=stdin.readLine()) != null) {
        numberOfFiles++;
        try {
          fileInput=new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
          fileName=fileName.substring(0,fileName.lastIndexOf("String_Node_Str"));
          String className=fileName.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
          while ((line=fileInput.readLine()) != null) {
            numberOfLines++;
            ptIndexer.append(className,line);
          }
        }
  finally {
          if (fileInput != null) {
            fileInput.close();
          }
        }
      }
      System.out.println("String_Node_Str" + numberOfFiles + "String_Node_Str"+ numberOfLines+ "String_Node_Str");
    }
  finally {
      try {
        if (stdin != null) {
          stdin.close();
        }
      }
  finally {
        if (fileInput != null) {
          fileInput.close();
        }
      }
    }
    System.out.println(ptIndexer.statistics());
    ptIndexer.write(dictionaryFile);
  }
 else {
    ptIndexer.read(dictionaryFile);
    System.out.println(ptIndexer.search(target));
  }
}

Fixed version (ground truth):
/** 
 * A test driver for the indexer. <p>Usage:</p> <pre> java -classpath $PTII doc.doclets.PtIndexer [-c] [target] </pre> <p>If called with no arguments, create the dictionary PtIndexer.ser The standard input is read and assumed to be file names.  Each file is read and the dictionary is updated with words and locations.  The location is determined by substituting "." for "/" in the file name.  </p> <p>Typically, the PtDoclet creates the dictionary, but this driver can be used for testing. To create the .xml file to be read:</p> <pre> cd $PTII/doc; make docs </pre> <p>To run the tool on the .xml files and create the dictionary again:</p> <pre> cd codeDoc find . -name "*.xml" | java -classpath $PTII doc.doclets.PtIndexer </pre> <p>If called with <code>-c</code> then use compression.</p> <p> If called with one argument that is not <code>-c</code>, then the argument is assumed to be a target and the collection of places where target is found is returned.</p>
 * @param args The arguments, if any
 * @exception IOException If thrown while reading the input files or dictionary.
 * @exception ClassNotFoundException If the file does not contain thedictionary class.
 */
public static void main(String args[]) throws IOException, ClassNotFoundException {
  String usage="String_Node_Str";
  String dictionaryFile="String_Node_Str";
  if (args.length > 2) {
    System.err.println(usage);
    return;
  }
  String target=null;
  if (args.length >= 1) {
    if (args[0].equals("String_Node_Str")) {
      _useCompression=true;
      if (args.length == 2) {
        target=args[1];
      }
    }
 else {
      target=args[0];
    }
  }
  if (_useCompression) {
    dictionaryFile="String_Node_Str";
  }
  PtIndexer ptIndexer=new PtIndexer();
  if (target == null) {
    BufferedReader stdin=null;
    BufferedReader fileInput=null;
    int numberOfFiles=0;
    int numberOfLines=0;
    try {
      stdin=new BufferedReader(new InputStreamReader(System.in,java.nio.charset.Charset.defaultCharset()));
      String fileName=null;
      String line=null;
      while ((fileName=stdin.readLine()) != null) {
        numberOfFiles++;
        try {
          fileInput=new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
          fileName=fileName.substring(0,fileName.lastIndexOf("String_Node_Str"));
          String className=fileName.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str");
          while ((line=fileInput.readLine()) != null) {
            numberOfLines++;
            ptIndexer.append(className,line);
          }
        }
  finally {
          if (fileInput != null) {
            fileInput.close();
          }
        }
      }
      System.out.println("String_Node_Str" + numberOfFiles + "String_Node_Str"+ numberOfLines+ "String_Node_Str");
    }
  finally {
      try {
        if (stdin != null) {
          stdin.close();
        }
      }
  finally {
        if (fileInput != null) {
          fileInput.close();
        }
      }
    }
    System.out.println(ptIndexer.statistics());
    ptIndexer.write(dictionaryFile);
  }
 else {
    ptIndexer.read(dictionaryFile);
    System.out.println(ptIndexer.search(target));
  }
}