Program: 170381
Project: 170381
Buggy source:
private Product getL1cMosaicProduct(File granuleMetadataFile,boolean isAGranule) throws IOException {
  Objects.requireNonNull(granuleMetadataFile);
  String filterTileId=null;
  File metadataFile=null;
  if (isAGranule) {
    try {
      Objects.requireNonNull(granuleMetadataFile.getParentFile());
      Objects.requireNonNull(granuleMetadataFile.getParentFile().getParentFile());
      Objects.requireNonNull(granuleMetadataFile.getParentFile().getParentFile().getParentFile());
    }
 catch (    NullPointerException npe) {
      throw new IOException(String.format("String_Node_Str",granuleMetadataFile.getName()));
    }
    File up2levels=granuleMetadataFile.getParentFile().getParentFile().getParentFile();
    File tileIdFilter=granuleMetadataFile.getParentFile();
    filterTileId=tileIdFilter.getName();
    File[] files=up2levels.listFiles();
    for (    File f : files) {
      if (S2ProductFilename.isProductFilename(f.getName()) && S2ProductFilename.isMetadataFilename(f.getName())) {
        metadataFile=f;
        break;
      }
    }
    if (metadataFile == null) {
      throw new IOException(String.format("String_Node_Str",granuleMetadataFile.getName()));
    }
  }
 else {
    metadataFile=granuleMetadataFile;
  }
  final String aFilter=filterTileId;
  L1cMetadata metadataHeader=null;
  try {
    metadataHeader=parseHeader(metadataFile);
  }
 catch (  JDOMException|UnmarshalException e) {
    throw new IOException("String_Node_Str" + metadataFile.getName());
  }
  L1cSceneDescription sceneDescription=L1cSceneDescription.create(metadataHeader,Tile.idGeom.G10M);
  logger.fine("String_Node_Str" + sceneDescription);
  File productDir=getProductDir(metadataFile);
  initCacheDir(productDir);
  ProductCharacteristics productCharacteristics=metadataHeader.getProductCharacteristics();
  Product product=new Product(FileUtils.getFilenameWithoutExtension(metadataFile),"String_Node_Str" + productCharacteristics.processingLevel,sceneDescription.getSceneRectangle().width,sceneDescription.getSceneRectangle().height);
  product.getMetadataRoot().addElement(metadataHeader.getMetadataElement());
  product.setFileLocation(metadataFile.getParentFile());
  if (forceResize) {
    setGeoCoding(product,sceneDescription.getSceneEnvelope());
  }
  product.setPreferredTileSize(DEFAULT_JAI_TILE_SIZE,DEFAULT_JAI_TILE_SIZE);
  product.setNumResolutionsMax(L1C_TILE_LAYOUTS[0].numResolutions);
  String autoGrouping="String_Node_Str";
  for (  String utmZone : metadataHeader.getUTMZonesList()) {
    autoGrouping+=utmZone.replace(':','_');
  }
  autoGrouping+="String_Node_Str";
  product.setAutoGrouping(autoGrouping);
  for (  String utmZone : metadataHeader.getUTMZonesList()) {
    Map<Integer,BandInfo> bandInfoMap=new HashMap<Integer,BandInfo>();
    List<L1cMetadata.Tile> utmZoneTileList;
    if (isAGranule) {
      utmZoneTileList=metadataHeader.getTileList().stream().filter(p -> p.id.equalsIgnoreCase(aFilter)).collect(Collectors.toList());
    }
 else {
      utmZoneTileList=metadataHeader.getTileList(utmZone);
    }
    for (    SpectralInformation bandInformation : productCharacteristics.bandInformations) {
      int bandIndex=bandInformation.bandId;
      if (bandIndex >= 0 && bandIndex < productCharacteristics.bandInformations.length) {
        HashMap<String,File> tileFileMap=new HashMap<String,File>();
        for (        Tile tile : utmZoneTileList) {
          S2GranuleDirFilename gf=S2GranuleDirFilename.create(tile.id);
          S2GranuleImageFilename imageFilename=gf.getImageFilename(bandInformation.physicalBand);
          String imgFilename="String_Node_Str" + File.separator + tile.id+ File.separator+ "String_Node_Str"+ File.separator+ imageFilename.name;
          logger.finer("String_Node_Str" + imgFilename + "String_Node_Str"+ bandInformation.physicalBand);
          File file=new File(productDir,imgFilename);
          if (file.exists()) {
            tileFileMap.put(tile.id,file);
          }
 else {
            logger.warning(String.format("String_Node_Str",file));
          }
        }
        if (!tileFileMap.isEmpty()) {
          BandInfo bandInfo=createBandInfoFromHeaderInfo(bandInformation,tileFileMap);
          bandInfoMap.put(bandIndex,bandInfo);
        }
 else {
          logger.warning(String.format("String_Node_Str",bandInformation.physicalBand));
        }
      }
 else {
        logger.warning(String.format("String_Node_Str",bandInformation.physicalBand));
      }
    }
    if (!bandInfoMap.isEmpty()) {
      addBands(product,bandInfoMap,sceneDescription.getSceneEnvelope(),new L1cSceneMultiLevelImageFactory(sceneDescription,ImageManager.getImageToModelTransform(product.getGeoCoding())),utmZone);
    }
    List<EopPolygon> polygons=filterMasksInUTMZones(utmZoneTileList);
    Map<String,List<EopPolygon>> polygonsByType=new HashMap<>();
    if (!polygons.isEmpty()) {
      Set<String> polygonTypes=polygons.stream().map(p -> p.getType()).collect(Collectors.toSet());
      for (      String polygonType : polygonTypes) {
        polygonsByType.put(polygonType,polygons.stream().filter(p -> p.getType().equals(polygonType)).collect(Collectors.toList()));
      }
      try {
        AffineTransform scaler=AffineTransform.getScaleInstance(this.productResolution,this.productResolution).createInverse();
        AffineTransform move=AffineTransform.getTranslateInstance(-sceneDescription.getSceneEnvelope().getMinX(),-sceneDescription.getSceneEnvelope().getMinY());
        AffineTransform mirror_y=new AffineTransform(1,0,0,-1,0,sceneDescription.getSceneEnvelope().getHeight() / this.productResolution);
        AffineTransform world2pixel=new AffineTransform(mirror_y);
        world2pixel.concatenate(scaler);
        world2pixel.concatenate(move);
        try {
          for (          String polygonType : polygonTypes) {
            final SimpleFeatureType type=Placemark.createGeometryFeatureType();
            final DefaultFeatureCollection collection=new DefaultFeatureCollection("String_Node_Str",type);
            List<EopPolygon> typedPolygon=polygonsByType.get(polygonType);
            for (int index=0; index < typedPolygon.size(); index++) {
              Polygon pol=typedPolygon.get(index).getPolygon();
              pol=(Polygon)JTS.transform(pol,new AffineTransform2D(world2pixel));
              Object[] data1={pol,String.format("String_Node_Str",index)};
              SimpleFeatureImpl f1=new SimpleFeatureImpl(data1,type,new FeatureIdImpl(String.format("String_Node_Str",index)),true);
              collection.add(f1);
            }
            VectorDataNode vdn=new VectorDataNode(polygonType,collection);
            product.getVectorDataGroup().add(vdn);
          }
        }
 catch (        MismatchedDimensionException e) {
        }
catch (        TransformException e) {
        }
      }
 catch (      NoninvertibleTransformException e) {
      }
    }
  }
  if (metadataHeader.getTileList().get(0).sunAnglesGrid != null) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",0);
  }
  if (metadataHeader.getTileList().get(1).sunAnglesGrid != null) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",1);
  }
  if (metadataHeader.getTileList().get(2).sunAnglesGrid != null) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",2);
  }
  if (metadataHeader.getTileList().get(3).sunAnglesGrid != null) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",3);
  }
  return product;
}

