use of java.util.ConcurrentModificationException in project tomcat by apache.
the class WebappClassLoaderBase method loadedByThisOrChild.
/**
* @param o object to test, may be null
* @return <code>true</code> if o has been loaded by the current classloader
* or one of its descendants.
*/
private boolean loadedByThisOrChild(Object o) {
if (o == null) {
return false;
}
Class<?> clazz;
if (o instanceof Class) {
clazz = (Class<?>) o;
} else {
clazz = o.getClass();
}
ClassLoader cl = clazz.getClassLoader();
while (cl != null) {
if (cl == this) {
return true;
}
cl = cl.getParent();
}
if (o instanceof Collection<?>) {
Iterator<?> iter = ((Collection<?>) o).iterator();
try {
while (iter.hasNext()) {
Object entry = iter.next();
if (loadedByThisOrChild(entry)) {
return true;
}
}
} catch (ConcurrentModificationException e) {
log.warn(sm.getString("webappClassLoader.loadedByThisOrChildFail", clazz.getName(), getContextName()), e);
}
}
return false;
}
use of java.util.ConcurrentModificationException in project cpsolver by UniTime.
the class SwapStudentSelection method selectNeighbour.
/**
* For each student that does not have a complete schedule, try to find a
* request and a student that can be moved out of an enrollment so that the
* selected student can be assigned to the selected request.
*/
@Override
public Neighbour<Request, Enrollment> selectNeighbour(Solution<Request, Enrollment> solution) {
Student student = null;
while ((student = nextStudent()) != null) {
Progress p = Progress.getInstance(solution.getModel());
p.incProgress();
if (p.getProgress() > 2.0 * p.getProgressMax())
return null;
if (student.isComplete(solution.getAssignment()) || student.nrAssignedRequests(solution.getAssignment()) == 0)
continue;
for (int i = 0; i < 5; i++) {
try {
Selection selection = getSelection(solution.getAssignment(), student);
Neighbour<Request, Enrollment> neighbour = selection.select();
if (neighbour != null) {
addStudent(student);
return neighbour;
} else
iProblemStudents.addAll(selection.getProblemStudents());
break;
} catch (ConcurrentModificationException e) {
}
}
}
return null;
}
use of java.util.ConcurrentModificationException in project cpsolver by UniTime.
the class BacktrackSelection method selectNeighbour.
@Override
public Neighbour<Request, Enrollment> selectNeighbour(Solution<Request, Enrollment> solution) {
Request request = null;
if (iNbrIterations > iMaxIterations)
return null;
while ((request = nextRequest()) != null) {
Progress.getInstance(solution.getModel()).incProgress();
Enrollment e = request.getAssignment(solution.getAssignment());
if (e != null && request instanceof FreeTimeRequest)
continue;
if (e != null && e.getPriority() == 0 && ((CourseRequest) request).getSelectedChoices().isEmpty())
continue;
for (int i = 0; i < 5; i++) {
try {
Neighbour<Request, Enrollment> n = iRBtNSel.selectNeighbour(solution, request);
if (iRBtNSel.getContext() != null) {
iNbrIterations++;
iTotalTime += iRBtNSel.getContext().getTime();
if (iRBtNSel.getContext().isTimeoutReached())
iNbrTimeoutReached++;
if (n == null)
iNbrNoSolution++;
}
if (n != null && n.value(solution.getAssignment()) <= 0.0)
return n;
break;
} catch (ConcurrentModificationException ex) {
}
}
}
return null;
}
use of java.util.ConcurrentModificationException in project ignite by apache.
the class CacheExchangeMergeTest method testNoConcurrentModificationExceptionAfterMergeExchanges.
/**
* Test checks that there will be no {@link ConcurrentModificationException}
* when merging exchanges and iterating over {@link ExchangeDiscoveryEvents#events} at the same time.
*
* @throws Exception If failed.
*/
@Test
public void testNoConcurrentModificationExceptionAfterMergeExchanges() throws Exception {
testSpi = true;
LogListener logLsnr = matches("Merge exchange future on finish [").build();
listeningLog.registerAllListeners(logLsnr);
AtomicBoolean stop = new AtomicBoolean();
Collection<Exception> exceptions = new ConcurrentLinkedQueue<>();
try {
startGrid(0);
for (int i = 1; i < 9; i++) {
IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(i));
TestRecordingCommunicationSpi spi = ((TestRecordingCommunicationSpi) cfg.getCommunicationSpi());
spi.blockMessages((node, msg) -> delay(msg));
runAsync(() -> startGrid(cfg), "create-node-" + cfg.getIgniteInstanceName());
spi.waitForBlocked();
}
List<Ignite> allNodes = IgnitionEx.allGridsx();
CountDownLatch latch = new CountDownLatch(allNodes.size());
for (Ignite gridEx : allNodes) {
runAsync(() -> {
Collection<DiscoveryEvent> evts = ((IgniteEx) gridEx).context().cache().context().exchange().lastTopologyFuture().events().events();
latch.countDown();
int i = 0;
while (!stop.get()) {
try {
for (DiscoveryEvent evt : evts) {
if (nonNull(evt))
i++;
}
} catch (ConcurrentModificationException e) {
exceptions.add(e);
log.error("i = " + i, e);
break;
}
}
}, "get-ex-" + gridEx.configuration().getIgniteInstanceName());
}
for (Ignite node : allNodes) TestRecordingCommunicationSpi.spi(node).stopBlock();
latch.await();
awaitPartitionMapExchange();
} finally {
stop.set(true);
}
assertTrue(logLsnr.check());
assertTrue(exceptions.isEmpty());
}
use of java.util.ConcurrentModificationException in project jPOS by jpos.
the class ContextTest method testConcurrentException.
@Test
public void testConcurrentException() throws InterruptedException {
final Context ctx = new Context();
CountDownLatch latch = new CountDownLatch(1);
AtomicInteger errorsPut = new AtomicInteger();
AtomicInteger errorsDump = new AtomicInteger();
Runnable addEvent = () -> {
for (int i = 0; i < 10000; i++) {
try {
ctx.put("Prop-" + i, i);
} catch (ConcurrentModificationException e) {
errorsPut.incrementAndGet();
}
Thread.yield();
}
latch.countDown();
};
Runnable newFrozen = () -> {
while (latch.getCount() > 0) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ctx.dumpMap(new PrintStream(baos), "");
} catch (ConcurrentModificationException e) {
errorsDump.incrementAndGet();
}
Thread.yield();
}
};
new Thread(addEvent).start();
Thread t1 = new Thread(newFrozen);
t1.start();
t1.join();
if (errorsPut.get() + errorsDump.get() > 0)
fail("Concurrent Exception has been raised " + errorsPut.get() + "/" + errorsDump.get() + " time(s)");
}
Aggregations