Program: 11537
Project: 11537
Buggy source:
/** 
 * Called by the framework in order to compute a tile for the given target band. <p>The default implementation throws a runtime exception with the message "not implemented".</p>
 * @param targetBand The target band.
 * @param targetTile The current tile associated with the target band to be computed.
 * @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 raster.
 */
@Override public void computeTile(Band targetBand,Tile targetTile,ProgressMonitor pm) throws OperatorException {
  final Rectangle targetTileRectangle=targetTile.getRectangle();
  final int tx0=targetTileRectangle.x;
  final int ty0=targetTileRectangle.y;
  final int tw=targetTileRectangle.width;
  final int th=targetTileRectangle.height;
  final int x0=tx0 * nRgLooks;
  final int y0=ty0 * nAzLooks;
  final int w=tw * nRgLooks;
  final int h=th * nAzLooks;
  final Rectangle sourceTileRectangle=new Rectangle(x0,y0,w,h);
  try {
    Tile sourceRaster1;
    Tile sourceRaster2=null;
    final String[] srcBandNames=targetBandNameToSourceBandName.get(targetBand.getName());
    Band sourceBand1;
    if (srcBandNames.length == 1) {
      sourceBand1=sourceProduct.getBand(srcBandNames[0]);
      sourceRaster1=getSourceTile(sourceBand1,sourceTileRectangle);
      if (sourceRaster1 == null) {
        throw new OperatorException("String_Node_Str");
      }
    }
 else {
      sourceBand1=sourceProduct.getBand(srcBandNames[0]);
      final Band sourceBand2=sourceProduct.getBand(srcBandNames[1]);
      sourceRaster1=getSourceTile(sourceBand1,sourceTileRectangle);
      sourceRaster2=getSourceTile(sourceBand2,sourceTileRectangle);
      if (sourceRaster1 == null || sourceRaster2 == null) {
        throw new OperatorException("String_Node_Str");
      }
    }
    final ProductData trgData=targetTile.getDataBuffer();
    final ProductData srcData1=sourceRaster1.getDataBuffer();
    final ProductData srcData2=sourceRaster2 != null ? sourceRaster2.getDataBuffer() : null;
    final TileIndex trgIndex=new TileIndex(targetTile);
    final TileIndex srcIndex=new TileIndex(sourceRaster1);
    final Unit.UnitType bandUnit=Unit.getUnitType(sourceBand1);
    final boolean isdB=bandUnit == Unit.UnitType.INTENSITY_DB || bandUnit == Unit.UnitType.AMPLITUDE_DB;
    final boolean isComplex=outputIntensity && (bandUnit == Unit.UnitType.REAL || bandUnit == Unit.UnitType.IMAGINARY);
    double meanValue;
    final int maxy=ty0 + th;
    final int maxx=tx0 + tw;
    if (nRgLooks == 1 && nAzLooks == 1) {
      if (!isComplex && targetTile.getDataBuffer().getType() == sourceRaster1.getDataBuffer().getType()) {
        targetTile.setRawSamples(sourceRaster1.getRawSamples());
      }
 else {
        for (int ty=ty0; ty < maxy; ty++) {
          trgIndex.calculateStride(ty);
          srcIndex.calculateStride(ty);
          for (int tx=tx0; tx < maxx; tx++) {
            final int index=srcIndex.getIndex(tx);
            final double i=srcData1.getElemDoubleAt(index);
            if (srcData2 != null) {
              final double q=srcData2.getElemDoubleAt(index);
              trgData.setElemDoubleAt(trgIndex.getIndex(tx),i * i + q * q);
            }
 else {
              trgData.setElemDoubleAt(trgIndex.getIndex(tx),i);
            }
          }
        }
      }
    }
 else {
      for (int ty=ty0; ty < maxy; ty++) {
        trgIndex.calculateStride(ty);
        for (int tx=tx0; tx < maxx; tx++) {
          meanValue=getMeanValue(tx,ty,srcData1,srcData2,srcIndex,nRgLooks,nAzLooks,isdB,isComplex);
          trgData.setElemDoubleAt(trgIndex.getIndex(tx),meanValue);
        }
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
 finally {
    pm.done();
  }
}

Fixed version (ground truth):
/** 
 * Called by the framework in order to compute a tile for the given target band. <p>The default implementation throws a runtime exception with the message "not implemented".</p>
 * @param targetBand The target band.
 * @param targetTile The current tile associated with the target band to be computed.
 * @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 raster.
 */
@Override public void computeTile(Band targetBand,Tile targetTile,ProgressMonitor pm) throws OperatorException {
  final Rectangle targetTileRectangle=targetTile.getRectangle();
  final int tx0=targetTileRectangle.x;
  final int ty0=targetTileRectangle.y;
  final int tw=targetTileRectangle.width;
  final int th=targetTileRectangle.height;
  final int x0=tx0 * nRgLooks;
  final int y0=ty0 * nAzLooks;
  final int w=tw * nRgLooks;
  final int h=th * nAzLooks;
  final Rectangle sourceTileRectangle=new Rectangle(x0,y0,w,h);
  try {
    Tile sourceRaster1;
    Tile sourceRaster2=null;
    final String[] srcBandNames=targetBandNameToSourceBandName.get(targetBand.getName());
    Band sourceBand1;
    if (srcBandNames.length == 1) {
      sourceBand1=sourceProduct.getBand(srcBandNames[0]);
      sourceRaster1=getSourceTile(sourceBand1,sourceTileRectangle);
      if (sourceRaster1 == null) {
        throw new OperatorException("String_Node_Str");
      }
    }
 else {
      sourceBand1=sourceProduct.getBand(srcBandNames[0]);
      final Band sourceBand2=sourceProduct.getBand(srcBandNames[1]);
      sourceRaster1=getSourceTile(sourceBand1,sourceTileRectangle);
      sourceRaster2=getSourceTile(sourceBand2,sourceTileRectangle);
      if (sourceRaster1 == null || sourceRaster2 == null) {
        throw new OperatorException("String_Node_Str");
      }
    }
    final ProductData trgData=targetTile.getDataBuffer();
    final ProductData srcData1=sourceRaster1.getDataBuffer();
    final ProductData srcData2=sourceRaster2 != null ? sourceRaster2.getDataBuffer() : null;
    final TileIndex trgIndex=new TileIndex(targetTile);
    final TileIndex srcIndex=new TileIndex(sourceRaster1);
    final Unit.UnitType bandUnit=Unit.getUnitType(sourceBand1);
    final boolean isdB=bandUnit == Unit.UnitType.INTENSITY_DB || bandUnit == Unit.UnitType.AMPLITUDE_DB;
    final boolean isComplex=outputIntensity && (bandUnit == Unit.UnitType.REAL || bandUnit == Unit.UnitType.IMAGINARY);
    double meanValue;
    final int maxy=ty0 + th;
    final int maxx=tx0 + tw;
    if (nRgLooks == 1 && nAzLooks == 1) {
      if (!isComplex && targetTile.getDataBuffer().getType() == sourceRaster1.getDataBuffer().getType()) {
        targetTile.setRawSamples(sourceRaster1.getRawSamples());
      }
 else {
        for (int ty=ty0; ty < maxy; ty++) {
          trgIndex.calculateStride(ty);
          srcIndex.calculateStride(ty);
          for (int tx=tx0; tx < maxx; tx++) {
            final int index=srcIndex.getIndex(tx);
            final double i=srcData1.getElemDoubleAt(index);
            if (srcData2 != null) {
              final double q=srcData2.getElemDoubleAt(index);
              trgData.setElemDoubleAt(trgIndex.getIndex(tx),i * i + q * q);
            }
 else {
              trgData.setElemDoubleAt(trgIndex.getIndex(tx),i);
            }
          }
        }
      }
    }
 else {
      for (int ty=ty0; ty < maxy; ty++) {
        trgIndex.calculateStride(ty);
        for (int tx=tx0; tx < maxx; tx++) {
          meanValue=getMeanValue(tx,ty,srcData1,srcData2,srcIndex,nRgLooks,nAzLooks,isdB,isComplex,isPolsar);
          trgData.setElemDoubleAt(trgIndex.getIndex(tx),meanValue);
        }
      }
    }
  }
 catch (  Throwable e) {
    OperatorUtils.catchOperatorException(getId(),e);
  }
 finally {
    pm.done();
  }
}