Program: 11576
Project: 11576
Buggy source:
/** 
 * Compute source image geodetic boundary (minimum/maximum latitude/longitude) from the its corner latitude/longitude.
 * @param sourceProduct The input source product.
 * @throws OperatorException for no geocoding
 * @return geoBoundary The object to pass back the max/min lat/lon.
 */
public static ImageGeoBoundary computeImageGeoBoundary(final Product sourceProduct) throws OperatorException {
  final ImageGeoBoundary geoBoundary=new ImageGeoBoundary();
  final GeoCoding geoCoding=sourceProduct.getGeoCoding();
  if (geoCoding == null) {
    throw new OperatorException("String_Node_Str");
  }
  final GeoPos geoPosFirstNear=geoCoding.getGeoPos(new PixelPos(0,0),null);
  final GeoPos geoPosFirstFar=geoCoding.getGeoPos(new PixelPos(sourceProduct.getSceneRasterWidth() - 1,0),null);
  final GeoPos geoPosLastNear=geoCoding.getGeoPos(new PixelPos(0,sourceProduct.getSceneRasterHeight() - 1),null);
  final GeoPos geoPosLastFar=geoCoding.getGeoPos(new PixelPos(sourceProduct.getSceneRasterWidth() - 1,sourceProduct.getSceneRasterHeight() - 1),null);
  final double[] lats={geoPosFirstNear.getLat(),geoPosFirstFar.getLat(),geoPosLastNear.getLat(),geoPosLastFar.getLat()};
  final double[] lons={geoPosFirstNear.getLon(),geoPosFirstFar.getLon(),geoPosLastNear.getLon(),geoPosLastFar.getLon()};
  geoBoundary.latMin=90.0;
  geoBoundary.latMax=-90.0;
  for (  double lat : lats) {
    if (lat < geoBoundary.latMin) {
      geoBoundary.latMin=lat;
    }
    if (lat > geoBoundary.latMax) {
      geoBoundary.latMax=lat;
    }
  }
  geoBoundary.lonMin=360.0;
  geoBoundary.lonMax=0.0;
  for (  double lon : lons) {
    if (lon < 0) {
      lon+=360;
    }
    if (lon < geoBoundary.lonMin) {
      geoBoundary.lonMin=lon;
    }
    if (lon > geoBoundary.lonMax) {
      geoBoundary.lonMax=lon;
    }
  }
  return geoBoundary;
}

Fixed version (ground truth):
/** 
 * Compute source image geodetic boundary (minimum/maximum latitude/longitude) from the its corner latitude/longitude.
 * @param sourceProduct The input source product.
 * @throws OperatorException for no geocoding
 * @return geoBoundary The object to pass back the max/min lat/lon.
 */
public static ImageGeoBoundary computeImageGeoBoundary(final Product sourceProduct) throws OperatorException {
  final ImageGeoBoundary geoBoundary=new ImageGeoBoundary();
  final GeoCoding geoCoding=sourceProduct.getGeoCoding();
  if (geoCoding == null) {
    throw new OperatorException("String_Node_Str");
  }
  final GeoPos geoPosFirstNear=geoCoding.getGeoPos(new PixelPos(0,0),null);
  final GeoPos geoPosFirstFar=geoCoding.getGeoPos(new PixelPos(sourceProduct.getSceneRasterWidth() - 1,0),null);
  final GeoPos geoPosLastNear=geoCoding.getGeoPos(new PixelPos(0,sourceProduct.getSceneRasterHeight() - 1),null);
  final GeoPos geoPosLastFar=geoCoding.getGeoPos(new PixelPos(sourceProduct.getSceneRasterWidth() - 1,sourceProduct.getSceneRasterHeight() - 1),null);
  final double[] lats={geoPosFirstNear.getLat(),geoPosFirstFar.getLat(),geoPosLastNear.getLat(),geoPosLastFar.getLat()};
  final double[] lons={geoPosFirstNear.getLon(),geoPosFirstFar.getLon(),geoPosLastNear.getLon(),geoPosLastFar.getLon()};
  geoBoundary.latMin=90.0;
  geoBoundary.latMax=-90.0;
  for (  double lat : lats) {
    if (lat < geoBoundary.latMin) {
      geoBoundary.latMin=lat;
    }
    if (lat > geoBoundary.latMax) {
      geoBoundary.latMax=lat;
    }
  }
  geoBoundary.lonMin=180.0;
  geoBoundary.lonMax=-180.0;
  for (  double lon : lons) {
    if (lon < geoBoundary.lonMin) {
      geoBoundary.lonMin=lon;
    }
    if (lon > geoBoundary.lonMax) {
      geoBoundary.lonMax=lon;
    }
  }
  if (geoBoundary.lonMax - geoBoundary.lonMin >= 180) {
    geoBoundary.lonMin=360.0;
    geoBoundary.lonMax=0.0;
    for (    double lon : lons) {
      if (lon < 0) {
        lon+=360;
      }
      if (lon < geoBoundary.lonMin) {
        geoBoundary.lonMin=lon;
      }
      if (lon > geoBoundary.lonMax) {
        geoBoundary.lonMax=lon;
      }
    }
  }
  return geoBoundary;
}