mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
08.30.2019 1eee1eff15bb3c9c742577b86def127f8deee8a1
ConcurrentModificationException on queue: synchronized added.
1 files modified
20 ■■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/BorgQueueExecutor.java 20 ●●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/BorgQueueExecutor.java
@@ -73,7 +73,7 @@
        job.cancel();
        queue.refreshQueue();
    }
    /**
     * For displaying purposes.
     *
@@ -86,15 +86,17 @@
        if (origQueue == null) {
            return jobList;
        }
        Iterator<AbstractJob<String>> it = origQueue.getQueueIterator();
        while (it.hasNext()) {
            AbstractJob<String> origJob = it.next();
            if (!(origJob instanceof BorgJob)) {
                log.error("Oups, only BorgJobs are supported. Ignoring unexpected job: " + origJob.getClass());
                continue;
        synchronized (origQueue) {
            Iterator<AbstractJob<String>> it = origQueue.getQueueIterator();
            while (it.hasNext()) {
                AbstractJob<String> origJob = it.next();
                if (!(origJob instanceof BorgJob)) {
                    log.error("Oups, only BorgJobs are supported. Ignoring unexpected job: " + origJob.getClass());
                    continue;
                }
                BorgJob<?> borgJob = ((BorgJob<?>) origJob).clone();
                jobList.add(borgJob);
            }
            BorgJob<?> borgJob = ((BorgJob<?>) origJob).clone();
            jobList.add(borgJob);
        }
        return jobList;
    }