Program: 11156
Project: 11156
Buggy source:
private void openDataset(File file){
  fileOpen=file != null;
  if (!fileOpen) {
    infoText.setText("String_Node_Str");
    gdalFileField.setText("String_Node_Str");
    mapnikFileField.setText("String_Node_Str");
    previewCanvas.setIcon(null);
    bandCount=0;
    dataset=null;
    sector=null;
    mapFile=null;
  }
 else {
    try {
      gdalFileField.setText(file.getAbsolutePath());
      mapnikFileField.setText(file.getAbsolutePath());
      this.mapFile=file;
      if (gdalRadio.isSelected()) {
        final Dataset dataset=GDALUtil.open(file);
        final Sector sector=GDALUtil.getSector(dataset);
        this.sector=sector;
        this.dataset=dataset;
        final int width=dataset.getRasterXSize();
        final int height=dataset.getRasterYSize();
        if (sector.getMinLongitude() == 0 && sector.getMinLatitude() == 0 && sector.getMaxLongitude() == width && sector.getMaxLatitude() == height) {
          throw new TilerException("String_Node_Str" + file + "String_Node_Str");
        }
        if (sector.getMinLatitude() < -90 || sector.getMaxLatitude() > 90 || sector.getMinLongitude() < -180 || sector.getMaxLongitude() > 180) {
          throw new TilerException("String_Node_Str" + sector + "String_Node_Str");
        }
        bandCount=dataset.getRasterCount();
        if (bandCount == 0) {
          throw new TilerException("String_Node_Str");
        }
        String projection=dataset.GetProjection();
        SpatialReference spatialReference=(projection == null || projection.length() == 0 || !GDALUtil.isProjectionsSupported()) ? null : new SpatialReference(projection);
        String[] dataTypes=new String[bandCount];
        int[] dataTypeSizes=new int[bandCount];
        Double[] nodata=new Double[bandCount];
        double[] min=new double[bandCount];
        double[] max=new double[bandCount];
        for (int i=0; i < bandCount; i++) {
          Band band=dataset.GetRasterBand(i + 1);
          int dataType=band.getDataType();
          dataTypes[i]=gdal.GetDataTypeName(dataType);
          dataTypeSizes[i]=gdal.GetDataTypeSize(dataType);
          Double[] nodataValue=new Double[1];
          band.GetNoDataValue(nodataValue);
          nodata[i]=nodataValue[0];
          double[] minmax=new double[2];
          band.ComputeRasterMinMax(minmax,1);
          min[i]=minmax[0];
          max[i]=minmax[1];
        }
        StringLineBuilder info=new StringLineBuilder();
        info.appendLine("String_Node_Str");
        info.appendLine("String_Node_Str" + width + "String_Node_Str"+ height);
        info.appendLine("String_Node_Str" + (sector.getDeltaLongitude() / width) + "String_Node_Str"+ (sector.getDeltaLatitude() / height));
        info.appendLine("String_Node_Str" + sector.getMinLongitude() + "String_Node_Str"+ sector.getMinLatitude()+ "String_Node_Str");
        info.appendLine("String_Node_Str" + sector.getMaxLongitude() + "String_Node_Str"+ sector.getMaxLatitude()+ "String_Node_Str");
        info.appendLine("String_Node_Str" + bandCount);
        for (int i=0; i < bandCount; i++) {
          info.appendLine("String_Node_Str" + (i + 1) + "String_Node_Str");
          info.appendLine("String_Node_Str" + dataTypes[i] + "String_Node_Str"+ dataTypeSizes[i]+ "String_Node_Str");
          info.appendLine("String_Node_Str" + nodata[i]);
          info.appendLine("String_Node_Str" + min[i]);
          info.appendLine("String_Node_Str" + max[i]);
        }
        if (spatialReference != null) {
          info.appendLine("String_Node_Str");
          info.appendLine(Util.fixNewlines(spatialReference.ExportToPrettyWkt()));
        }
        String text=info.toString(true);
        infoText.setText(text);
        infoText.select(0,0);
        Thread thread=new Thread(new Runnable(){
          public void run(){
            logger.fine("String_Node_Str");
            try {
              int w=400;
              int h=w;
              if (width > height) {
                h=w * height / width;
              }
 else {
                w=h * width / height;
              }
              GDALTile tile=new GDALTile(dataset,w,h,sector.getMinLatitude(),sector.getMinLongitude(),sector.getMaxLatitude(),sector.getMaxLongitude());
              tile=tile.convertToType(gdalconst.GDT_Byte);
              BufferedImage image=tile.getAsImage();
              ImageIcon icon=new ImageIcon(image);
              previewCanvas.setIcon(icon);
              logger.fine("String_Node_Str");
            }
 catch (            Exception e) {
              logger.warning(e.getMessage());
            }
          }
        }
);
        thread.setDaemon(true);
        thread.start();
      }
 else {
        infoText.setText("String_Node_Str");
        this.bandCount=0;
        Sector sect=MapnikUtil.getSector(mapFile);
        if (sect == null) {
          sect=Sector.FULL_SPHERE;
          logger.warning("String_Node_Str");
        }
        this.sector=sect;
        minLatitudeField.setValue(sect.getMinLatitude());
        minLongitudeField.setValue(sect.getMinLongitude());
        maxLatitudeField.setValue(sect.getMaxLatitude());
        maxLongitudeField.setValue(sect.getMaxLongitude());
        Thread thread=new Thread(new Runnable(){
          public void run(){
            logger.fine("String_Node_Str");
            try {
              File dst=File.createTempFile("String_Node_Str","String_Node_Str");
              dst.deleteOnExit();
              MapnikUtil.tile(sector,previewCanvas.getWidth(),previewCanvas.getHeight(),mapFile,dst,logger);
              BufferedImage image=ImageIO.read(dst);
              ImageIcon icon=new ImageIcon(image);
              previewCanvas.setIcon(icon);
              logger.fine("String_Node_Str");
            }
 catch (            Exception e) {
              logger.warning(e.toString());
            }
          }
        }
);
        thread.setDaemon(true);
        thread.start();
      }
      logger.info("String_Node_Str" + file + "String_Node_Str");
    }
 catch (    Exception e) {
      logger.severe(e.getMessage());
      openDataset(null);
      return;
    }
  }
  bandCountChanged();
  tileTypeChanged();
  imageFormatChanged();
  recalculateTiles();
  frame.doLayout();
}

