You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Stephen Tu (JIRA)" <ji...@apache.org> on 2010/08/05 06:30:16 UTC
[jira] Created: (AVRO-607) SpecificData.getSchema not thread-safe
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
Reporter: Stephen Tu
Priority: Minor
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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (AVRO-607) SpecificData.getSchema not thread-safe
Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/AVRO-607?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-607:
------------------------------
Attachment: AVRO-607.patch
Here's a simple patch. I've converted it to use ConcurrentHashMap instead. We already have static ConcurrentHashMaps that contain instances of Class, and most instances of Type are Class. So this will prevent classes and types from getting GC'd, but neither need to be GC'd much.
A better fix might be to update all uses of static ConcurrentHashMaps with 'new com.google.common.collect.
new MapMaker().weakKeys().makeMap()'.
http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/collect/MapMaker.html
Should we add a dependency on Google Collections?
> 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
> Reporter: Stephen Tu
> Priority: Minor
> 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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.