[
https://issues.apache.org/jira/browse/AVRO-1781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15094503#comment-15094503
]
Ryan Blue commented on AVRO-1781:
---------------------------------
The problem is that Guava's MapMaker maps don't allow Null. I've updated the
patch to use Optional and tests are passing.
I also ran into trouble with the mapred module because the Guava dependency,
despite being shaded, was overriding Hadoop's guava dependency. I've added a
ban for all versions of Guava other than 11.0.2 and for avro-guava-dependencies
(to make sure it doesn't leak Guava classes into the classpath). Unfortunately,
the only way to avoid hitting the Guava ban is to use version 11.0.2. If I use
19.0 and build/test from the mapred directory it correctly uses 11.0.2, but if
I build from the lang/java directory the dependencies are all resolved at once
and 19.0 overrides the transitive dependency's version. Luckily, everything
works with 11.0.2 and the jar is even a little smaller.
I also had to update this to exclude Google's JSR301 jar, which might be GPL
and is banned by avro-tools. I'm attaching a new patch.
> Schema.parse is not thread safe
> -------------------------------
>
> Key: AVRO-1781
> URL: https://issues.apache.org/jira/browse/AVRO-1781
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.8.0
> Reporter: Sean Busbey
> Priority: Blocker
> Fix For: 1.8.0
>
> Attachments: AVRO-1781.1.patch
>
>
> Post AVRO-1497, Schema.parse calls {{LogicalTypes.fromSchemaIgnoreInvalid}}
> on any schema that is expressed as a JSON object (anything except bare
> primitives).
> That static method relies on a static cache based on WeakIdentityHashMap
> (WIHM).
> WIHM clearly states that it isn't threadsafe
> [ref|https://github.com/apache/avro/blob/branch-1.8/lang/java/avro/src/main/java/org/apache/avro/util/WeakIdentityHashMap.java#L42]
> {code}
> *
> * Note that this implementation is not synchronized.
> * </b>
> */
> public class WeakIdentityHashMap<K, V> implements Map<K, V> {
> {code}
> All of the Schema.Parser instances use that same static Schema.parse method.
> The end result is that as-is it's only safe to have a single thread parsing
> schemas in a given JVM.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)