Skip to content

Commit

Permalink
fix random silent ArrayIndexOutOfBoundsException in Bug_574883 test
Browse files Browse the repository at this point in the history
  • Loading branch information
EcljpseB0T authored and jukzi committed Oct 17, 2022
1 parent ea31faf commit 4c5e8f4
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*******************************************************************************/
package org.eclipse.core.tests.runtime.jobs;

import java.util.*;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import org.eclipse.core.runtime.*;
Expand All @@ -30,7 +31,7 @@ public class Bug_574883 extends AbstractJobManagerTest {

static class SerialExecutor extends Job {

private final List<Runnable> queue;
private final Queue<Runnable> queue;
private final Object myFamily;

/**
Expand All @@ -41,7 +42,7 @@ public SerialExecutor(String jobName, Object family) {
super(jobName);
Assert.isNotNull(family);
this.myFamily = family;
this.queue = Collections.synchronizedList(new LinkedList<>());
this.queue = new ConcurrentLinkedQueue<>();
setSystem(true);
}

Expand All @@ -52,7 +53,7 @@ public boolean belongsTo(Object family) {

@Override
protected IStatus run(IProgressMonitor monitor) {
Runnable action = queue.remove(0);
Runnable action = queue.poll();
try {
if (action != null && !monitor.isCanceled()) {
action.run();
Expand Down

0 comments on commit 4c5e8f4

Please sign in to comment.