Program: 117099
Project: 117099
Buggy source:
/** 
 * Finds a printer in the PrintServices listing and returns it's respective PrintService.<p>  If a PrintService is supplied, the same PrintService is returned.  If an Object is supplied, it calls the "toString()" method and then does a standard name search.</p>
 * @param o The object holding the name of the printer to search for.
 * @return PrintService ps for RawPrint(ps, cmds)
 */
public static PrintService findPrinter(Object o){
  PrintService exact=null;
  PrintService begins=null;
  PrintService partial=null;
  String printerName;
  if (o == null) {
    return null;
  }
 else   if (o instanceof String) {
    printerName="String_Node_Str" + (String)o + "String_Node_Str";
  }
 else   if (o instanceof PrintService) {
    return (PrintService)o;
  }
 else {
    printerName="String_Node_Str" + o.toString() + "String_Node_Str";
  }
  getPrinterList();
  LogIt.log(Level.INFO,"String_Node_Str" + printers.length + "String_Node_Str");
  LogIt.log(Level.INFO,"String_Node_Str" + printerName);
  Pattern p1=Pattern.compile("String_Node_Str" + printerName + "String_Node_Str",Pattern.CASE_INSENSITIVE);
  Pattern p2=Pattern.compile("String_Node_Str" + printerName,Pattern.CASE_INSENSITIVE);
  Pattern p3=Pattern.compile(printerName,Pattern.CASE_INSENSITIVE);
  for (  PrintService ps : printers) {
    String sysPrinter=((PrinterName)ps.getAttribute(PrinterName.class)).getValue();
    Matcher m1=p1.matcher(sysPrinter);
    Matcher m2=p2.matcher(sysPrinter);
    Matcher m3=p3.matcher(sysPrinter);
    if (m1.find()) {
      exact=ps;
      LogIt.log("String_Node_Str" + sysPrinter);
    }
 else     if (m2.find()) {
      begins=ps;
      LogIt.log("String_Node_Str" + sysPrinter);
    }
 else     if (m3.find()) {
      partial=ps;
      LogIt.log("String_Node_Str" + sysPrinter);
    }
  }
  if (exact != null) {
    LogIt.log("String_Node_Str" + exact.getName());
    return exact;
  }
 else   if (begins != null) {
    LogIt.log("String_Node_Str" + begins.getName());
    return begins;
  }
 else   if (partial != null) {
    LogIt.log("String_Node_Str" + partial.getName());
    return partial;
  }
  LogIt.log(Level.WARNING,"String_Node_Str" + printerName);
  return null;
}

Fixed version (ground truth):
/** 
 * Finds a printer in the PrintServices listing and returns it's respective PrintService.<p>  If a PrintService is supplied, the same PrintService is returned.  If an Object is supplied, it calls the "toString()" method and then does a standard name search.</p>
 * @param printerNameObject The object holding the name of the printer to search for.
 * @return PrintService ps for RawPrint(ps, cmds)
 */
public static PrintService findPrinter(Object printerNameObject){
  PrintService exact=null;
  PrintService begins=null;
  PrintService partial=null;
  String printerName;
  if (printerNameObject == null) {
    return null;
  }
 else   if (printerNameObject instanceof String) {
    printerName="String_Node_Str" + printerNameObject + "String_Node_Str";
  }
 else   if (printerNameObject instanceof PrintService) {
    return (PrintService)printerNameObject;
  }
 else {
    printerName="String_Node_Str" + printerNameObject.toString() + "String_Node_Str";
  }
  getPrinterList();
  LogIt.log(Level.INFO,"String_Node_Str" + printers.length + "String_Node_Str");
  LogIt.log(Level.INFO,"String_Node_Str" + printerName);
  Pattern p1=Pattern.compile("String_Node_Str" + printerName + "String_Node_Str",Pattern.CASE_INSENSITIVE);
  Pattern p2=Pattern.compile("String_Node_Str" + printerName,Pattern.CASE_INSENSITIVE);
  Pattern p3=Pattern.compile(printerName,Pattern.CASE_INSENSITIVE);
  for (  PrintService ps : printers) {
    String sysPrinter=ps.getAttribute(PrinterName.class).getValue();
    Matcher m1=p1.matcher(sysPrinter);
    Matcher m2=p2.matcher(sysPrinter);
    Matcher m3=p3.matcher(sysPrinter);
    if (m1.find()) {
      exact=ps;
      LogIt.log("String_Node_Str" + sysPrinter);
    }
 else     if (m2.find()) {
      begins=ps;
      LogIt.log("String_Node_Str" + sysPrinter);
    }
 else     if (m3.find()) {
      partial=ps;
      LogIt.log("String_Node_Str" + sysPrinter);
    }
  }
  if (exact != null) {
    LogIt.log("String_Node_Str" + exact.getName());
    return exact;
  }
 else   if (begins != null) {
    LogIt.log("String_Node_Str" + begins.getName());
    return begins;
  }
 else   if (partial != null) {
    LogIt.log("String_Node_Str" + partial.getName());
    return partial;
  }
  LogIt.log(Level.WARNING,"String_Node_Str" + printerName);
  return null;
}