8000 Fix thread safety of parser by ybasket · Pull Request #114 · circe/circe-yaml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix thread safety of parser #114

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

Merged
merged 1 commit into from
May 5, 2020
Merged

Fix thread safety of parser #114

merged 1 commit into from
May 5, 2020

Conversation

ybasket
Copy link
Contributor
@ybasket ybasket commented Apr 27, 2020

Should resolve #112. As described in the issue, sharing the FlatteningConstructor isn't thread-safe as it has unsafe HashMap inside. It's very hard to reproduce as the problematic time window is very small (happens during hash map reorganisation), so relying on my own mental reasoning here for fixing. SnakeYAML explicitly states it isn't thread safe, see https://bitbucket.org/asomov/snakeyaml/wiki/Documentation#markdown-header-threading.

Drawback of this PR is that it introduces a little overhead by creating a FlatteningConstructor for every parse, but I think this is justified given the safety gained.

@codecov-io
Copy link
codecov-io commented Apr 27, 2020

Codecov Report

Merging #114 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #114   +/-   ##
=======================================
  Coverage   96.07%   96.07%           
=======================================
  Files           4        4           
  Lines         102      102           
  Branches        4        5    +1     
=======================================
  Hits           98       98           
  Misses          4        4           
Impacted Files Coverage Δ
src/main/scala/io/circe/yaml/parser/package.scala 92.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d15073...17bfb65. Read the comment docs.

@travisbrown
Copy link
Member

👍 , thanks for taking care of this!

@travisbrown travisbrown merged commit 100c862 into circe:master May 5, 2020
@ybasket
Copy link
Contributor Author
ybasket commented May 5, 2020

Sure. Got bitten by this at work, so it would be cool if you could release some time soon-ish!

@travisbrown
Copy link
Member

@ybasket Release is on its way to Maven Central: https://github.com/circe/circe-yaml/releases/tag/v0.13.1

@vaslabs
Copy link
vaslabs commented May 5, 2020

I was randomly getting a tree node class cast exception on the java HashMap until now. Thanks for this fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

io.circe.yaml.parse is not threadsafe
4 participants
0