katylettuce / beast-mcmc

Automatically exported from code.google.com/p/beast-mcmc
0 stars 0 forks source link

ConcurrentModificationException in SimpleOperatorSchedule.java #689

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
 - ConcurrentModificationException when adding List<MCMCOperator> to SimpleOperatorSchedule.addOperators

 - java code
        List<MCMCOperator> defalutOperatorsList = new ArrayList<MCMCOperator>();
        MCMCOperator operator = new ScaleOperator(kappa, 0.75);
        defalutOperatorsList.add(operator);
        operator = new ScaleOperator(popSize, 0.75);
        defalutOperatorsList.add(operator);

        OperatorSchedule schedule = new SimpleOperatorSchedule();
        schedule.addOperators(defalutOperatorsList); //here

 - trace
java.util.ConcurrentModificationException
    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:819)
    at java.util.ArrayList$Itr.next(ArrayList.java:791)
    at dr.inference.operators.SimpleOperatorSchedule.addOperators(SimpleOperatorSchedule.java:55)

What is the expected output? What do you see instead?
- In SimpleOperatorSchedule.java
change from
    public void addOperators(List<MCMCOperator> operators) {
        for (MCMCOperator operator : operators) {
            operators.add(operator);

to 
    public void addOperators(List<MCMCOperator> operators) {
        for (MCMCOperator operator : operators) {
            this.operators.add(operator);
            ^^^^^

What version of the product are you using? On what operating system?
BEAST 1.7.4. SimpleOperatorSchedule.java is identical between 1.7.4 and 1.7.5
java version "1.7.0_21"
OS: Fedora 18

Please provide any additional information below.

Original issue reported on code.google.com by steven...@gmail.com on 4 Jun 2013 at 8:25

GoogleCodeExporter commented 9 years ago
Fixed as suggested.

Original comment by ramb...@gmail.com on 31 Jul 2014 at 11:05