use of java.util.ConcurrentModificationException in project intellij-community by JetBrains.
the class IntervalTreeImpl method processContaining.
private boolean processContaining(@Nullable IntervalNode<T> root, int offset, int modCountBefore, int deltaUpToRootExclusive, @NotNull Processor<? super T> processor) {
if (root == null) {
return true;
}
assert root.isValid();
int delta = deltaUpToRootExclusive + root.delta;
if (offset > maxEndOf(root, deltaUpToRootExclusive)) {
// right of the rightmost interval in the subtree
return true;
}
if (!processContaining(root.getLeft(), offset, modCountBefore, delta, processor))
return false;
int myStartOffset = root.intervalStart() + delta;
int myEndOffset = root.intervalEnd() + delta;
boolean overlaps = myStartOffset <= offset && offset < myEndOffset;
if (overlaps) {
if (!root.processAliveKeys(processor))
return false;
if (modCount != modCountBefore)
throw new ConcurrentModificationException();
}
if (offset < myStartOffset) {
// left of the root, cant be in the right subtree
return true;
}
return processContaining(root.getRight(), offset, modCountBefore, delta, processor);
}
use of java.util.ConcurrentModificationException in project intellij-community by JetBrains.
the class IntervalTreeImpl method findMinOverlappingWith.
private IntervalNode<T> findMinOverlappingWith(@Nullable IntervalNode<T> root, @NotNull Interval interval, int modCountBefore, int deltaUpToRootExclusive) {
if (root == null) {
return null;
}
assert root.isValid();
int delta = deltaUpToRootExclusive + root.delta;
if (interval.intervalStart() > maxEndOf(root, deltaUpToRootExclusive)) {
// right of the rightmost interval in the subtree
return null;
}
IntervalNode<T> inLeft = findMinOverlappingWith(root.getLeft(), interval, modCountBefore, delta);
if (inLeft != null)
return inLeft;
int myStartOffset = root.intervalStart() + delta;
int myEndOffset = root.intervalEnd() + delta;
boolean overlaps = Math.max(myStartOffset, interval.intervalStart()) <= Math.min(myEndOffset, interval.intervalEnd());
if (overlaps)
return root;
if (modCount != modCountBefore)
throw new ConcurrentModificationException();
if (interval.intervalEnd() < myStartOffset) {
// left of the root, cant be in the right subtree
return null;
}
return findMinOverlappingWith(root.getRight(), interval, modCountBefore, delta);
}
use of java.util.ConcurrentModificationException in project cloudstack by apache.
the class NetappManagerImpl method destroyVolumeOnFiler.
/**
* This method destroys the volume on netapp filer
* @param ipAddress -- ip address of filer
* @param aggrName -- name of containing aggregate
* @param volName -- name of volume to destroy
* @throws ResourceInUseException
* @throws NaException
* @throws NaAPIFailedException
*/
@Override
@DB
public void destroyVolumeOnFiler(String ipAddress, String aggrName, String volName) throws ServerException, InvalidParameterValueException, ResourceInUseException {
NaElement xi0;
NaElement xi1;
NetappVolumeVO volume = null;
volume = _volumeDao.findVolume(ipAddress, aggrName, volName);
if (volume == null) {
s_logger.warn("The volume does not exist in our system");
throw new InvalidParameterValueException("The given tuple:" + ipAddress + "," + aggrName + "," + volName + " doesn't exist in our system");
}
List<LunVO> lunsOnVol = _lunDao.listLunsByVolId(volume.getId());
if (lunsOnVol != null && lunsOnVol.size() > 0) {
s_logger.warn("There are luns on the volume");
throw new ResourceInUseException("There are luns on the volume");
}
final TransactionLegacy txn = TransactionLegacy.currentTxn();
txn.start();
PoolVO pool = _poolDao.findById(volume.getPoolId());
if (pool == null) {
throw new InvalidParameterValueException("Failed to find pool for given volume");
//FIXME: choose a better exception. this is a db integrity exception
}
pool = _poolDao.acquireInLockTable(pool.getId());
if (pool == null) {
throw new ConcurrentModificationException("Failed to acquire lock on pool " + volume.getPoolId());
}
NaServer s = null;
try {
s = getServer(volume.getIpAddress(), volume.getUsername(), volume.getPassword());
//bring the volume down
xi0 = new NaElement("volume-offline");
xi0.addNewChild("name", volName);
s.invokeElem(xi0);
//now destroy it
xi1 = new NaElement("volume-destroy");
xi1.addNewChild("name", volName);
s.invokeElem(xi1);
//now delete from our records
_volumeDao.remove(volume.getId());
txn.commit();
} catch (UnknownHostException uhe) {
s_logger.warn("Unable to delete volume on filer ", uhe);
throw new ServerException("Unable to delete volume on filer", uhe);
} catch (NaAPIFailedException naf) {
s_logger.warn("Unable to delete volume on filer ", naf);
if (naf.getErrno() == 13040) {
s_logger.info("Deleting the volume: " + volName);
_volumeDao.remove(volume.getId());
txn.commit();
}
throw new ServerException("Unable to delete volume on filer", naf);
} catch (NaException nae) {
txn.rollback();
s_logger.warn("Unable to delete volume on filer ", nae);
throw new ServerException("Unable to delete volume on filer", nae);
} catch (IOException ioe) {
txn.rollback();
s_logger.warn("Unable to delete volume on filer ", ioe);
throw new ServerException("Unable to delete volume on filer", ioe);
} finally {
if (pool != null) {
_poolDao.releaseFromLockTable(pool.getId());
}
if (s != null)
s.close();
}
}
use of java.util.ConcurrentModificationException in project robovm by robovm.
the class ConcurrentModTest method testSet.
/*
* Test method for 'java.util.AbstractList.subList(int, int)'
*/
public void testSet() {
AbstractList al = new ArrayList();
Double one = new Double(1.0);
Double two = new Double(2.0);
Double three = new Double(3.0);
Double four = new Double(4.0);
al.add(one);
al.add(two);
al.add(three);
al.add(four);
List sub = al.subList(1, 3);
assertEquals(2, sub.size());
// the sub.get(1) is 3.0
assertTrue(((Double) sub.get(1)).doubleValue() <= 3.0);
assertTrue(((Double) sub.get(1)).doubleValue() > 2.0);
// remove the 2.0
al.remove(1);
try {
// illegal call the subList's method set(int,Object).
sub.set(1, two);
fail("It should throws ConcurrentModificationException.");
} catch (ConcurrentModificationException e) {
return;
}
}
use of java.util.ConcurrentModificationException in project robovm by robovm.
the class ConcurrentModTest method testGet.
/*
* Test method for 'java.util.AbstractList.subList(int, int)'
*/
public void testGet() {
AbstractList al = new ArrayList();
Double one = new Double(1.0);
Double two = new Double(2.0);
Double three = new Double(3.0);
Double four = new Double(4.0);
al.add(one);
al.add(two);
al.add(three);
al.add(four);
List sub = al.subList(1, 3);
assertEquals(2, sub.size());
// the sub.get(1) is 3.0
assertTrue(((Double) sub.get(1)).doubleValue() <= 3.0);
assertTrue(((Double) sub.get(1)).doubleValue() > 2.0);
// remove the 2.0
al.remove(1);
try {
// illegal call the subList's method get(int).
sub.get(1);
fail("It should throws ConcurrentModificationException.");
} catch (ConcurrentModificationException e) {
return;
}
try {
al.get(-1);
fail("IndexOutOfBoundsException expected");
} catch (IndexOutOfBoundsException ee) {
//expected
}
try {
al.get(al.size() + 1);
fail("IndexOutOfBoundsException expected");
} catch (IndexOutOfBoundsException ee) {
//expected
}
}
Aggregations