Skip to content

YAMLMapper doesn't close output file if an error occurs #109

@pmwmedia

Description

@pmwmedia

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"));
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    PropertiesIssue related to (Java) Properties format backendTOMLIssue related to TOML format backendcsvyamlIssue related to YAML format backend

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions