commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Naozumi Taromaru (Commented) (JIRA)" <>
Subject [jira] [Commented] (JXPATH-152) Concurrent access on hashmap of JXPathIntrospector
Date Thu, 23 Feb 2012 08:35:49 GMT


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);
Thread-1 use JXPathContext instance-1.
Thread-2 use JXPathContext instance-2.

Thread-1 and Thread-2 may execute
JXPathIntrospector#getBeanInfo (static method)

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:
>             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:!default.jspa
For more information on JIRA, see:


View raw message