Fixed version (ground truth):
private Product getL1cMosaicProduct(File granuleMetadataFile,boolean isAGranule) throws IOException {
  Objects.requireNonNull(granuleMetadataFile);
  String filterTileId=null;
  File metadataFile=null;
  if (isAGranule) {
    try {
      Objects.requireNonNull(granuleMetadataFile.getParentFile());
      Objects.requireNonNull(granuleMetadataFile.getParentFile().getParentFile());
      Objects.requireNonNull(granuleMetadataFile.getParentFile().getParentFile().getParentFile());
    }
 catch (    NullPointerException npe) {
      throw new IOException(String.format("String_Node_Str",granuleMetadataFile.getName()));
    }
    File up2levels=granuleMetadataFile.getParentFile().getParentFile().getParentFile();
    File tileIdFilter=granuleMetadataFile.getParentFile();
    filterTileId=tileIdFilter.getName();
    File[] files=up2levels.listFiles();
    for (    File f : files) {
      if (S2ProductFilename.isProductFilename(f.getName()) && S2ProductFilename.isMetadataFilename(f.getName())) {
        metadataFile=f;
        break;
      }
    }
    if (metadataFile == null) {
      throw new IOException(String.format("String_Node_Str",granuleMetadataFile.getName()));
    }
  }
 else {
    metadataFile=granuleMetadataFile;
  }
  final String aFilter=filterTileId;
  L1cMetadata metadataHeader=null;
  try {
    metadataHeader=parseHeader(metadataFile);
  }
 catch (  JDOMException|UnmarshalException e) {
    throw new IOException("String_Node_Str" + metadataFile.getName());
  }
  L1cSceneDescription sceneDescription=L1cSceneDescription.create(metadataHeader,Tile.idGeom.G10M);
  logger.fine("String_Node_Str" + sceneDescription);
  File productDir=getProductDir(metadataFile);
  initCacheDir(productDir);
  ProductCharacteristics productCharacteristics=metadataHeader.getProductCharacteristics();
  Product product=new Product(FileUtils.getFilenameWithoutExtension(metadataFile),"String_Node_Str" + productCharacteristics.processingLevel,sceneDescription.getSceneRectangle().width,sceneDescription.getSceneRectangle().height);
  product.getMetadataRoot().addElement(metadataHeader.getMetadataElement());
  product.setFileLocation(metadataFile.getParentFile());
  if (forceResize) {
    setGeoCoding(product,sceneDescription.getSceneEnvelope());
  }
  product.setPreferredTileSize(DEFAULT_JAI_TILE_SIZE,DEFAULT_JAI_TILE_SIZE);
  product.setNumResolutionsMax(L1C_TILE_LAYOUTS[0].numResolutions);
  String autoGrouping="String_Node_Str";
  for (  String utmZone : metadataHeader.getUTMZonesList()) {
    autoGrouping+=utmZone.replace(':','_');
  }
  autoGrouping+="String_Node_Str";
  product.setAutoGrouping(autoGrouping);
  for (  String utmZone : metadataHeader.getUTMZonesList()) {
    Map<Integer,BandInfo> bandInfoMap=new HashMap<Integer,BandInfo>();
    List<L1cMetadata.Tile> utmZoneTileList=metadataHeader.getTileList(utmZone);
    if (isAGranule) {
      utmZoneTileList=utmZoneTileList.stream().filter(p -> p.id.equalsIgnoreCase(aFilter)).collect(Collectors.toList());
    }
    for (    SpectralInformation bandInformation : productCharacteristics.bandInformations) {
      int bandIndex=bandInformation.bandId;
      if (bandIndex >= 0 && bandIndex < productCharacteristics.bandInformations.length) {
        HashMap<String,File> tileFileMap=new HashMap<String,File>();
        for (        Tile tile : utmZoneTileList) {
          S2GranuleDirFilename gf=S2GranuleDirFilename.create(tile.id);
          S2GranuleImageFilename imageFilename=gf.getImageFilename(bandInformation.physicalBand);
          String imgFilename="String_Node_Str" + File.separator + tile.id+ File.separator+ "String_Node_Str"+ File.separator+ imageFilename.name;
          logger.finer("String_Node_Str" + imgFilename + "String_Node_Str"+ bandInformation.physicalBand);
          File file=new File(productDir,imgFilename);
          if (file.exists()) {
            tileFileMap.put(tile.id,file);
          }
 else {
            logger.warning(String.format("String_Node_Str",file));
          }
        }
        if (!tileFileMap.isEmpty()) {
          BandInfo bandInfo=createBandInfoFromHeaderInfo(bandInformation,tileFileMap);
          bandInfoMap.put(bandIndex,bandInfo);
        }
 else {
          logger.warning(String.format("String_Node_Str",bandInformation.physicalBand));
        }
      }
 else {
        logger.warning(String.format("String_Node_Str",bandInformation.physicalBand));
      }
    }
    if (!bandInfoMap.isEmpty()) {
      addBands(product,bandInfoMap,sceneDescription.getSceneEnvelope(),new L1cSceneMultiLevelImageFactory(sceneDescription,ImageManager.getImageToModelTransform(product.getGeoCoding())),utmZone);
    }
    List<EopPolygon> polygons=filterMasksInUTMZones(utmZoneTileList);
    Map<String,List<EopPolygon>> polygonsByType=new HashMap<>();
    if (!polygons.isEmpty()) {
      Set<String> polygonTypes=polygons.stream().map(p -> p.getType()).collect(Collectors.toSet());
      for (      String polygonType : polygonTypes) {
        polygonsByType.put(polygonType,polygons.stream().filter(p -> p.getType().equals(polygonType)).collect(Collectors.toList()));
      }
      try {
        AffineTransform scaler=AffineTransform.getScaleInstance(this.productResolution,this.productResolution).createInverse();
        AffineTransform move=AffineTransform.getTranslateInstance(-sceneDescription.getSceneEnvelope().getMinX(),-sceneDescription.getSceneEnvelope().getMinY());
        AffineTransform mirror_y=new AffineTransform(1,0,0,-1,0,sceneDescription.getSceneEnvelope().getHeight() / this.productResolution);
        AffineTransform world2pixel=new AffineTransform(mirror_y);
        world2pixel.concatenate(scaler);
        world2pixel.concatenate(move);
        try {
          for (          String polygonType : polygonTypes) {
            final SimpleFeatureType type=Placemark.createGeometryFeatureType();
            final DefaultFeatureCollection collection=new DefaultFeatureCollection("String_Node_Str",type);
            List<EopPolygon> typedPolygon=polygonsByType.get(polygonType);
            for (int index=0; index < typedPolygon.size(); index++) {
              Polygon pol=typedPolygon.get(index).getPolygon();
              pol=(Polygon)JTS.transform(pol,new AffineTransform2D(world2pixel));
              Object[] data1={pol,String.format("String_Node_Str",index)};
              SimpleFeatureImpl f1=new SimpleFeatureImpl(data1,type,new FeatureIdImpl(String.format("String_Node_Str",index)),true);
              collection.add(f1);
            }
            VectorDataNode vdn=new VectorDataNode(polygonType,collection);
            product.getVectorDataGroup().add(vdn);
          }
        }
 catch (        MismatchedDimensionException e) {
        }
catch (        TransformException e) {
        }
      }
 catch (      NoninvertibleTransformException e) {
      }
    }
  }
  if (!"String_Node_Str".equalsIgnoreCase(productCharacteristics.getMetaDataLevel())) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",SUN_ZENITH_GRID_INDEX);
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",SUN_AZIMUTH_GRID_INDEX);
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",VIEW_ZENITH_GRID_INDEX);
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",VIEW_AZIMUTH_GRID_INDEX);
  }
  return product;
}