snowplow / iglu-scala-client

Scala client for Iglu schema registry
https://github.com/snowplow/iglu/wiki
Apache License 2.0
5 stars 13 forks source link

Prevent IllegalStateException in test suite by avoiding concurrent access to resolvers #36

Open fblundun opened 9 years ago

fblundun commented 9 years ago

In build https://travis-ci.org/snowplow/iglu-scala-client/jobs/81756147

[error] ! a Resolver should report its failed lookups when a JSON Schema can't be resolved
[error]   IllegalStateException: Entry.next=null, data[removeIndex]=iglu:com.snowplowanalytics.self-desc/instance-iglu-only/jsonschema/1-0-0=Success({"$schema":"http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#","description":"Top-level schema for the validation process (Iglu-only)","self":{"vendor":"com.snowplowanalytics.self-desc","name":"instance-iglu-only","format":"jsonschema","version":"1-0-0"},"type":"object","properties":{"schema":{"type":"string","pattern":"^iglu:[a-zA-Z0-9-_.]+/[a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+/[0-9]+-[0-9]+-[0-9]+$"},"data":{}},"required":["schema","data"],"additionalProperties":false}) previous=iglu:com.snowplowanalytics.self-desc/instance-iglu-only/jsonschema/1-0-0=Success({"$schema":"http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#","description":"Top-level schema for the validation process (Iglu-only)","self":{"vendor":"com.snowplowanalytics.self-desc","name":"instance-iglu-only","format":"jsonschema","version":"1-0-0"},"type":"object","properties":{"schema":{"type":"string","pattern":"^iglu:[a-zA-Z0-9-_.]+/[a-zA-Z0-9-_]+/[a-zA-Z0-9-_]+/[0-9]+-[0-9]+-[0-9]+$"},"data":{}},"required":["schema","data"],"additionalProperties":false}) key=iglu:com.acme.icarus/wing/jsonschema/1-0-0 value=Failure(NonEmptyList(error: Could not find schema with key iglu:com.acme.icarus/wing/jsonschema/1-0-0 in any repository, tried:
[error]     level: "error"
[error]     repositories: ["Iglu Test Embedded [embedded]","Iglu Client Embedded [embedded]"]
[error] )) size=10 maxSize=10 Please check that your keys are immutable, and that you have used synchronization properly. If so, then please report this to commons-dev@jakarta.apache.org as a bug. (LRUMap.java:301)
[error] org.apache.commons.collections.map.LRUMap.reuseMapping(LRUMap.java:301)
[error] org.apache.commons.collections.map.LRUMap.addMapping(LRUMap.java:267)
[error] org.apache.commons.collections.map.AbstractHashedMap.put(AbstractHashedMap.java:284)
[error] com.snowplowanalytics.iglu.client.Resolver$cache$$anonfun$store$1.apply(Resolver.scala:198)
[error] com.snowplowanalytics.iglu.client.Resolver$cache$$anonfun$store$1.apply(Resolver.scala:197)
[error] com.snowplowanalytics.iglu.client.Resolver$cache$.store(Resolver.scala:197)
[error] com.snowplowanalytics.iglu.client.Resolver.recurse$1(Resolver.scala:234)
[error] com.snowplowanalytics.iglu.client.Resolver.lookupSchema(Resolver.scala:247)
[error] com.snowplowanalytics.iglu.client.ResolverSpec.e3(ResolverSpec.scala:131)
[error] com.snowplowanalytics.iglu.client.ResolverSpec$$anonfun$is$1$$anonfun$apply$1$$anonfun$apply$7.apply(ResolverSpec.scala:72)
[error] com.snowplowanalytics.iglu.client.ResolverSpec$$anonfun$is$1$$anonfun$apply$1$$anonfun$apply$7.apply(ResolverSpec.scala:72)
fblundun commented 9 years ago

sbt runs tests in parallel, so multiple threads can simultaneously access the TestResolver here and so simultaneously access its LRUCache, which is not thread-safe.

fblundun commented 9 years ago

This would be resolved by #28 but for now we can just create a new TestResolver whenever we need it.

fblundun commented 9 years ago

Actually, parallel execution in tests seems to be set to false here.

    parallelExecution in Test := false, // Parallel tests cause havoc with LRU cache

I don't know what else could have gone wrong - the keys are definitely immutable.

alexanderdean commented 9 years ago

Pushing back...