Program: 11560
Project: 11560
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;
    int tOffset, sOffset;
    final int maxy=ty0 + th;
    final int maxx=tx0 + tw;
    if (nRgLooks == 1 && nAzLooks == 1) {
      if (isComplex) {
        for (int ty=ty0; ty < maxy; ty++) {
          tOffset=trgIndex.calculateStride(ty);
          sOffset=srcIndex.calculateStride(ty);
          for (int tx=tx0; tx < maxx; tx++) {
            final int sIndex=tx - sOffset;
            final double i=srcData1.getElemDoubleAt(sIndex);
            final double q=srcData2.getElemDoubleAt(sIndex);
            trgData.setElemDoubleAt(tx - tOffset,i * i + q * q);
          }
        }
      }
 else {
        targetTile.setRawSamples(getSourceTile(sourceBand1,targetTile.getRectangle()).getRawSamples());
      }
    }
 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 synchronized 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;
    int offset;
    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++) {
          offset=trgIndex.calculateStride(ty);
          for (int tx=tx0; tx < maxx; tx++) {
            final int index=tx - offset;
            final double i=srcData1.getElemDoubleAt(index);
            if (srcData2 != null) {
              final double q=srcData2.getElemDoubleAt(index);
              trgData.setElemDoubleAt(index,i * i + q * q);
            }
 else {
              trgData.setElemDoubleAt(index,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();
  }
}