[
https://issues.apache.org/jira/browse/AVRO-2051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16092096#comment-16092096
]
Doug Cutting commented on AVRO-2051:
------------------------------------
Should we perhaps instead put the ConcurrentLinkedHashMap into the
org.apache.avro.util package, rather than implementing this as a nested utility
class?
Also, I'm not sure why you added methods for the hashCode, equals and hasProps,
but I question whether these should be protected (where they appear in javadoc
for subclasses to override) or rather package private (so that they can only be
used by other classes in the package). I generally think we should avoid
adding publicly visible methods that we don't expect things outside the package
to ever need to call. The Schema classes are not meant to be extensible.
Perhaps this should at least be a separate issue, since it's not related to the
thread contention issue?
Lastly, it would be good to add a test that verifys the thread contention has
been addressed. This might be as simple as a synchronized(schema) thread that
blocks another thread that tries to change properties without the patch and
does not with the patch.
> Thread contention accessing JsonProperties props
> ------------------------------------------------
>
> Key: AVRO-2051
> URL: https://issues.apache.org/jira/browse/AVRO-2051
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.8.2
> Reporter: Daniel Kulp
>
> See
> https://lists.apache.org/thread.html/dd34ab8439137a81a9de29ad4161f37b17638394cea0806765689976@%3Cuser.avro.apache.org%3E
> Basically, the getJsonProp method, being synchronized, is causing thread
> contention issues when trying to share schemas between threads. My
> proposal (pull request forthcoming) is to treat "props" as an immutable map
> and do a copy+add+swap for the addProp method. This will make the addProp
> call slower (particularly for large maps of props), but would make the reads
> significantly faster as no locking will be needed.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)