# Liquibase maven thread-safety

**URL:** <https://forum.liquibase.org/t/liquibase-maven-thread-safety/10117>\
**Category:** Liquibase Development\
**Created:** [January 7, 2025, 12:47pm UTC](https://forum.liquibase.org/t/liquibase-maven-thread-safety/10117 "2025-01-07T12:47:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![facboy](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@facboy](https://forum.liquibase.org/u/facboy)\
**Post date:** [January 7, 2025, 12:47pm UTC](https://forum.liquibase.org/t/liquibase-maven-thread-safety/10117/1 "2025-01-07T12:47:13Z")

</div>

short background, i’m trying to run the `updateSQL` goal under `mvnd` (maven daemon). i have a couple of modules in the reactor build that run this goal, and they often run in parallel. i get random (almost 50% of the time) errors where the output file is corrupted (e.g. just ends halfway through a file), or i get “Stream closed” exceptions.

i’m using liquibase 4.30.0, if that makes any difference.

i’ve been eyeballing the `Scope` class, and i must admit i don’t quite understand it - it seems like if at any point a thread calls `Scope.getCurrentScope()` then the `SingletonScopeManager` will be set as the scope manager and will be used by that thread and any child threads it creates. doesn’t this create a thread-safety issue when e.g. multiple child threads create child scopes, getting/setting `currentScope` which is shared across the ‘root’ thread and all its children?

is there a related problem when it initializes the rootScope in a `SingletonScopeManager`. i notice it sets it (i.e. makes it visible in the scope manager) before actually initializing it with its attributes, so it’s theoretically possible for another thread to see the `rootScope` but for it to have some or all of its initial values unset.
