Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use yaml instance instead of static variable to enable threadsaftey #1246

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,12 @@
* Utilities for dealing with {@link ManifestV3}s. Includes the functionality to transform to and from standard CLI YAML files.
*/
public final class ApplicationManifestUtilsV3 extends ApplicationManifestUtilsCommon {
private static final Yaml YAML;
private static final DumperOptions dumperOptions;

static {
DumperOptions dumperOptions = new DumperOptions();
dumperOptions = new DumperOptions();
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
dumperOptions.setExplicitStart(true);

YAML = new Yaml(dumperOptions);
}

private static final Pattern FIND_VARIABLE_REGEX =
Expand Down Expand Up @@ -104,9 +102,10 @@ public static void write(Path path, ManifestV3 manifest) {
* @param out the {@link OutputStream} to write to
* @param manifest the manifest to write
*/
public static void write(OutputStream out, ManifestV3 manifest) {
public static void write(OutputStream out, ManifestV3 manifest) {
Yaml yaml = new Yaml(dumperOptions);
try (Writer writer = new OutputStreamWriter(out)) {
YAML.dump(toYaml(manifest), writer);
yaml.dump(toYaml(manifest), writer);
} catch (IOException e) {
throw Exceptions.propagate(e);
}
Expand Down