Program: 140967
Project: 140967
Buggy source:
/** 
 * Render an image and write it to a file, while a progress dialog with a cancel button is displayed.
 * @param filePath file to write to.
 * @param scale The final image will be this many times larger than thegrid.
 */
private void exportContours(final String filePath,final String imageFormat,final int scale){
  String dialogTitle="String_Node_Str";
  SwingWorkerWithProgressIndicatorDialog worker;
  worker=new SwingWorkerWithProgressIndicatorDialog<Void>(this,dialogTitle,"String_Node_Str"){
    @Override public void done(){
      try {
        get();
        String worldFilePath=WorldFileExporter.constructPath(filePath);
        Grid grid=model.getFilteredGrid();
        double cellSize=grid.getCellSize() / scale;
        double west=grid.getWest() - cellSize / 2;
        double north=grid.getNorth() + cellSize / 2;
        WorldFileExporter.writeWorldFile(worldFilePath,cellSize,west,north);
        WKTProjectionFile.write(grid.getPrjFileContent(),filePath);
      }
 catch (      ExecutionException e) {
        new File(filePath).delete();
        String msg="String_Node_Str";
        String title="String_Node_Str";
        JOptionPane.showMessageDialog(getContentPane(),msg,title,JOptionPane.ERROR_MESSAGE);
      }
catch (      InterruptedException|CancellationException e) {
      }
catch (      IOException exc) {
        new File(filePath).delete();
      }
 finally {
        completeProgress();
      }
    }
    @Override protected Void doInBackground() throws Exception {
      start();
      IlluminatedContoursOperator op;
      boolean illuminated=(model.foregroundVisualization == ForegroundVisualization.ILLUMINATED_CONTOURS);
      op=model.setupIlluminatedContoursOperator(illuminated);
      int w=model.getFilteredGrid().getCols() * scale;
      int h=model.getFilteredGrid().getRows() * scale;
      BufferedImage image=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
      op.renderToImage(image,model.getFilteredGrid(),model.computeFilteredGradientGrid(),this);
      if (!isCancelled()) {
        setCancellable(false);
        setIndeterminate(true);
        File file=new File(filePath);
        setMessage("String_Node_Str" + file.getName() + "String_Node_Str");
        ImageIO.write(image,imageFormat,file);
      }
      return null;
    }
  }
;
  worker.setIndeterminate(false);
  worker.setMessage("String_Node_Str");
  worker.execute();
}

Fixed version (ground truth):
/** 
 * Render an image and write it to a file, while a progress dialog with a cancel button is displayed.
 * @param filePath file to write to.
 * @param scale The final image will be this many times larger than thegrid.
 */
private void exportContours(final String filePath,final String imageFormat,final int scale){
  String dialogTitle="String_Node_Str";
  SwingWorkerWithProgressIndicatorDialog worker;
  worker=new SwingWorkerWithProgressIndicatorDialog<Void>(this,dialogTitle,"String_Node_Str"){
    @Override public void done(){
      SwingUtilities.invokeLater(new Runnable(){
        @Override public void run(){
          completeProgress();
        }
      }
);
      if (isCancelled()) {
        return;
      }
      try {
        get();
        String worldFilePath=WorldFileExporter.constructPath(filePath);
        Grid grid=model.getFilteredGrid();
        double cellSize=grid.getCellSize() / scale;
        double west=grid.getWest() - cellSize / 2;
        double north=grid.getNorth() + cellSize / 2;
        WorldFileExporter.writeWorldFile(worldFilePath,cellSize,west,north);
        WKTProjectionFile.write(grid.getPrjFileContent(),filePath);
      }
 catch (      ExecutionException e) {
        new File(filePath).delete();
        String msg="String_Node_Str";
        String title="String_Node_Str";
        JOptionPane.showMessageDialog(getContentPane(),msg,title,JOptionPane.ERROR_MESSAGE);
      }
catch (      InterruptedException|CancellationException e) {
      }
catch (      IOException exc) {
        new File(filePath).delete();
      }
 finally {
        completeProgress();
      }
    }
    @Override protected Void doInBackground() throws Exception {
      start();
      IlluminatedContoursOperator op;
      boolean illuminated=(model.foregroundVisualization == ForegroundVisualization.ILLUMINATED_CONTOURS);
      op=model.setupIlluminatedContoursOperator(illuminated);
      int w=model.getFilteredGrid().getCols() * scale;
      int h=model.getFilteredGrid().getRows() * scale;
      BufferedImage image=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB);
      op.renderToImage(image,model.getFilteredGrid(),model.computeFilteredGradientGrid(),this);
      if (!isCancelled()) {
        setCancellable(false);
        setIndeterminate(true);
        File file=new File(filePath);
        setMessage("String_Node_Str" + file.getName() + "String_Node_Str");
        ImageIO.write(image,imageFormat,file);
      }
      return null;
    }
  }
;
  worker.setIndeterminate(false);
  worker.setMessage("String_Node_Str");
  worker.execute();
}