private static Map loadFile()

in src/main/java/com/microsoft/dhalion/conf/ConfigBuilder.java [89:110]


  private static Map<String, Object> loadFile(Path file) {
    Map<String, Object> props = new HashMap<>();

    // check if the file exists and also it is a regular file
    if (!Files.exists(file) || !Files.isRegularFile(file)) {
      LOG.info("Config file " + file + " does not exist or is not a regular file");
      return props;
    }

    LOG.log(Level.INFO, "Reading config file {0}", file);

    Map<String, Object> propsYaml = null;
    try (FileInputStream fin = new FileInputStream(file.toFile())) {
      Yaml yaml = new Yaml();
      propsYaml = yaml.load(fin);
      LOG.log(Level.INFO, "Successfully read config file {0}", file);
    } catch (IOException e) {
      LOG.log(Level.SEVERE, "Failed to load config file: " + file, e);
    }

    return propsYaml != null ? propsYaml : props;
  }