Program: 170375
Project: 170375
Buggy source:
@Override protected Product getMosaicProduct(File metadataFile) throws IOException {
  if (!validateOpenJpegExecutables(S2Config.OPJ_INFO_EXE,S2Config.OPJ_DECOMPRESSOR_EXE)) {
    throw new IOException("String_Node_Str");
  }
  Objects.requireNonNull(metadataFile);
  boolean isAGranule=S2OrthoGranuleMetadataFilename.isGranuleFilename(metadataFile.getName());
  if (isAGranule) {
    logger.fine("String_Node_Str");
  }
  TimeProbe timeProbe=TimeProbe.start();
  if (!updateTileLayout(metadataFile.toPath(),isAGranule)) {
    throw new IOException(String.format("String_Node_Str",metadataFile.getName()));
  }
  SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
  String filterTileId=null;
  File rootMetaDataFile=null;
  String granuleDirName=null;
  timeProbe.reset();
  if (isAGranule) {
    granuleDirName=metadataFile.getParentFile().getName();
    try {
      Objects.requireNonNull(metadataFile.getParentFile());
      Objects.requireNonNull(metadataFile.getParentFile().getParentFile());
      Objects.requireNonNull(metadataFile.getParentFile().getParentFile().getParentFile());
    }
 catch (    NullPointerException npe) {
      throw new IOException(String.format("String_Node_Str",metadataFile.getName()));
    }
    File up2levels=metadataFile.getParentFile().getParentFile().getParentFile();
    File tileIdFilter=metadataFile.getParentFile();
    filterTileId=tileIdFilter.getName();
    File[] files=up2levels.listFiles();
    if (files != null) {
      for (      File f : files) {
        if (S2ProductFilename.isProductFilename(f.getName()) && S2ProductFilename.isMetadataFilename(f.getName())) {
          rootMetaDataFile=f;
          break;
        }
      }
    }
    if (rootMetaDataFile == null) {
      throw new IOException(String.format("String_Node_Str",metadataFile.getName()));
    }
  }
 else {
    rootMetaDataFile=metadataFile;
  }
  final String aFilter=filterTileId;
  S2Metadata metadataHeader=parseHeader(rootMetaDataFile,granuleDirName,getConfig(),epsgCode);
  SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
  timeProbe.reset();
  S2OrthoSceneLayout sceneDescription=S2OrthoSceneLayout.create(metadataHeader);
  logger.fine("String_Node_Str" + sceneDescription);
  File productDir=getProductDir(rootMetaDataFile);
  initCacheDir(productDir);
  S2Metadata.ProductCharacteristics productCharacteristics=metadataHeader.getProductCharacteristics();
  Product product=new Product(FileUtils.getFilenameWithoutExtension(rootMetaDataFile),"String_Node_Str" + productCharacteristics.getProcessingLevel(),sceneDescription.getSceneDimension(getProductResolution()).width,sceneDescription.getSceneDimension(getProductResolution()).height);
  for (  MetadataElement metadataElement : metadataHeader.getMetadataElements()) {
    product.getMetadataRoot().addElement(metadataElement);
  }
  product.setFileLocation(metadataFile);
  try {
    product.setSceneGeoCoding(new CrsGeoCoding(CRS.decode(this.epsgCode),product.getSceneRasterWidth(),product.getSceneRasterHeight(),sceneDescription.getSceneOrigin()[0],sceneDescription.getSceneOrigin()[1],this.getProductResolution().resolution,this.getProductResolution().resolution,0.0,0.0));
  }
 catch (  FactoryException e) {
    throw new IOException(e);
  }
catch (  TransformException e) {
    throw new IOException(e);
  }
  product.setPreferredTileSize(S2Config.DEFAULT_JAI_TILE_SIZE,S2Config.DEFAULT_JAI_TILE_SIZE);
  product.setNumResolutionsMax(getConfig().getTileLayout(S2SpatialResolution.R10M.resolution).numResolutions);
  product.setAutoGrouping("String_Node_Str");
  product.setStartTime(parseDate(productCharacteristics.getProductStartTime(),"String_Node_Str"));
  product.setEndTime(parseDate(productCharacteristics.getProductStopTime(),"String_Node_Str"));
  List<BandInfo> bandInfoList=new ArrayList<>();
  List<S2Metadata.Tile> tileList=metadataHeader.getTileList();
  if (isAGranule) {
    tileList=tileList.stream().filter(p -> p.getId().equalsIgnoreCase(aFilter)).collect(Collectors.toList());
  }
  for (  S2BandInformation bandInformation : productCharacteristics.getBandInformations()) {
    HashMap<String,File> tileFileMap=new HashMap<>();
    for (    S2Metadata.Tile tile : tileList) {
      S2OrthoGranuleDirFilename gf=S2OrthoGranuleDirFilename.create(tile.getId());
      if (gf != null) {
        String imgFilename=String.format("String_Node_Str",File.separator,tile.getId(),File.separator,bandInformation.getImageFileTemplate().replace("String_Node_Str",gf.missionID).replace("String_Node_Str",gf.siteCentre).replace("String_Node_Str",gf.creationDate).replace("String_Node_Str",gf.absoluteOrbit).replace("String_Node_Str",gf.tileNumber).replace("String_Node_Str",String.format("String_Node_Str",bandInformation.getResolution().resolution)));
        logger.finer("String_Node_Str" + imgFilename + "String_Node_Str"+ bandInformation.getPhysicalBand());
        File file=new File(productDir,imgFilename);
        if (file.exists()) {
          tileFileMap.put(tile.getId(),file);
        }
 else {
          logger.warning(String.format("String_Node_Str",file));
        }
      }
    }
    if (!tileFileMap.isEmpty()) {
      BandInfo bandInfo=createBandInfoFromHeaderInfo(bandInformation,tileFileMap);
      bandInfoList.add(bandInfo);
    }
 else {
      logger.warning(String.format("String_Node_Str",bandInformation.getPhysicalBand()));
    }
  }
  SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
  timeProbe.reset();
  if (!bandInfoList.isEmpty()) {
    addBands(product,bandInfoList,sceneDescription);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
    scaleBands(product,bandInfoList);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
    addVectorMasks(product,tileList,bandInfoList);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
    addIndexMasks(product,bandInfoList);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
  }
  if (!"String_Node_Str".equalsIgnoreCase(productCharacteristics.getMetaDataLevel())) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",SUN_ZENITH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",SUN_AZIMUTH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",VIEW_ZENITH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",VIEW_AZIMUTH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
  }
  return product;
}

