[
https://issues.apache.org/jira/browse/AVRO-607?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15384445#comment-15384445
]
Andrius Druzinis-Vitkus commented on AVRO-607:
----------------------------------------------
Hi all, I would like to propose a fix based on Guava's Caches. The advantage of
a cache over a (synchronised) map is that caches offer atomic
"get-if-absent-compute" semantics, which should prevent race conditions. Also,
it offers a 'weak keys' option (and weak values, if needed).
Since I can't see an Attach patch button, I've added the patch to a GitHub gist:
https://gist.github.com/driu/51238a26f3a980d2b91222f788ff651b
> SpecificData.getSchema not thread-safe
> --------------------------------------
>
> Key: AVRO-607
> URL: https://issues.apache.org/jira/browse/AVRO-607
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.3.3, 1.8.1
> Reporter: Stephen Tu
> Priority: Blocker
> Fix For: 1.8.2
>
> Attachments: AVRO-607.patch
>
>
> SpecificData.getSchema uses a WeakHashMap to cache schemas, but WeakHashMap
> is not thread-safe, and the method itself is not synchronized. Seems like
> this could lead to the data structure getting corrupted.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)