Kabir Khan created WFCORE-2111:
----------------------------------
Summary: Fix incorrect usage of AtomicMapFieldUpdater.putAtomic()
Key: WFCORE-2111
URL:
https://issues.jboss.org/browse/WFCORE-2111
Project: WildFly Core
Issue Type: Bug
Components: Domain Management
Affects Versions: 3.0.0.Alpha15
Reporter: Kabir Khan
Assignee: Kabir Khan
The javadoc for the copy of AtomicMapFieldUpdater used in core specifies that if
putAtomic() returns a value, that the put did not succeed. The transformer and
notification registries are full of code checking the return value like
https://github.com/kabir/wildfly-core/blob/3396609db1eebf7af382133b7d22fa...
:
{code}
SubRegistry getOrCreate(final String key) {
for (;;) {
final Map<String, SubRegistry> subRegistries =
subRegistriesUpdater.get(this);
SubRegistry registry = subRegistries.get(key);
if(registry == null) {
registry = new SubRegistry();
SubRegistry existing = subRegistriesUpdater.putAtomic(this, key, registry,
subRegistries);
if(existing == null) {
return registry;
} else if (existing != registry) {
return existing; // Problematic
}
}
return registry;
}
}
{code}
This calling code assumes that if 'existing' is returned and is not the same as
the created 'registry' that the put succeeded, and it was added to
'existing'. However, this is not what happens, when 'existing' is
returned, its value is actually the same as the 'subRegistries' snapshot, and no
insertion has happened.
To clear up the confusion, make AtomicMapFieldUpdater return a boolean where
'true' is returned if the put succeeded, and 'false' when it did not. If
'false' is returned the caller needs to retry the put as implied today.
--
This message was sent by Atlassian JIRA
(v7.2.3#72005)