Fixed version (ground truth):
@Override protected Product getMosaicProduct(File metadataFile) throws IOException {
  if (!validateOpenJpegExecutables(S2Config.OPJ_INFO_EXE,S2Config.OPJ_DECOMPRESSOR_EXE)) {
    throw new IOException("String_Node_Str");
  }
  Objects.requireNonNull(metadataFile);
  boolean isAGranule=S2OrthoGranuleMetadataFilename.isGranuleFilename(metadataFile.getName());
  if (isAGranule) {
    logger.fine("String_Node_Str");
  }
  TimeProbe timeProbe=TimeProbe.start();
  if (!updateTileLayout(metadataFile.toPath(),isAGranule)) {
    throw new IOException(String.format("String_Node_Str",metadataFile.getName()));
  }
  SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
  String filterTileId=null;
  File rootMetaDataFile=null;
  String granuleDirName=null;
  timeProbe.reset();
  if (isAGranule) {
    granuleDirName=metadataFile.getParentFile().getName();
    try {
      Objects.requireNonNull(metadataFile.getParentFile());
      Objects.requireNonNull(metadataFile.getParentFile().getParentFile());
      Objects.requireNonNull(metadataFile.getParentFile().getParentFile().getParentFile());
    }
 catch (    NullPointerException npe) {
      throw new IOException(String.format("String_Node_Str",metadataFile.getName()));
    }
    File up2levels=metadataFile.getParentFile().getParentFile().getParentFile();
    File tileIdFilter=metadataFile.getParentFile();
    filterTileId=tileIdFilter.getName();
    File[] files=up2levels.listFiles();
    if (files != null) {
      for (      File f : files) {
        if (S2ProductFilename.isProductFilename(f.getName()) && S2ProductFilename.isMetadataFilename(f.getName())) {
          rootMetaDataFile=f;
          break;
        }
      }
    }
    if (rootMetaDataFile == null) {
      throw new IOException(String.format("String_Node_Str",metadataFile.getName()));
    }
  }
 else {
    rootMetaDataFile=metadataFile;
  }
  final String aFilter=filterTileId;
  S2Metadata metadataHeader=parseHeader(rootMetaDataFile,granuleDirName,getConfig(),epsgCode);
  SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
  timeProbe.reset();
  S2OrthoSceneLayout sceneDescription=S2OrthoSceneLayout.create(metadataHeader);
  logger.fine("String_Node_Str" + sceneDescription);
  File productDir=getProductDir(rootMetaDataFile);
  initCacheDir(productDir);
  S2Metadata.ProductCharacteristics productCharacteristics=metadataHeader.getProductCharacteristics();
  Product product=new Product(FileUtils.getFilenameWithoutExtension(rootMetaDataFile),"String_Node_Str" + productCharacteristics.getProcessingLevel(),sceneDescription.getSceneDimension(getProductResolution()).width,sceneDescription.getSceneDimension(getProductResolution()).height);
  for (  MetadataElement metadataElement : metadataHeader.getMetadataElements()) {
    product.getMetadataRoot().addElement(metadataElement);
  }
  product.setFileLocation(metadataFile);
  try {
    product.setSceneGeoCoding(new CrsGeoCoding(CRS.decode(this.epsgCode),product.getSceneRasterWidth(),product.getSceneRasterHeight(),sceneDescription.getSceneOrigin()[0],sceneDescription.getSceneOrigin()[1],this.getProductResolution().resolution,this.getProductResolution().resolution,0.0,0.0));
  }
 catch (  FactoryException e) {
    throw new IOException(e);
  }
catch (  TransformException e) {
    throw new IOException(e);
  }
  product.setPreferredTileSize(S2Config.DEFAULT_JAI_TILE_SIZE,S2Config.DEFAULT_JAI_TILE_SIZE);
  product.setNumResolutionsMax(getConfig().getTileLayout(S2SpatialResolution.R10M.resolution).numResolutions);
  product.setAutoGrouping("String_Node_Str");
  product.setStartTime(parseDate(productCharacteristics.getProductStartTime(),"String_Node_Str"));
  product.setEndTime(parseDate(productCharacteristics.getProductStopTime(),"String_Node_Str"));
  List<BandInfo> bandInfoList=new ArrayList<>();
  List<S2Metadata.Tile> tileList=metadataHeader.getTileList();
  if (isAGranule) {
    tileList=tileList.stream().filter(p -> p.getId().equalsIgnoreCase(aFilter)).collect(Collectors.toList());
  }
  for (  S2BandInformation bandInformation : productCharacteristics.getBandInformations()) {
    HashMap<String,File> tileFileMap=new HashMap<>();
    for (    S2Metadata.Tile tile : tileList) {
      S2OrthoGranuleDirFilename gf=S2OrthoGranuleDirFilename.create(tile.getId());
      if (gf != null) {
        String imgFilename=String.format("String_Node_Str",File.separator,tile.getId(),File.separator,bandInformation.getImageFileTemplate().replace("String_Node_Str",gf.missionID).replace("String_Node_Str",gf.siteCentre).replace("String_Node_Str",gf.creationDate).replace("String_Node_Str",gf.absoluteOrbit).replace("String_Node_Str",gf.tileNumber).replace("String_Node_Str",String.format("String_Node_Str",bandInformation.getResolution().resolution)));
        logger.finer("String_Node_Str" + imgFilename + "String_Node_Str"+ bandInformation.getPhysicalBand());
        File file=new File(productDir,imgFilename);
        if (file.exists()) {
          tileFileMap.put(tile.getId(),file);
        }
 else {
          logger.warning(String.format("String_Node_Str",file));
        }
      }
    }
    if (!tileFileMap.isEmpty()) {
      BandInfo bandInfo=createBandInfoFromHeaderInfo(bandInformation,tileFileMap);
      bandInfoList.add(bandInfo);
    }
 else {
      logger.warning(String.format("String_Node_Str",bandInformation.getPhysicalBand()));
    }
  }
  SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
  timeProbe.reset();
  if (!bandInfoList.isEmpty()) {
    addBands(product,bandInfoList,sceneDescription);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
    scaleBands(product,bandInfoList);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
    addVectorMasks(product,tileList,bandInfoList);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
    addIndexMasks(product,bandInfoList,sceneDescription);
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
  }
  if (!"String_Node_Str".equalsIgnoreCase(productCharacteristics.getMetaDataLevel())) {
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",SUN_ZENITH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",SUN_AZIMUTH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",VIEW_ZENITH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    addTiePointGridBand(product,metadataHeader,sceneDescription,"String_Node_Str",VIEW_AZIMUTH_GRID_INDEX,"String_Node_Str","String_Node_Str");
    SystemUtils.LOG.fine(String.format("String_Node_Str",timeProbe.elapsed(TimeUnit.MILLISECONDS)));
    timeProbe.reset();
  }
  return product;
}