avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1781) Schema.parse is not thread safe
Date Wed, 20 Jan 2016 04:19:39 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15107968#comment-15107968

ASF subversion and git services commented on AVRO-1781:

Commit 1725668 from [~blue@cloudera.com] in branch 'avro/trunk'
[ https://svn.apache.org/r1725668 ]

AVRO-1781 ADDENDUM: Remove LogicalTypes cache.

This cache maps a Schema to its corresponding LogicalType that has been
constructed from the Schema's properties, by object identity. This is no
longer needed now that the LogicalType is set on the schema instance
when it is parsed. The cache was necessary when we were trying to avoid
all changes to the Schema class.

> 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
>            Assignee: Ryan Blue
>            Priority: Blocker
>             Fix For: 1.8.0
>         Attachments: AVRO-1781-ADDENDUM.1.patch, AVRO-1781-ADDENDUM.2.patch, 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

View raw message