Skip to content

fix: YamlConfiguration(Path) sharing one non-thread-safe YamlProperties - #206

Open
DragonL0508 wants to merge 1 commit into
FairyProject:v0.7from
DragonL0508:fix/yaml-config-shared-properties
Open

DragonL0508 wants to merge 1 commit into
FairyProject:v0.7from
DragonL0508:fix/yaml-config-shared-properties

Conversation

@DragonL0508

Copy link
Copy Markdown

Every YamlConfiguration created with the single-argument constructor is bound to YamlProperties.DEFAULT, so all of them share the same snakeyaml Representer/Constructor, which are not thread-safe. Saving two such configurations from different threads at the same time (async saves, Folia regions) randomly fails inside snakeyaml's Serializer with Nodes must be provided, anchor is not specified for alias or ConcurrentModificationException.

Each configuration now gets its own YamlProperties by default, and DEFAULT is documented as shared.

Tests: YamlConfigurationConcurrencyTest saves several configurations concurrently and loads them back.

🤖 Generated with Claude Code

Every YamlConfiguration created with the single-argument constructor is
bound to YamlProperties.DEFAULT, so all of them share the same snakeyaml
Representer/Constructor. Those are not thread-safe: saving two such
configurations from different threads at the same time (e.g. async
saves, or Folia regions) randomly fails inside snakeyaml's Serializer
with "Nodes must be provided", "anchor is not specified for alias" or
ConcurrentModificationException.

Give each configuration its own YamlProperties by default, and document
that DEFAULT is shared.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant