You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Naozumi Taromaru (Commented) (JIRA)" <ji...@apache.org> on 2012/02/23 09:35:49 UTC

[jira] [Commented] (JXPATH-152) Concurrent access on hashmap of JXPathIntrospector

    [ https://issues.apache.org/jira/browse/JXPATH-152?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13214456#comment-13214456 ] 

Naozumi Taromaru commented on JXPATH-152:
-----------------------------------------

I think that this issue is a critical bug.

For example,
if the following code(an ordinary code) is executed in a multithread environment,
all threads hang-up(infinity loop) occurs in the worst case.

----
JXPathContext context = JXPathContext.newContext(target);
Iterator ite = context.iteratePointers(requestXpath);
while (ite.hasNext()) {
    Pointer p = (Pointer) ite.next();
    ...
}
----
Thread-1 use JXPathContext instance-1.
Thread-2 use JXPathContext instance-2.

However,
Thread-1 and Thread-2 may execute
JXPathIntrospector#getBeanInfo (static method)
concurrently.

JXPathIntrospector#getBeanInfo execute
"byClass.put(beanClass, beanInfo);".
("byClass" is HashMap in static field)

That is,
Thread-1 and Thread-2 may execute
HashMap#put concurrently.

Thread-1 and Thread-2 use same HashMap instance (in static field).

In the worst case,
Thread-1 and Thread-2 expand HashMap capacity concurrently.
Then, the structure of HashMap is broken.

If a thread use broken HashMap's method(get, put, etc...),
the thread execute infinity loop in HashMap.

If HashMap(byClass) is broken,
Thread-1 use JXPathContext ... infinity loop
Thread-2 use JXPathContext ... infinity loop
Thread-3 use JXPathContext ... infinity loop
...
As a result, all threads hang-up(infinity loop).

                
> Concurrent access on hashmap of JXPathIntrospector
> --------------------------------------------------
>
>                 Key: JXPATH-152
>                 URL: https://issues.apache.org/jira/browse/JXPATH-152
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: Java5, Windows/AIX
>            Reporter: pleutre
>            Priority: Minor
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> JXPathIntrospector.registerDynamicClass method can be called in static part of classes. 
> If two classes A & B try to registerDynamicClass in the same time a concurrent access exception can append on hashmap of JXPathIntrospector.
> Replace hashmap by concurrent hashmap or synchronized access to these hashmaps.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira