[
https://issues.apache.org/jira/browse/PHOENIX-4860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16588602#comment-16588602
]
Jack Steenkamp commented on PHOENIX-4860:
-----------------------------------------
Thank you for your comments all. The use of a global static did appear a little
inconsistent to me with regards to the rest of the design (having just
implemented the application along the lines of the advice given in
PHOENIX-2388). Thought it best though not to be too presumptuous on raising
this - given my lack of knowledge.
I've attached another, more extensive, patch that makes the CursorUtil (maybe
we need to rename this to CursorState?) a member variable of PhoenixConnection
and gets rid of the static accesses. I still keep a global map to ensure that
Cursors are unique in the VM.
> CursorUtil Needs to Use a ConcurrentHashMap rather than HashMap
> ---------------------------------------------------------------
>
> Key: PHOENIX-4860
> URL: https://issues.apache.org/jira/browse/PHOENIX-4860
> Project: Phoenix
> Issue Type: Bug
> Affects Versions: 4.14.0, 4.13.1, 5.0.0
> Reporter: Jack Steenkamp
> Assignee: Jack Steenkamp
> Priority: Major
> Attachments: CursorUtil-More-Extensive.patch, CursorUtil.patch
>
>
> in very rare cases, when dealing with Apache Phoenix Cursors, the following
> NullPointerException is encountered:
> java.lang.NullPointerException: null
> at org.apache.phoenix.util.CursorUtil.updateCursor(CursorUtil.java:179)
> at
> org.apache.phoenix.iterate.CursorResultIterator.next(CursorResultIterator.java:46)
> at org.apache.phoenix.jdbc.PhoenixResultSet.next(PhoenixResultSet.java:779)
> (This is for 4.13.1 - but seems that
> org.apache.phoenix.util.CursorUtil has not changed, at the time of writing,
> since first being introduced as part of PHOENIX-3572).
> Upon closer inspection it would seem that on line 124 of CursorUtil, a
> HashMap is used to keep state which is then exposed via a number of
> static methods, which, one has to assume, can be accessed by many
> different threads. Using a plain old HashMap in cases like these can cause
> issues.
> The mapCursorIDQuery member should be a ConcurrentHashMap instead? That
> should tighten up the class and prevent any potential inconsistencies.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)