Aled Sage created BROOKLYN-119:
----------------------------------

             Summary: ConcurrentModificationException when persisting entity 
attributes
                 Key: BROOKLYN-119
                 URL: https://issues.apache.org/jira/browse/BROOKLYN-119
             Project: Brooklyn
          Issue Type: Bug
    Affects Versions: 0.7.0-SNAPSHOT
            Reporter: Aled Sage
            Priority: Minor


When running apps with persistence enabled, the log sometimes contains the an 
exception like the following:

{noformat}
2015-01-15 14:47:51,025 WARN  b.e.r.PersistenceExceptionHandlerImpl 
[brooklyn-execmanager-RBNffgWM-169]: Problem persisting (ignoring): generate 
memento for ENTITY brooklyn.entity.webapp.jboss.JBoss7ServerImpl(fQvgDCKq)
java.util.ConcurrentModificationException: null
        at 
java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:711) 
~[na:1.8.0_25]
        at 
java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:744) 
~[na:1.8.0_25]
        at 
java.util.LinkedHashMap$LinkedEntryIterator.next(LinkedHashMap.java:742) 
~[na:1.8.0_25]
        at brooklyn.event.basic.AttributeMap.asMap(AttributeMap.java:79) 
~[brooklyn-core-0.7.0-SNAPSHOT.jar:0.7.0-SNAPSHOT]
        at 
brooklyn.entity.basic.AbstractEntity.getAllAttributes(AbstractEntity.java:1053) 
~[brooklyn-core-0.7.0-SNAPSHOT.jar:0.7.0-SNAPSHOT]
        at 
brooklyn.entity.rebind.dto.MementosGenerators.newEntityMementoBuilder(MementosGenerators.java:173)
 ~[brooklyn-core-0.7.0-SNAPSHOT.jar:0.7.0-SNAPSHOT]
        at 
brooklyn.entity.rebind.BasicEntityRebindSupport.getMementoWithProperties(BasicEntityRebindSupport.java:70)
 ~[brooklyn-core-0.7.0-SNAPSHOT.jar:na]
        at 
brooklyn.entity.rebind.BasicEntityRebindSupport.getMemento(BasicEntityRebindSupport.java:62)
 ~[brooklyn-core-0.7.0-SNAPSHOT.jar:na]
        at 
brooklyn.entity.rebind.BasicEntityRebindSupport.getMemento(BasicEntityRebindSupport.java:1)
 ~[brooklyn-core-0.7.0-SNAPSHOT.jar:na]
        at 
brooklyn.entity.rebind.PeriodicDeltaChangeListener.persistNow(PeriodicDeltaChangeListener.java:392)
 ~[brooklyn-core-0.7.0-SNAPSHOT.jar:na]
        at 
brooklyn.entity.rebind.PeriodicDeltaChangeListener$1$1.call(PeriodicDeltaChangeListener.java:215)
 [brooklyn-core-0.7.0-SNAPSHOT.jar:na]
        at 
brooklyn.entity.rebind.PeriodicDeltaChangeListener$1$1.call(PeriodicDeltaChangeListener.java:1)
 [brooklyn-core-0.7.0-SNAPSHOT.jar:na]
        at 
brooklyn.util.task.BasicExecutionManager$ScheduledTaskCallable$1.call(BasicExecutionManager.java:410)
 [brooklyn-core-0.7.0-SNAPSHOT.jar:0.7.0-SNAPSHOT]
        at 
brooklyn.util.task.BasicExecutionManager$SubmissionCallable.call(BasicExecutionManager.java:469)
 [brooklyn-core-0.7.0-SNAPSHOT.jar:0.7.0-SNAPSHOT]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
[na:1.8.0_25]
        at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
[na:1.8.0_25]
        at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
[na:1.8.0_25]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
{noformat}

This means that `AttributeMap.values` was modified by another thread during 
this method call, and that the `values` map is not a `ConcurrentMap`.

The field is initialised by the map being passed into the constructor (which is 
intended to allow a back-end storage such as Hazelcast to be used). The comment 
on the field says "Assumed to be something like a ConcurrentMap passed in", but 
clearly it is being passed a `java.util.LinkedHashMap`.

The application seems to continue to behave itself. As long as the entity is 
persisted again before the Brooklyn server is restarted, then it will not have 
any impact. However, we should definitely fix this!



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to