Program: 11578
Project: 11578
Buggy source:
private static void updateMetadata(final Product product,ProductSubsetDef subsetDef) throws IOException {
  try {
    final MetadataElement root=product.getMetadataRoot();
    if (root == null)     return;
    final MetadataElement absRoot=root.getElement("String_Node_Str");
    if (absRoot == null)     return;
    final String mission=absRoot.getAttributeString("String_Node_Str");
    boolean nearRangeOnLeft=true;
    if (mission.equals("String_Node_Str")) {
      final String pass=absRoot.getAttributeString("String_Node_Str");
      if (pass.contains("String_Node_Str")) {
        nearRangeOnLeft=false;
      }
    }
    final MetadataAttribute firstLineTime=absRoot.getAttribute("String_Node_Str");
    if (firstLineTime != null) {
      final ProductData.UTC startTime=product.getStartTime();
      if (startTime != null)       firstLineTime.getData().setElems(startTime.getArray());
    }
    final MetadataAttribute lastLineTime=absRoot.getAttribute("String_Node_Str");
    if (lastLineTime != null) {
      final ProductData.UTC endTime=product.getEndTime();
      if (endTime != null)       lastLineTime.getData().setElems(endTime.getArray());
    }
    final MetadataAttribute totalSize=absRoot.getAttribute("String_Node_Str");
    if (totalSize != null)     totalSize.getData().setElemUInt(product.getRawStorageSize());
    if (nearRangeOnLeft) {
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",0.5f,0.5f);
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",product.getSceneRasterWidth() - 1 + 0.5f,0.5f);
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",0.5f,product.getSceneRasterHeight() - 1 + 0.5f);
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",product.getSceneRasterWidth() - 1 + 0.5f,product.getSceneRasterHeight() - 1 + 0.5f);
    }
 else {
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",product.getSceneRasterWidth() - 1 + 0.5f,0.5f);
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",0.5f,0.5f);
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",product.getSceneRasterWidth() - 1 + 0.5f,product.getSceneRasterHeight() - 1 + 0.5f);
      setLatLongMetadata(product,absRoot,"String_Node_Str","String_Node_Str",0.5f,product.getSceneRasterHeight() - 1 + 0.5f);
    }
    final MetadataAttribute height=absRoot.getAttribute("String_Node_Str");
    if (height != null)     height.getData().setElemUInt(product.getSceneRasterHeight());
    final MetadataAttribute width=absRoot.getAttribute("String_Node_Str");
    if (width != null)     width.getData().setElemUInt(product.getSceneRasterWidth());
    final MetadataAttribute offsetX=absRoot.getAttribute("String_Node_Str");
    if (offsetX != null && subsetDef.getRegion() != null)     offsetX.getData().setElemUInt(subsetDef.getRegion().x);
    final MetadataAttribute offsetY=absRoot.getAttribute("String_Node_Str");
    if (offsetY != null && subsetDef.getRegion() != null)     offsetY.getData().setElemUInt(subsetDef.getRegion().y);
    final MetadataAttribute slantRange=absRoot.getAttribute("String_Node_Str");
    if (slantRange != null) {
      final TiePointGrid srTPG=product.getTiePointGrid("String_Node_Str");
      if (srTPG != null) {
        final double slantRangeTime;
        if (nearRangeOnLeft) {
          slantRangeTime=srTPG.getPixelDouble(0,0) / 1000000000.0;
        }
 else {
          slantRangeTime=srTPG.getPixelDouble(product.getSceneRasterWidth() - 1,0) / 1000000000.0;
        }
        final double halfLightSpeed=299792458.0 / 2.0;
        final double slantRangeDist=slantRangeTime * halfLightSpeed;
        slantRange.getData().setElemDouble(slantRangeDist);
      }
    }
    setSubsetSRGRCoefficients(product,subsetDef,absRoot);
  }
 catch (  Exception e) {
    throw new IOException(e);
  }
}