Fixed version (ground truth):
private void openDataset(File file){
  fileOpen=file != null;
  if (!fileOpen) {
    infoText.setText("String_Node_Str");
    gdalFileField.setText("String_Node_Str");
    mapnikFileField.setText("String_Node_Str");
    previewCanvas.setIcon(null);
    bandCount=0;
    dataset=null;
    sector=null;
    mapFile=null;
  }
 else {
    try {
      gdalFileField.setText(file.getAbsolutePath());
      mapnikFileField.setText(file.getAbsolutePath());
      this.mapFile=file;
      if (gdalRadio.isSelected()) {
        final Dataset dataset=GDALUtil.open(file);
        final Sector sector=GDALUtil.getSector(dataset);
        this.sector=sector;
        this.dataset=dataset;
        final int width=dataset.getRasterXSize();
        final int height=dataset.getRasterYSize();
        if (sector.getMinLongitude() == 0 && sector.getMinLatitude() == 0 && sector.getMaxLongitude() == width && sector.getMaxLatitude() == height) {
          throw new TilerException("String_Node_Str" + file + "String_Node_Str");
        }
        if (sector.getMinLatitude() < -180 || sector.getMaxLatitude() > 180 || sector.getMinLongitude() < -360 || sector.getMaxLongitude() > 360 || Math.abs(sector.getDeltaLatitude()) > 180 || Math.abs(sector.getDeltaLongitude()) > 360) {
          throw new TilerException("String_Node_Str" + sector + "String_Node_Str");
        }
        bandCount=dataset.getRasterCount();
        if (bandCount == 0) {
          throw new TilerException("String_Node_Str");
        }
        String projection=dataset.GetProjection();
        SpatialReference spatialReference=(projection == null || projection.length() == 0 || !GDALUtil.isProjectionsSupported()) ? null : new SpatialReference(projection);
        String[] dataTypes=new String[bandCount];
        int[] dataTypeSizes=new int[bandCount];
        Double[] nodata=new Double[bandCount];
        double[] min=new double[bandCount];
        double[] max=new double[bandCount];
        for (int i=0; i < bandCount; i++) {
          Band band=dataset.GetRasterBand(i + 1);
          int dataType=band.getDataType();
          dataTypes[i]=gdal.GetDataTypeName(dataType);
          dataTypeSizes[i]=gdal.GetDataTypeSize(dataType);
          Double[] nodataValue=new Double[1];
          band.GetNoDataValue(nodataValue);
          nodata[i]=nodataValue[0];
          double[] minmax=new double[2];
          band.ComputeRasterMinMax(minmax,1);
          min[i]=minmax[0];
          max[i]=minmax[1];
        }
        StringLineBuilder info=new StringLineBuilder();
        info.appendLine("String_Node_Str");
        info.appendLine("String_Node_Str" + width + "String_Node_Str"+ height);
        info.appendLine("String_Node_Str" + (sector.getDeltaLongitude() / width) + "String_Node_Str"+ (sector.getDeltaLatitude() / height));
        info.appendLine("String_Node_Str" + sector.getMinLongitude() + "String_Node_Str"+ sector.getMinLatitude()+ "String_Node_Str");
        info.appendLine("String_Node_Str" + sector.getMaxLongitude() + "String_Node_Str"+ sector.getMaxLatitude()+ "String_Node_Str");
        info.appendLine("String_Node_Str" + bandCount);
        for (int i=0; i < bandCount; i++) {
          info.appendLine("String_Node_Str" + (i + 1) + "String_Node_Str");
          info.appendLine("String_Node_Str" + dataTypes[i] + "String_Node_Str"+ dataTypeSizes[i]+ "String_Node_Str");
          info.appendLine("String_Node_Str" + nodata[i]);
          info.appendLine("String_Node_Str" + min[i]);
          info.appendLine("String_Node_Str" + max[i]);
        }
        if (spatialReference != null) {
          info.appendLine("String_Node_Str");
          info.appendLine(Util.fixNewlines(spatialReference.ExportToPrettyWkt()));
        }
        String text=info.toString(true);
        infoText.setText(text);
        infoText.select(0,0);
        Thread thread=new Thread(new Runnable(){
          public void run(){
            logger.fine("String_Node_Str");
            try {
              int w=400;
              int h=w;
              if (width > height) {
                h=w * height / width;
              }
 else {
                w=h * width / height;
              }
              GDALTile tile=new GDALTile(dataset,w,h,sector.getMinLatitude(),sector.getMinLongitude(),sector.getMaxLatitude(),sector.getMaxLongitude());
              tile=tile.convertToType(gdalconst.GDT_Byte);
              BufferedImage image=tile.getAsImage();
              ImageIcon icon=new ImageIcon(image);
              previewCanvas.setIcon(icon);
              logger.fine("String_Node_Str");
            }
 catch (            Exception e) {
              logger.warning(e.getMessage());
            }
          }
        }
);
        thread.setDaemon(true);
        thread.start();
      }
 else {
        infoText.setText("String_Node_Str");
        this.bandCount=0;
        Sector sect=MapnikUtil.getSector(mapFile);
        if (sect == null) {
          sect=Sector.FULL_SPHERE;
          logger.warning("String_Node_Str");
        }
        this.sector=sect;
        minLatitudeField.setValue(sect.getMinLatitude());
        minLongitudeField.setValue(sect.getMinLongitude());
        maxLatitudeField.setValue(sect.getMaxLatitude());
        maxLongitudeField.setValue(sect.getMaxLongitude());
        Thread thread=new Thread(new Runnable(){
          public void run(){
            logger.fine("String_Node_Str");
            try {
              File dst=File.createTempFile("String_Node_Str","String_Node_Str");
              dst.deleteOnExit();
              MapnikUtil.tile(sector,previewCanvas.getWidth(),previewCanvas.getHeight(),mapFile,dst,logger);
              BufferedImage image=ImageIO.read(dst);
              ImageIcon icon=new ImageIcon(image);
              previewCanvas.setIcon(icon);
              logger.fine("String_Node_Str");
            }
 catch (            Exception e) {
              logger.warning(e.toString());
            }
          }
        }
);
        thread.setDaemon(true);
        thread.start();
      }
      logger.info("String_Node_Str" + file + "String_Node_Str");
    }
 catch (    Exception e) {
      logger.severe(e.getMessage());
      openDataset(null);
      return;
    }
  }
  bandCountChanged();
  tileTypeChanged();
  imageFormatChanged();
  recalculateTiles();
  frame.doLayout();
}