If an exception is thrown while writing anything to a YAML file, the mapper won't close the opened YAML file.
A simple example to reproduce the resource leak:
@Test
public void test() throws IOException {
try {
new YAMLMapper().writeValue(new File("test.yml"), new Object());
} finally {
Files.delete(Paths.get("test.yml"));
}
}
If an exception is thrown while writing anything to a YAML file, the mapper won't close the opened YAML file.
A simple example to reproduce the resource leak: