Skip to content

Commit

Permalink
Use yaml instance instead of static variable to enable threadsaftey
Browse files Browse the repository at this point in the history
  • Loading branch information
LitschiW authored Oct 14, 2024
1 parent 1fffc4c commit 8870523
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit 8870523

Please sign in to comment.