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

Kai Reinhard
08.33.2019 2725e9f3e52b008e28019a148cae4b58fc6dc69c
ConcurrentModificationException on queue: synchronized added.
1 files modified
16 ■■■■■ changed files
borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/JobQueue.java 16 ●●●●● patch | view | raw | blame | history
borgbutler-core/src/main/java/de/micromata/borgbutler/jobs/JobQueue.java
@@ -38,7 +38,9 @@
    }
    public Iterator<AbstractJob<T>> getQueueIterator() {
        return Collections.unmodifiableList(queue).iterator();
        synchronized (queue) {
            return Collections.unmodifiableList(queue).iterator();
        }
    }
    /**
@@ -48,11 +50,13 @@
     * @return The job if any job with the given unique job number is queued, otherwise null.
     */
    public AbstractJob<T> getQueuedJobByUniqueJobNumber(long uniqueJobNumber) {
        Iterator<AbstractJob<T>> it = queue.iterator();
        while (it.hasNext()) {
            AbstractJob<T> job = it.next();
            if (job.getUniqueJobNumber() == uniqueJobNumber) {
                return job;
        synchronized (queue) {
            Iterator<AbstractJob<T>> it = queue.iterator();
            while (it.hasNext()) {
                AbstractJob<T> job = it.next();
                if (job.getUniqueJobNumber() == uniqueJobNumber) {
                    return job;
                }
            }
        }
        return null;