Skip to content

[Bug]: YamlSnakeYamlFormatHandler creates new Yaml instance on every serialize call #201

@Splatcrafter

Description

@Splatcrafter

AI REVIEWED

Module: cli
File: cli/format/YamlSnakeYamlFormatHandler.java
Severity: Medium

Summary

Unlike all Jackson-based handlers which reuse static mapper instances, the SnakeYAML handler creates a new Yaml instance on every serialize() and serializePretty() call. This causes unnecessary allocation overhead.

Suggested Fix

Cache Yaml instances as fields:

private final Yaml compactYaml = new Yaml(this.compactOptions);
private final Yaml prettyYaml = new Yaml(this.prettyOptions);

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance problems or opportunities (runtime, memory, allocations, IO, startup)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions