Program: 11579
Project: 11579
Buggy source:
private static void setSubsetSRGRCoefficients(final Product product,final ProductSubsetDef subsetDef,final MetadataElement absRoot){
  final MetadataElement SRGRCoefficientsElem=absRoot.getElement("String_Node_Str");
  if (SRGRCoefficientsElem != null) {
    final ProductData.UTC startTimeUTC=product.getStartTime();
    final ProductData.UTC endTimeUTC=product.getEndTime();
    final double startTime=startTimeUTC == null ? 0 : startTimeUTC.getMJD();
    final double endTime=endTimeUTC == null ? 0 : endTimeUTC.getMJD();
    final double rangeSpacing=absRoot.getAttributeDouble("String_Node_Str",0);
    final double colIndex=subsetDef.getRegion() == null ? 0 : subsetDef.getRegion().getX();
    MetadataElement itemBeforeStart=null;
    if (startTimeUTC != null && endTimeUTC != null) {
      for (      MetadataElement srgrList : SRGRCoefficientsElem.getElements()) {
        final ProductData.UTC time=srgrList.getAttributeUTC("String_Node_Str");
        if (time.getMJD() < startTime) {
          if (itemBeforeStart == null) {
            itemBeforeStart=srgrList;
          }
 else {
            final ProductData.UTC maxTimeSoFar=itemBeforeStart.getAttributeUTC("String_Node_Str");
            if (maxTimeSoFar.getMJD() < time.getMJD()) {
              itemBeforeStart=srgrList;
            }
          }
        }
      }
    }
    for (    MetadataElement srgrList : SRGRCoefficientsElem.getElements()) {
      final ProductData.UTC time=srgrList.getAttributeUTC("String_Node_Str");
      if (startTimeUTC != null && endTimeUTC != null && (time.getMJD() < startTime || time.getMJD() > endTime) && srgrList != itemBeforeStart) {
        SRGRCoefficientsElem.removeElement(srgrList);
      }
 else {
        final double grO=srgrList.getAttributeDouble("String_Node_Str",0);
        final double ground_range_origin_subset=grO + colIndex * rangeSpacing;
        srgrList.setAttributeDouble("String_Node_Str",ground_range_origin_subset);
      }
    }
  }
}

Fixed version (ground truth):
private static void setSubsetSRGRCoefficients(final Product sourceProduct,final Product targetProduct,final ProductSubsetDef subsetDef,final MetadataElement absRoot,final boolean nearRangeOnLeft){
  final MetadataElement SRGRCoefficientsElem=absRoot.getElement("String_Node_Str");
  if (SRGRCoefficientsElem != null) {
    final ProductData.UTC startTimeUTC=targetProduct.getStartTime();
    final ProductData.UTC endTimeUTC=targetProduct.getEndTime();
    final double startTime=startTimeUTC == null ? 0 : startTimeUTC.getMJD();
    final double endTime=endTimeUTC == null ? 0 : endTimeUTC.getMJD();
    final double rangeSpacing=absRoot.getAttributeDouble("String_Node_Str",0);
    final double colIndex=subsetDef.getRegion() == null ? 0 : subsetDef.getRegion().getX();
    MetadataElement itemBeforeStart=null;
    if (startTimeUTC != null && endTimeUTC != null) {
      for (      MetadataElement srgrList : SRGRCoefficientsElem.getElements()) {
        final ProductData.UTC time=srgrList.getAttributeUTC("String_Node_Str");
        if (time.getMJD() < startTime) {
          if (itemBeforeStart == null) {
            itemBeforeStart=srgrList;
          }
 else {
            final ProductData.UTC maxTimeSoFar=itemBeforeStart.getAttributeUTC("String_Node_Str");
            if (maxTimeSoFar.getMJD() < time.getMJD()) {
              itemBeforeStart=srgrList;
            }
          }
        }
      }
    }
    for (    MetadataElement srgrList : SRGRCoefficientsElem.getElements()) {
      final ProductData.UTC time=srgrList.getAttributeUTC("String_Node_Str");
      if (startTimeUTC != null && endTimeUTC != null && (time.getMJD() < startTime || time.getMJD() > endTime) && srgrList != itemBeforeStart) {
        SRGRCoefficientsElem.removeElement(srgrList);
      }
 else {
        final double grO=srgrList.getAttributeDouble("String_Node_Str",0);
        double ground_range_origin_subset;
        if (nearRangeOnLeft) {
          ground_range_origin_subset=grO + colIndex * rangeSpacing;
        }
 else {
          final double colIndexFromRight=sourceProduct.getSceneRasterWidth() - colIndex - targetProduct.getSceneRasterWidth();
          ground_range_origin_subset=grO + colIndexFromRight * rangeSpacing;
        }
        srgrList.setAttributeDouble("String_Node_Str",ground_range_origin_subset);
      }
    }
  }
}