public static synchronized @Nonnull Map<String, Object> loadYamlFile(File file)
            throws Exception {
        try (FileInputStream inputStream = new FileInputStream((file))) {
            Map<String, Object> yamlResult =
                    (Map<String, Object>) loader.loadFromInputStream(inputStream);
            return yamlResult == null ? new HashMap<>() : yamlResult;
        } catch (FileNotFoundException e) {
            LOG.error("Failed to find YAML file", e);
            throw e;
        } catch (IOException | YamlEngineException e) {
            if (e instanceof MarkedYamlEngineException) {
                YamlEngineException exception =
                        wrapExceptionToHiddenSensitiveData((MarkedYamlEngineException) e);
                LOG.error("Failed to parse YAML configuration", exception);
                throw exception;
            } else {
                throw e;
            }
        }
    }
@Test
    void testLoadYamlFile() throws Exception {
        File confFile = new File(tmpDir, "test.yaml");
        try (final PrintWriter pw = new PrintWriter(confFile)) {
            pw.println("key1: value1");
            pw.println("key2: ");
            pw.println("  subKey1: value2");
            pw.println("key3: [a, b, c]");
            pw.println("key4: {k1: v1, k2: v2, k3: v3}");
            pw.println("key5: '*'");
            pw.println("key6: true");
            pw.println("key7: 'true'");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }

        Map<String, Object> yamlData = YamlParserUtils.loadYamlFile(confFile);
        assertThat(yamlData).isNotNull();
        assertThat(yamlData).containsEntry("key1", "value1");
        assertThat(((Map<?, ?>) yamlData.get("key2")).get("subKey1")).isEqualTo("value2");
        assertThat(yamlData).containsEntry("key3", Arrays.asList("a", "b", "c"));

        Map<String, String> map = new HashMap<>();
        map.put("k1", "v1");
        map.put("k2", "v2");
        map.put("k3", "v3");
        assertThat(yamlData).containsEntry("key4", map);
        assertThat(yamlData).containsEntry("key5", "*");
        assertThat((Boolean) yamlData.get("key6")).isTrue();
        assertThat(yamlData).containsEntry("key7", "true");
    }