Skip to content

Commit

Permalink
Ensure that the config classes are not slurped concurrently as Config…
Browse files Browse the repository at this point in the history
…Slurper.parse(Script, URL) modifies meta class of the passed script class and is hence not thread safe when passed instances of the same class.

Fixes geb/issues#423
  • Loading branch information
erdi committed Feb 20, 2016
1 parent b8b8400 commit 4c1f295
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/manual/src/docs/asciidoc/140-project.adoc
Expand Up @@ -78,6 +78,7 @@ This page lists the high level changes between versions of Geb.

* Fix a MissingMethodException thrown from `Navigator.value()` when using Groovy versions < 2.4.0. [issue:422[]]
* Don't unnecessarily synchronize methods of `CachingDirverFactory.ThreadLocalCache`. [issue:421[]]
* Ensure `ConfigSlurper.parse(Script, URL)` is called in a thread safe way from `ConfigurationLoader`. [issue:423[]]

=== 0.13.0

Expand Down
Expand Up @@ -278,7 +278,10 @@ class ConfigurationLoader {
* @throws geb.error.UnableToLoadException if the config class could not be read.
*/
protected ConfigObject loadRawConfig(Class configClass) throws UnableToLoadException {
loadRawConfig(createSlurper(), configClass)
def slurper = createSlurper()
synchronized (configClass) {
loadRawConfig(slurper, configClass)
}
}

protected ConfigObject loadRawConfig(ConfigSlurper slurper, URL source) {
Expand All @@ -295,7 +298,7 @@ class ConfigurationLoader {
}
}

protected ConfigObject loadRawConfig(ConfigSlurper slurper, source) {
protected ConfigObject loadRawConfig(ConfigSlurper slurper, Class source) {
try {
slurper.parse(source)
} catch (Throwable e) {
Expand Down

0 comments on commit 4c1f295

Please sign in to comment.