Program: 11567
Project: 11567
Buggy source:
/** 
 * Called by the framework in order to compute the stack of tiles for the given target bands. <p>The default implementation throws a runtime exception with the message "not implemented".</p>
 * @param targetTiles     The current tiles to be computed for each target band.
 * @param targetRectangle The area in pixel coordinates to be computed (same for all rasters in <code>targetRasters</code>).
 * @param pm              A progress monitor which should be used to determine computation cancelation requests.
 * @throws org.esa.beam.framework.gpf.OperatorException if an error occurs during computation of the target rasters.
 */
@Override public void computeTileStack(Map<Band,Tile> targetTiles,Rectangle targetRectangle,ProgressMonitor pm) throws OperatorException {
  try {
    final List<Product> validProducts=new ArrayList<Product>(sourceProduct.length);
    for (    final Product srcProduct : selectedProducts) {
      final Rectangle srcRect=srcRectMap.get(srcProduct);
      if (srcRect == null || !srcRect.intersects(targetRectangle)) {
        continue;
      }
      validProducts.add(srcProduct);
    }
    if (validProducts.isEmpty()) {
      return;
    }
    final GeoPos geoPos=new GeoPos();
    final PixelPos pixelPos=new PixelPos();
    final int minX=targetRectangle.x;
    final int minY=targetRectangle.y;
    final int maxX=targetRectangle.x + targetRectangle.width - 1;
    final int maxY=targetRectangle.y + targetRectangle.height - 1;
    final TileGeoreferencing tileGeoRef=new TileGeoreferencing(targetProduct,minX,minY,maxX - minX,maxY - minY);
    final List<PixelPos[]> srcPixelCoords=new ArrayList<PixelPos[]>(validProducts.size());
    final int numPixelPos=targetRectangle.width * targetRectangle.height;
    for (    Product validProduct : validProducts) {
      srcPixelCoords.add(new PixelPos[numPixelPos]);
    }
    int coordIndex=0;
    int prodIndex;
    for (int y=minY; y <= maxY; ++y) {
      for (int x=minX; x <= maxX; ++x) {
        tileGeoRef.getGeoPos(x,y,geoPos);
        prodIndex=0;
        for (        final Product srcProduct : validProducts) {
          srcProduct.getGeoCoding().getPixelPos(geoPos,pixelPos);
          if (pixelPos.x >= feather && pixelPos.y >= feather && pixelPos.x < srcProduct.getSceneRasterWidth() - feather && pixelPos.y < srcProduct.getSceneRasterHeight() - feather) {
            srcPixelCoords.get(prodIndex)[coordIndex]=new PixelPos(pixelPos.x,pixelPos.y);
          }
 else {
            srcPixelCoords.get(prodIndex)[coordIndex]=null;
          }
          ++prodIndex;
        }
        ++coordIndex;
      }
    }
    final Resampling resampling=ResamplingFactory.createResampling(resamplingMethod);
    if (gradientDomainMosaic) {
      performGradientDomainMosaic(targetTiles,targetRectangle,srcPixelCoords,validProducts,resampling,pm);
      return;
    }
    final List<SourceData> validSourceData=new ArrayList<SourceData>(validProducts.size());
    for (    final Map.Entry<Band,Tile> bandTileEntry : targetTiles.entrySet()) {
      final String trgBandName=bandTileEntry.getKey().getName();
      validSourceData.clear();
      prodIndex=0;
      for (      final Product srcProduct : validProducts) {
        final Band srcBand=srcProduct.getBand(trgBandName);
        if (srcBand == null) {
          continue;
        }
        final PixelPos[] pixPos=srcPixelCoords.get(prodIndex);
        final Rectangle sourceRectangle=getBoundingBox(pixPos,feather,feather,srcProduct.getSceneRasterWidth() - feather,srcProduct.getSceneRasterHeight() - feather,4);
        if (sourceRectangle != null) {
          double min=0, max=0, mean=0, std=0;
          if (normalizeByMean) {
            try {
              final Stx stats=srcBand.getStx(true,ProgressMonitor.NULL);
              mean=stats.getMean();
              min=stats.getMin();
              max=stats.getMax();
              std=stats.getStandardDeviation();
            }
 catch (            Throwable e) {
              normalizeByMean=false;
            }
          }
          final Tile srcTile=getSourceTile(srcBand,sourceRectangle);
          if (srcTile != null) {
            validSourceData.add(new SourceData(srcTile,pixPos,resampling,min,max,mean,std));
          }
        }
        ++prodIndex;
      }
      if (!validSourceData.isEmpty()) {
        collocateSourceBand(validSourceData,resampling,bandTileEntry.getValue());
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
 finally {
    pm.done();
  }
}

Fixed version (ground truth):
/** 
 * Called by the framework in order to compute the stack of tiles for the given target bands. <p>The default implementation throws a runtime exception with the message "not implemented".</p>
 * @param targetTiles     The current tiles to be computed for each target band.
 * @param targetRectangle The area in pixel coordinates to be computed (same for all rasters in <code>targetRasters</code>).
 * @param pm              A progress monitor which should be used to determine computation cancelation requests.
 * @throws org.esa.beam.framework.gpf.OperatorException if an error occurs during computation of the target rasters.
 */
@Override public void computeTileStack(Map<Band,Tile> targetTiles,Rectangle targetRectangle,ProgressMonitor pm) throws OperatorException {
  try {
    final List<Product> validProducts=new ArrayList<Product>(sourceProduct.length);
    for (    final Product srcProduct : selectedProducts) {
      final Rectangle srcRect=srcRectMap.get(srcProduct);
      if (srcRect == null || !srcRect.intersects(targetRectangle)) {
        continue;
      }
      validProducts.add(srcProduct);
    }
    if (validProducts.isEmpty()) {
      return;
    }
    final GeoPos geoPos=new GeoPos();
    final PixelPos pixelPos=new PixelPos();
    final int minX=targetRectangle.x;
    final int minY=targetRectangle.y;
    final int maxX=targetRectangle.x + targetRectangle.width - 1;
    final int maxY=targetRectangle.y + targetRectangle.height - 1;
    final TileGeoreferencing tileGeoRef=new TileGeoreferencing(targetProduct,minX,minY,maxX - minX + 1,maxY - minY + 1);
    final List<PixelPos[]> srcPixelCoords=new ArrayList<PixelPos[]>(validProducts.size());
    final int numPixelPos=targetRectangle.width * targetRectangle.height;
    for (    Product validProduct : validProducts) {
      srcPixelCoords.add(new PixelPos[numPixelPos]);
    }
    int coordIndex=0;
    int prodIndex;
    for (int y=minY; y <= maxY; ++y) {
      for (int x=minX; x <= maxX; ++x) {
        tileGeoRef.getGeoPos(x,y,geoPos);
        prodIndex=0;
        for (        final Product srcProduct : validProducts) {
          srcProduct.getGeoCoding().getPixelPos(geoPos,pixelPos);
          if (pixelPos.x >= feather && pixelPos.y >= feather && pixelPos.x < srcProduct.getSceneRasterWidth() - feather && pixelPos.y < srcProduct.getSceneRasterHeight() - feather) {
            srcPixelCoords.get(prodIndex)[coordIndex]=new PixelPos(pixelPos.x,pixelPos.y);
          }
 else {
            srcPixelCoords.get(prodIndex)[coordIndex]=null;
          }
          ++prodIndex;
        }
        ++coordIndex;
      }
    }
    final Resampling resampling=ResamplingFactory.createResampling(resamplingMethod);
    if (gradientDomainMosaic) {
      performGradientDomainMosaic(targetTiles,targetRectangle,srcPixelCoords,validProducts,resampling,pm);
      return;
    }
    final List<SourceData> validSourceData=new ArrayList<SourceData>(validProducts.size());
    for (    final Map.Entry<Band,Tile> bandTileEntry : targetTiles.entrySet()) {
      final String trgBandName=bandTileEntry.getKey().getName();
      validSourceData.clear();
      prodIndex=0;
      for (      final Product srcProduct : validProducts) {
        final Band srcBand=srcProduct.getBand(trgBandName);
        if (srcBand == null) {
          continue;
        }
        final PixelPos[] pixPos=srcPixelCoords.get(prodIndex);
        final Rectangle sourceRectangle=getBoundingBox(pixPos,feather,feather,srcProduct.getSceneRasterWidth() - feather,srcProduct.getSceneRasterHeight() - feather,4);
        if (sourceRectangle != null) {
          double min=0, max=0, mean=0, std=0;
          if (normalizeByMean) {
            try {
              final Stx stats=srcBand.getStx(true,ProgressMonitor.NULL);
              mean=stats.getMean();
              min=stats.getMin();
              max=stats.getMax();
              std=stats.getStandardDeviation();
            }
 catch (            Throwable e) {
              normalizeByMean=false;
            }
          }
          final Tile srcTile=getSourceTile(srcBand,sourceRectangle);
          if (srcTile != null) {
            validSourceData.add(new SourceData(srcTile,pixPos,resampling,min,max,mean,std));
          }
        }
        ++prodIndex;
      }
      if (!validSourceData.isEmpty()) {
        collocateSourceBand(validSourceData,resampling,bandTileEntry.getValue());
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
 finally {
    pm.done();
  }
}