Fixed version (ground truth):
private static void updateMetadata(final Product sourceProduct,final Product targetProduct,ProductSubsetDef subsetDef) throws IOException {
  try {
    final MetadataElement root=targetProduct.getMetadataRoot();
    if (root == null)     return;
    final MetadataElement absRoot=root.getElement("String_Node_Str");
    if (absRoot == null)     return;
    boolean nearRangeOnLeft=isNearRangeOnLeft(targetProduct);
    final MetadataAttribute firstLineTime=absRoot.getAttribute("String_Node_Str");
    if (firstLineTime != null) {
      final ProductData.UTC startTime=targetProduct.getStartTime();
      if (startTime != null)       firstLineTime.getData().setElems(startTime.getArray());
    }
    final MetadataAttribute lastLineTime=absRoot.getAttribute("String_Node_Str");
    if (lastLineTime != null) {
      final ProductData.UTC endTime=targetProduct.getEndTime();
      if (endTime != null)       lastLineTime.getData().setElems(endTime.getArray());
    }
    final MetadataAttribute totalSize=absRoot.getAttribute("String_Node_Str");
    if (totalSize != null)     totalSize.getData().setElemUInt(targetProduct.getRawStorageSize());
    if (nearRangeOnLeft) {
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",0.5f,0.5f);
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",targetProduct.getSceneRasterWidth() - 1 + 0.5f,0.5f);
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",0.5f,targetProduct.getSceneRasterHeight() - 1 + 0.5f);
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",targetProduct.getSceneRasterWidth() - 1 + 0.5f,targetProduct.getSceneRasterHeight() - 1 + 0.5f);
    }
 else {
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",targetProduct.getSceneRasterWidth() - 1 + 0.5f,0.5f);
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",0.5f,0.5f);
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",targetProduct.getSceneRasterWidth() - 1 + 0.5f,targetProduct.getSceneRasterHeight() - 1 + 0.5f);
      setLatLongMetadata(targetProduct,absRoot,"String_Node_Str","String_Node_Str",0.5f,targetProduct.getSceneRasterHeight() - 1 + 0.5f);
    }
    final MetadataAttribute height=absRoot.getAttribute("String_Node_Str");
    if (height != null)     height.getData().setElemUInt(targetProduct.getSceneRasterHeight());
    final MetadataAttribute width=absRoot.getAttribute("String_Node_Str");
    if (width != null)     width.getData().setElemUInt(targetProduct.getSceneRasterWidth());
    final MetadataAttribute offsetX=absRoot.getAttribute("String_Node_Str");
    if (offsetX != null && subsetDef.getRegion() != null)     offsetX.getData().setElemUInt(subsetDef.getRegion().x);
    final MetadataAttribute offsetY=absRoot.getAttribute("String_Node_Str");
    if (offsetY != null && subsetDef.getRegion() != null)     offsetY.getData().setElemUInt(subsetDef.getRegion().y);
    final MetadataAttribute slantRange=absRoot.getAttribute("String_Node_Str");
    if (slantRange != null) {
      final TiePointGrid srTPG=targetProduct.getTiePointGrid("String_Node_Str");
      if (srTPG != null) {
        final double slantRangeTime;
        if (nearRangeOnLeft) {
          slantRangeTime=srTPG.getPixelDouble(0,0) / 1000000000.0;
        }
 else {
          slantRangeTime=srTPG.getPixelDouble(targetProduct.getSceneRasterWidth() - 1,0) / 1000000000.0;
        }
        final double halfLightSpeed=299792458.0 / 2.0;
        final double slantRangeDist=slantRangeTime * halfLightSpeed;
        slantRange.getData().setElemDouble(slantRangeDist);
      }
    }
    setSubsetSRGRCoefficients(sourceProduct,targetProduct,subsetDef,absRoot,nearRangeOnLeft);
  }
 catch (  Exception e) {
    throw new IOException(e);
  }
}