Program: 36280
Project: 36280
Buggy source:
public void print(PrintRequestAttributeSet attributes) throws PrinterException {
  PrintService psvc=getPrintService();
  if (psvc instanceof StreamPrintService) {
    spoolToService(psvc,attributes);
    return;
  }
  setAttributes(attributes);
  if (destinationAttr != null) {
    validateDestination(destinationAttr);
  }
  int firstPage=getFirstPage();
  int lastPage=getLastPage();
  if (lastPage == Pageable.UNKNOWN_NUMBER_OF_PAGES) {
    int totalPages=mDocument.getNumberOfPages();
    if (totalPages != Pageable.UNKNOWN_NUMBER_OF_PAGES) {
      lastPage=mDocument.getNumberOfPages() - 1;
    }
  }
  try {
synchronized (this) {
      performingPrinting=true;
      userCancelled=false;
    }
    PageRanges pr=(attributes == null) ? null : (PageRanges)attributes.get(PageRanges.class);
    int[][] prMembers=(pr == null) ? new int[0][0] : pr.getMembers();
    int loopi=0;
    do {
      if (EventQueue.isDispatchThread()) {
        onEventThread=true;
        printingLoop=AccessController.doPrivileged(new PrivilegedAction<SecondaryLoop>(){
          @Override public SecondaryLoop run(){
            return Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
          }
        }
);
        try {
          if (printLoop(false,firstPage,lastPage)) {
            printingLoop.enter();
          }
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else {
        onEventThread=false;
        try {
          printLoop(true,firstPage,lastPage);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
      if (++loopi < prMembers.length) {
        firstPage=prMembers[loopi][0] - 1;
        lastPage=prMembers[loopi][1] - 1;
      }
    }
 while (loopi < prMembers.length);
  }
  finally {
synchronized (this) {
      performingPrinting=false;
      notify();
    }
    if (printingLoop != null) {
      printingLoop.exit();
    }
  }
}

Fixed version (ground truth):
@Override public void print(PrintRequestAttributeSet attributes) throws PrinterException {
  PrintService psvc=getPrintService();
  if (psvc instanceof StreamPrintService) {
    spoolToService(psvc,attributes);
    return;
  }
  setAttributes(attributes);
  if (destinationAttr != null) {
    validateDestination(destinationAttr);
  }
  int firstPage=getFirstPage();
  int lastPage=getLastPage();
  if (lastPage == Pageable.UNKNOWN_NUMBER_OF_PAGES) {
    int totalPages=mDocument.getNumberOfPages();
    if (totalPages != Pageable.UNKNOWN_NUMBER_OF_PAGES) {
      lastPage=mDocument.getNumberOfPages() - 1;
    }
  }
  try {
synchronized (this) {
      performingPrinting=true;
      userCancelled=false;
    }
    PageRanges pr=(attributes == null) ? null : (PageRanges)attributes.get(PageRanges.class);
    int[][] prMembers=(pr == null) ? new int[0][0] : pr.getMembers();
    int loopi=0;
    do {
      if (EventQueue.isDispatchThread()) {
        onEventThread=true;
        printingLoop=AccessController.doPrivileged(new PrivilegedAction<SecondaryLoop>(){
          @Override public SecondaryLoop run(){
            return Toolkit.getDefaultToolkit().getSystemEventQueue().createSecondaryLoop();
          }
        }
);
        try {
          if (printLoop(false,firstPage,lastPage)) {
            printingLoop.enter();
          }
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
 else {
        onEventThread=false;
        try {
          printLoop(true,firstPage,lastPage);
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
      if (++loopi < prMembers.length) {
        firstPage=prMembers[loopi][0] - 1;
        lastPage=prMembers[loopi][1] - 1;
      }
    }
 while (loopi < prMembers.length);
  }
  finally {
synchronized (this) {
      performingPrinting=false;
      notify();
    }
    if (printingLoop != null) {
      printingLoop.exit();
    }
  }
}