Program: 28806
Project: 28806
Buggy source:
/** 
 * This add a new page to the list of pages in the mkdocs configuration
 * @param mkdocsConfigFile    The mkdocs configuration file
 * @param apiDirectoryContent The contents of the api directory
 * @throws FileNotFoundException If mkdocs configuration file is not found
 */
private static void updateAPIPagesInMkdocsConfig(File mkdocsConfigFile,List<String> apiDirectoryContent) throws FileNotFoundException {
  DumperOptions dumperOptions=new DumperOptions();
  dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
  Yaml yaml=new Yaml(dumperOptions);
  Map<String,Object> yamlConfig=(Map<String,Object>)yaml.load(new InputStreamReader(new FileInputStream(mkdocsConfigFile),Constants.DEFAULT_CHARSET));
  List<Map<String,Object>> yamlConfigPagesList=(List<Map<String,Object>>)yamlConfig.get(Constants.MKDOCS_CONFIG_PAGES_KEY);
  List<Map<String,Object>> apiPagesList=new ArrayList<>();
  for (  String apiFile : apiDirectoryContent) {
    String pageName=apiFile.substring(0,apiFile.length() - Constants.MARKDOWN_FILE_EXTENSION.length());
    Map<String,Object> newPage=new HashMap<>();
    newPage.put(pageName,Constants.API_SUB_DIRECTORY + Constants.MKDOCS_FILE_SEPARATOR + apiFile);
    apiPagesList.add(newPage);
  }
  Map<String,Object> yamlConfigAPIPage=null;
  for (  Map<String,Object> yamlConfigPage : yamlConfigPagesList) {
    if (yamlConfigPage.get(Constants.MKDOCS_CONFIG_PAGES_API_KEY) != null) {
      yamlConfigAPIPage=yamlConfigPage;
      break;
    }
  }
  if (yamlConfigAPIPage == null) {
    yamlConfigAPIPage=new HashMap<>();
    yamlConfigPagesList.add(yamlConfigAPIPage);
  }
  yamlConfigAPIPage.put(Constants.MKDOCS_CONFIG_PAGES_API_KEY,apiPagesList);
  yaml.dump(yamlConfig,new OutputStreamWriter(new FileOutputStream(mkdocsConfigFile),Constants.DEFAULT_CHARSET));
}

Fixed version (ground truth):
/** 
 * This add a new page to the list of pages in the mkdocs configuration
 * @param mkdocsConfigFile           The mkdocs configuration file
 * @param documentationBaseDirectory The base directory of the documentation
 * @throws FileNotFoundException If mkdocs configuration file is not found
 */
public static void updateAPIPagesInMkdocsConfig(File mkdocsConfigFile,String documentationBaseDirectory) throws FileNotFoundException {
  File documentationDirectory=new File(documentationBaseDirectory + File.separator + Constants.API_SUB_DIRECTORY);
  String[] documentationFiles=documentationDirectory.list((directory,fileName) -> fileName.endsWith(Constants.MARKDOWN_FILE_EXTENSION));
  List<String> apiDirectoryContent;
  if (documentationFiles == null) {
    apiDirectoryContent=new ArrayList<>();
  }
 else {
    apiDirectoryContent=Arrays.asList(documentationFiles);
    apiDirectoryContent.sort(String::compareTo);
  }
  DumperOptions dumperOptions=new DumperOptions();
  dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
  Yaml yaml=new Yaml(dumperOptions);
  Map<String,Object> yamlConfig=(Map<String,Object>)yaml.load(new InputStreamReader(new FileInputStream(mkdocsConfigFile),Constants.DEFAULT_CHARSET));
  List<Map<String,Object>> yamlConfigPagesList=(List<Map<String,Object>>)yamlConfig.get(Constants.MKDOCS_CONFIG_PAGES_KEY);
  List<Map<String,Object>> apiPagesList=new ArrayList<>();
  for (  String apiFile : apiDirectoryContent) {
    String pageName=apiFile.substring(0,apiFile.length() - Constants.MARKDOWN_FILE_EXTENSION.length());
    Map<String,Object> newPage=new HashMap<>();
    newPage.put(pageName,Constants.API_SUB_DIRECTORY + Constants.MKDOCS_FILE_SEPARATOR + apiFile);
    apiPagesList.add(newPage);
  }
  Map<String,Object> yamlConfigAPIPage=null;
  for (  Map<String,Object> yamlConfigPage : yamlConfigPagesList) {
    if (yamlConfigPage.get(Constants.MKDOCS_CONFIG_PAGES_API_KEY) != null) {
      yamlConfigAPIPage=yamlConfigPage;
      break;
    }
  }
  if (yamlConfigAPIPage == null) {
    yamlConfigAPIPage=new HashMap<>();
    yamlConfigPagesList.add(yamlConfigAPIPage);
  }
  yamlConfigAPIPage.put(Constants.MKDOCS_CONFIG_PAGES_API_KEY,apiPagesList);
  yaml.dump(yamlConfig,new OutputStreamWriter(new FileOutputStream(mkdocsConfigFile),Constants.DEFAULT_CHARSET));
}