Java Code Examples for java.util.ConcurrentModificationException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project collections-generic, under directory /src/java/org/apache/commons/collections15/map/.

Source file: AbstractLinkedMap.java

  22 
vote

protected LinkEntry<K,V> nextEntry(){
  if (parent.modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
  if (next == parent.header) {
    throw new NoSuchElementException(AbstractHashedMap.NO_NEXT_ENTRY);
  }
  last=next;
  next=next.after;
  return last;
}
 

Example 2

From project android_external_guava, under directory /src/com/google/common/collect/.

Source file: AbstractMapBasedMultiset.java

  21 
vote

public void remove(){
  checkState(canRemove,"no calls to next() since the last call to remove()");
  int frequency=currentEntry.getValue().get();
  if (frequency <= 0) {
    throw new ConcurrentModificationException();
  }
  if (currentEntry.getValue().addAndGet(-1) == 0) {
    entryIterator.remove();
  }
  size--;
  canRemove=false;
}
 

Example 3

From project bel-editor, under directory /org.openbel.editor.core/src/org/openbel/editor/core/record/.

Source file: RecordFile.java

  21 
vote

/** 
 * {@inheritDoc}
 */
@Override public boolean hasNext(){
  if (expectedRecordCt != recordCt) {
    throw new ConcurrentModificationException();
  }
  if (currentRecord < recordCt) {
    return true;
  }
  return false;
}
 

Example 4

From project Cloud9, under directory /src/dist/edu/umd/cloud9/util/map/.

Source file: HMapID.java

  21 
vote

final Entry nextEntry(){
  if (modCount != expectedModCount)   throw new ConcurrentModificationException();
  Entry e=next;
  if (e == null)   throw new NoSuchElementException();
  if ((next=e.next) == null) {
    Entry[] t=table;
    while (index < t.length && (next=t[index++]) == null)     ;
  }
  current=e;
  return e;
}
 

Example 5

From project com.idega.content, under directory /src/java/com/idega/content/business/.

Source file: WebDAVFilePermissionResourceBean.java

  21 
vote

protected void checkPath(String path){
  if (this.currentList != null) {
    String currentListPath=this.currentList.getResourcePath();
    if (currentListPath == null && path == null) {
      return;
    }
    if ((((currentListPath == null || path == null) && currentListPath != path) || !((currentListPath != null) && currentListPath.equals(path)))) {
      throw new ConcurrentModificationException("Asking for ACL for path '" + path + "' while current ACL is for '"+ this.currentList.getResourcePath()+ "'. The #clear() method needs to be invoked first.");
    }
  }
}
 

Example 6

From project CraftMania, under directory /CraftMania/src/org/craftmania/utilities/.

Source file: FastArrayList.java

  21 
vote

/** 
 * Save the state of the <tt>ArrayList</tt> instance to a stream (that is, serialize it).
 * @serialData The length of the array backing the <tt>ArrayList</tt>instance is emitted (int), followed by all of its elements (each an <tt>Object</tt>) in the proper order.
 */
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
  int expectedModCount=modCount;
  s.defaultWriteObject();
  s.writeInt(elementData.length);
  for (int i=0; i < size; i++)   s.writeObject(elementData[i]);
  if (modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
}
 

Example 7

From project DeuceSTM, under directory /src/java/org/deuce/trove/.

Source file: THashIterator.java

  21 
vote

/** 
 * Returns the index of the next value in the data structure or a negative value if the iterator is exhausted.
 * @return an <code>int</code> value
 * @exception ConcurrentModificationException if the underlyingcollection's size has been modified since the iterator was created.
 */
protected final int nextIndex(){
  if (_expectedSize != _hash.size()) {
    throw new ConcurrentModificationException();
  }
  Object[] set=_object_hash._set;
  int i=_index;
  while (i-- > 0 && (set[i] == TObjectHash.FREE || set[i] == TObjectHash.REMOVED))   ;
  return i;
}
 

Example 8

From project drools-chance, under directory /drools-chance-core/src/main/java/org/drools/chance/core/util/.

Source file: IntHashMap.java

  21 
vote

/** 
 * @see java.util.Iterator#remove()
 */
public void remove(){
  if (current == null) {
    throw new IllegalStateException();
  }
  if (modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
  int k=current.key;
  current=null;
  removeEntryForKey(k);
  expectedModCount=modCount;
}
 

Example 9

From project elasticsearch-index-termlist, under directory /src/main/java/org/elasticsearch/action/termlist/.

Source file: CompactHashSet.java

  21 
vote

public void remove(){
  if (modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
  if (lastReturned == -1 || lastReturned == -2) {
    throw new IllegalStateException();
  }
  if (objects[lastReturned] != null && objects[lastReturned] != deletedObject) {
    objects[lastReturned]=deletedObject;
    elements--;
    modCount++;
    expectedModCount=modCount;
  }
}
 

Example 10

From project elw, under directory /datapath/src/main/java/gnu/trove/.

Source file: TIterator.java

  21 
vote

/** 
 * Removes the last entry returned by the iterator. Invoking this method more than once for a single entry will leave the underlying data structure in a confused state.
 */
public void remove(){
  if (_expectedSize != _hash.size()) {
    throw new ConcurrentModificationException();
  }
  try {
    _hash.tempDisableAutoCompaction();
    _hash.removeAt(_index);
  }
  finally {
    _hash.reenableAutoCompaction(false);
  }
  _expectedSize--;
}
 

Example 11

From project fastjson, under directory /src/main/java/com/alibaba/fastjson/util/.

Source file: AntiCollisionHashMap.java

  21 
vote

final Entry<K,V> nextEntry(){
  if (modCount != expectedModCount)   throw new ConcurrentModificationException();
  Entry<K,V> e=next;
  if (e == null)   throw new NoSuchElementException();
  if ((next=e.next) == null) {
    Entry[] t=table;
    while (index < t.length && (next=t[index++]) == null)     ;
  }
  current=e;
  return e;
}
 

Example 12

From project formic, under directory /src/java/org/apache/commons/collections/map/.

Source file: AbstractHashedMap.java

  21 
vote

public void remove(){
  if (last == null) {
    throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
  }
  if (parent.modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
  parent.remove(last.getKey());
  last=null;
  expectedModCount=parent.modCount;
}
 

Example 13

From project gatein-naming, under directory /src/main/java/org/gatein/naming/util/.

Source file: FastCopyHashMap.java

  21 
vote

protected Entry<K,V> nextEntry(){
  if (modCount != expectedCount)   throw new ConcurrentModificationException();
  if (!hasNext && !hasNext())   throw new NoSuchElementException();
  current=next++;
  hasNext=false;
  return table[current];
}
 

Example 14

From project indextank-engine, under directory /cojen-2.2.1-sources/org/cojen/util/.

Source file: IntHashMap.java

  21 
vote

public Object next(){
  if (modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
  while (entry == null && index > 0) {
    entry=table[--index];
  }
  if (entry != null) {
    Entry e=lastReturned=entry;
    entry=e.next;
    return type == KEYS ? e.getKey() : (type == VALUES ? e.value : e);
  }
  throw new NoSuchElementException();
}
 

Example 15

From project jandex, under directory /src/main/java/org/jboss/jandex/.

Source file: StrongInternPool.java

  21 
vote

@SuppressWarnings("unchecked") public E next(){
  if (modCount != expectedCount)   throw new ConcurrentModificationException();
  if (!hasNext && !hasNext())   throw new NoSuchElementException();
  current=next++;
  hasNext=false;
  return (E)unmaskNull(table[current]);
}
 

Example 16

From project jboss-logmanager, under directory /src/main/java/org/jboss/logmanager/.

Source file: FastCopyHashMap.java

  21 
vote

protected Entry<K,V> nextEntry(){
  if (modCount != expectedCount)   throw new ConcurrentModificationException();
  if (!hasNext && !hasNext())   throw new NoSuchElementException();
  current=next++;
  hasNext=false;
  return table[current];
}
 

Example 17

From project jboss-modules, under directory /src/main/java/org/jboss/modules/.

Source file: FastCopyHashSet.java

  21 
vote

public E next(){
  if (modCount != expectedCount)   throw new ConcurrentModificationException();
  if (!hasNext && !hasNext())   throw new NoSuchElementException();
  current=next++;
  hasNext=false;
  return table[current];
}
 

Example 18

From project jboss-msc, under directory /src/main/java/org/jboss/msc/service/.

Source file: IdentityHashSet.java

  21 
vote

@SuppressWarnings("unchecked") public E next(){
  if (modCount != expectedCount)   throw new ConcurrentModificationException();
  if (!hasNext && !hasNext())   throw new NoSuchElementException();
  current=next++;
  hasNext=false;
  return (E)table[current];
}
 

Example 19

From project JDBM3, under directory /src/test/java/org/apache/jdbm/.

Source file: LongTreeMap.java

  21 
vote

final void makeNext(){
  if (expectedModCount != modCount) {
    throw new ConcurrentModificationException();
  }
 else   if (node == null) {
    throw new NoSuchElementException();
  }
  lastNode=node;
  node=successor(node);
}
 

Example 20

From project jMemorize, under directory /src/jmemorize/util/.

Source file: EquivalenceClassSet.java

  21 
vote

public boolean hasNext(){
  if (m_changeID != localChangeID) {
    throw new ConcurrentModificationException();
  }
  if (localEqvClassIter.hasNext() || (localItemIter != null && localItemIter.hasNext())) {
    return true;
  }
  return false;
}
 

Example 21

From project Json-lib, under directory /src/main/java/net/sf/json/.

Source file: JSONArray.java

  21 
vote

public void remove(){
  if (lastIndex == -1)   throw new IllegalStateException();
  try {
    JSONArray.this.remove(lastIndex);
    if (lastIndex < currentIndex) {
      currentIndex--;
    }
    lastIndex=-1;
  }
 catch (  IndexOutOfBoundsException e) {
    throw new ConcurrentModificationException();
  }
}
 

Example 22

From project keepassdroid, under directory /src/org/apache/commons/collections/map/.

Source file: AbstractHashedMap.java

  21 
vote

public void remove(){
  if (last == null) {
    throw new IllegalStateException(AbstractHashedMap.REMOVE_INVALID);
  }
  if (parent.modCount != expectedModCount) {
    throw new ConcurrentModificationException();
  }
  parent.remove(last.getKey());
  last=null;
  expectedModCount=parent.modCount;
}
 

Example 23

From project MachinaCraft, under directory /MachinaCore/src/gnu/trove/impl/hash/.

Source file: THashIterator.java

  21 
vote

/** 
 * Removes the last entry returned by the iterator. Invoking this method more than once for a single entry will leave the underlying data structure in a confused state.
 */
public void remove(){
  if (_expectedSize != _hash.size()) {
    throw new ConcurrentModificationException();
  }
  try {
    _hash.tempDisableAutoCompaction();
    _hash.removeAt(_index);
  }
  finally {
    _hash.reenableAutoCompaction(false);
  }
  _expectedSize--;
}
 

Example 24

From project mavuno, under directory /src/edu/umd/cloud9/util/map/.

Source file: HMapIF.java

  21 
vote

final Entry nextEntry(){
  if (modCount != expectedModCount)   throw new ConcurrentModificationException();
  Entry e=next;
  if (e == null)   throw new NoSuchElementException();
  if ((next=e.next) == null) {
    Entry[] t=table;
    while (index < t.length && (next=t[index++]) == null)     ;
  }
  current=e;
  return e;
}
 

Example 25

From project OpenTripPlanner, under directory /opentripplanner-routing/src/main/java/org/opentripplanner/routing/edgetype/.

Source file: TimetableResolver.java

  21 
vote

/** 
 * @return whether or not the update was actually applied
 */
public boolean update(TableTripPattern pattern,UpdateBlock block){
synchronized (this) {
    if (dirty == null)     throw new ConcurrentModificationException("This TimetableResolver is read-only.");
    Timetable tt=resolve(pattern);
    if (!dirty.contains(tt)) {
      tt=tt.copy();
      timetables.put(pattern,tt);
      dirty.add(tt);
    }
    return tt.update(block);
  }
}
 

Example 26

From project orientdb, under directory /commons/src/main/java/com/orientechnologies/common/collection/.

Source file: AbstractEntryIterator.java

  21 
vote

final OMVRBTreeEntry<K,V> nextEntry(){
  if (next == null)   throw new NoSuchElementException();
  if (tree.pageIndex < next.getSize() - 1) {
    tree.pageIndex++;
  }
 else {
    if (tree.modCount != expectedModCount)     throw new ConcurrentModificationException();
    tree.pageIndex=0;
    next=OMVRBTree.successor(next);
    lastReturned=next;
  }
  return next;
}
 

Example 27

From project orion.server, under directory /bundles/org.eclipse.orion.server.hosting/src/org/eclipse/orion/internal/server/hosting/.

Source file: SiteHostingService.java

  21 
vote

@Override public void stop(SiteConfiguration siteConfig,WebUser user) throws SiteHostingException {
synchronized (sites) {
    IHostedSite site=get(siteConfig,user);
    if (site == null) {
      return;
    }
    if (!sites.remove(site.getHost(),site)) {
      throw new ConcurrentModificationException("Table was modified concurrently");
    }
  }
}
 

Example 28

From project patricia-trie, under directory /src/main/java/org/ardverk/collection/.

Source file: AbstractPatriciaTrie.java

  21 
vote

/** 
 * Returns the next  {@link TrieEntry}
 */
protected TrieEntry<K,V> nextEntry(){
  if (expectedModCount != AbstractPatriciaTrie.this.modCount) {
    throw new ConcurrentModificationException();
  }
  TrieEntry<K,V> e=next;
  if (e == null) {
    throw new NoSuchElementException();
  }
  next=findNext(e);
  current=e;
  return e;
}
 

Example 29

From project platform_external_guava, under directory /src/com/google/common/collect/.

Source file: AbstractMapBasedMultiset.java

  21 
vote

public void remove(){
  checkState(canRemove,"no calls to next() since the last call to remove()");
  int frequency=currentEntry.getValue().get();
  if (frequency <= 0) {
    throw new ConcurrentModificationException();
  }
  if (currentEntry.getValue().addAndGet(-1) == 0) {
    entryIterator.remove();
  }
  size--;
  canRemove=false;
}
 

Example 30

From project replication-benchmarker, under directory /src/main/java/collect/.

Source file: ArraySkipList.java

  21 
vote

@SuppressWarnings("unchecked") @Override public E next(){
  checkForComodification();
  int i=cursor;
  if (i >= size) {
    throw new NoSuchElementException();
  }
  Object[] elementData=ArraySkipList.this.elementData;
  if (i >= elementData.length) {
    throw new ConcurrentModificationException();
  }
  cursor=i + 1;
  nextCursor();
  return (E)elementData[lastRet=i];
}
 

Example 31

From project simple-patricia-trie, under directory /src/main/java/org/ardverk/collection/spt/.

Source file: PatriciaTrie.java

  21 
vote

@Override public E next(){
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  if (expectedModCount != PatriciaTrie.this.modCount) {
    throw new ConcurrentModificationException();
  }
  current=entries[index++];
  return next(current);
}
 

Example 32

From project solder, under directory /impl/src/main/java/org/jboss/solder/util/collections/.

Source file: WrappedCollection.java

  21 
vote

/** 
 * If the delegate collection is empty, but the multimap has values for the key, replace the delegate with the new collection for the key. <p/> <p/> For a subcollection, refresh its ancestor and validate that the ancestor delegate hasn't changed.
 */
void refreshIfEmpty(){
  if (ancestor != null) {
    ancestor.refreshIfEmpty();
    if (ancestor.getDelegate() != ancestorDelegate) {
      throw new ConcurrentModificationException();
    }
  }
 else   if (delegate.isEmpty()) {
    Collection<V> newDelegate=abstractMultimap.map.get(key);
    if (newDelegate != null) {
      delegate=newDelegate;
    }
  }
}
 

Example 33

From project SpoutAPI, under directory /src/main/java/org/spout/api/datatable/.

Source file: ManagedHashMap.java

  21 
vote

@Override public Map.Entry<String,Serializable> next(){
  if (map.size() != expectedAmount) {
    throw new ConcurrentModificationException();
  }
  index++;
  current=next;
  if (index < expectedAmount) {
    next=list.get(index);
  }
 else {
    next=null;
  }
  return new Entry(map.getStringKey(keys.get(index - 1)),current);
}
 

Example 34

From project CircDesigNA, under directory /src/org/apache/commons/math/.

Source file: MathRuntimeException.java

  20 
vote

/** 
 * Constructs a new <code>ConcurrentModificationException</code> with specified formatted detail message. Message formatting is delegated to  {@link java.text.MessageFormat}.
 * @param pattern format specifier
 * @param arguments format arguments
 * @return built exception
 * @since 2.2
 */
public static ConcurrentModificationException createConcurrentModificationException(final Localizable pattern,final Object... arguments){
  return new ConcurrentModificationException(){
    /** 
 * Serializable version identifier. 
 */
    private static final long serialVersionUID=-1878427236170442052L;
    /** 
 * {@inheritDoc} 
 */
    @Override public String getMessage(){
      return buildMessage(Locale.US,pattern,arguments);
    }
    /** 
 * {@inheritDoc} 
 */
    @Override public String getLocalizedMessage(){
      return buildMessage(Locale.getDefault(),pattern,arguments);
    }
  }
;
}
 

Example 35

From project greenDAO, under directory /DaoTest/src/de/greenrobot/daotest/performance/target/.

Source file: LongHashMapJDBM.java

  20 
vote

public E next(){
  if (expectedModCount != associatedMap.modCount) {
    throw new ConcurrentModificationException();
  }
  if (!hasNext()) {
    throw new NoSuchElementException();
  }
  Entry<VT> result;
  Entry<VT> _entry=entry;
  if (_entry == null) {
    result=lastEntry=associatedMap.elementData[position++];
    entry=lastEntry.next;
  }
 else {
    if (lastEntry.next != _entry) {
      lastEntry=lastEntry.next;
    }
    result=_entry;
    entry=_entry.next;
  }
  canRemove=true;
  return type.get(result);
}
 

Example 36

From project karaf, under directory /util/src/main/java/org/apache/karaf/util/collections/.

Source file: CopyOnWriteArrayIdentityList.java

  20 
vote

/** 
 * @see java.util.List#get(int)
 */
public Object get(int index){
  SubListReadData data=read;
  if (data.data != list.getData()) {
    list.lock.lock();
    try {
      data=read;
      if (data.data != list.getData()) {
        throw new ConcurrentModificationException();
      }
    }
  finally {
      list.lock.unlock();
    }
  }
  checkIndexExlusive(index,data.size);
  return data.data[index + start];
}
 

Example 37

From project morphia, under directory /morphia/src/main/java/com/google/code/morphia/.

Source file: DatastoreImpl.java

  20 
vote

protected <T>WriteResult tryVersionedUpdate(DBCollection dbColl,T entity,DBObject dbObj,WriteConcern wc,DB db,MappedClass mc){
  WriteResult wr=null;
  if (mc.getFieldsAnnotatedWith(Version.class).isEmpty())   return wr;
  MappedField mfVersion=mc.getFieldsAnnotatedWith(Version.class).get(0);
  String versionKeyName=mfVersion.getNameToStore();
  Long oldVersion=(Long)mfVersion.getFieldValue(entity);
  long newVersion=VersionHelper.nextValue(oldVersion);
  dbObj.put(versionKeyName,newVersion);
  if (oldVersion != null && oldVersion > 0) {
    Object idValue=dbObj.get(Mapper.ID_KEY);
    UpdateResults<T> res=update(find(dbColl.getName(),(Class<T>)entity.getClass()).filter(Mapper.ID_KEY,idValue).filter(versionKeyName,oldVersion),dbObj,false,false,wc);
    wr=res.getWriteResult();
    if (res.getUpdatedCount() != 1)     throw new ConcurrentModificationException("Entity of class " + entity.getClass().getName() + " (id='"+ idValue+ "',version='"+ oldVersion+ "') was concurrently updated.");
  }
 else   if (wc == null)   wr=dbColl.save(dbObj);
 else   wr=dbColl.save(dbObj,wc);
  mfVersion.setFieldValue(entity,newVersion);
  return wr;
}
 

Example 38

From project nuxeo-tycho-osgi, under directory /nuxeo-core/nuxeo-core-api/src/main/java/org/nuxeo/ecm/core/api/repository/cache/.

Source file: DirtyUpdateChecker.java

  20 
vote

public static void check(DocumentModel doc){
  ThreadContext ctx=DirtyUpdateInvokeBridge.getThreadContext();
  if (ctx == null) {
    return;
  }
  long modified;
  try {
    Property modifiedProp=doc.getProperty("dc:modified");
    if (modifiedProp == null) {
      return;
    }
    Date modifiedDate=modifiedProp.getValue(Date.class);
    if (modifiedDate == null) {
      return;
    }
    modified=modifiedDate.getTime();
  }
 catch (  Exception e) {
    throw new ClientRuntimeException("cannot fetch dc modified for doc " + doc,e);
  }
  long tag=ctx.tag.longValue();
  if (tag >= modified) {
    return;
  }
  long invoked=ctx.invoked.longValue();
  if (invoked <= modified) {
    return;
  }
  String message=String.format("%s is outdated : cache %s - op start %s - doc %s",doc.getId(),new Date(tag),new Date(invoked),new Date(modified));
  throw new ConcurrentModificationException(message);
}
 

Example 39

From project AdminCmd, under directory /src/main/java/be/Balor/Manager/.

Source file: CommandManager.java

  19 
vote

@Override public void run(){
  try {
    processCmd();
    plotters.get(acc.getCommandClass()).increment();
  }
 catch (  final ConcurrentModificationException cme) {
    ACPluginManager.getScheduler().scheduleSyncDelayedTask(corePlugin,new SyncCommand(acc));
  }
catch (  final WorldNotLoaded e) {
    String message=e.getMessage();
    if (message == null || message == "") {
      message="This world is not loaded!";
    }
    final HashMap<String,String> replace=new HashMap<String,String>();
    replace.put("message",message);
    LocaleHelper.WORLD_NOT_LOADED.sendLocale(acc.getSender(),replace);
  }
catch (  final PlayerNotFound e) {
    e.getSender().sendMessage(e.getMessage());
  }
catch (  final ActionNotPermitedException e) {
    e.sendMessage();
  }
catch (  final Throwable t) {
    ACLogger.severe(acc.debug(),t);
    Utils.broadcastMessage("[AdminCmd] " + acc.debug());
  }
}
 

Example 40

From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/ai/desires/.

Source file: DesireQueue.java

  19 
vote

/** 
 * Iterates over desires, you have to provide iteration handler and optionally filters.<br> <br> Handlers and filters can't call following methods: <ul> <li> {@link #addDesire(Desire)}</li> <li> {@link #poll()}</li> <li> {@link #removeDesire(Desire)}</li> </ul> <p/> However, method  {@link #clear() can be called}.
 * @param handler DesireIterationhandler that will be called on the iteration
 * @param filters optional filters that will prevent passing unneede desires to the handler
 * @throws java.util.ConcurrentModificationException only if called handler or filter modified this queue
 * @see com.aionemu.gameserver.ai.desires.DesireIteratorFilter
 * @see com.aionemu.gameserver.ai.desires.DesireIteratorFilter#isOk(Desire)
 * @see com.aionemu.gameserver.ai.desires.DesireIteratorHandler
 * @see com.aionemu.gameserver.ai.desires.DesireIteratorHandler#next(Desire,java.util.Iterator)
 */
public synchronized void iterateDesires(DesireIteratorHandler handler,DesireIteratorFilter... filters) throws ConcurrentModificationException {
  if (queue == null) {
    return;
  }
  Iterator<Desire> iterator=queue.iterator();
  outer:   while (iterator.hasNext()) {
    Desire desire=iterator.next();
    if (filters != null && filters.length > 0) {
      for (      DesireIteratorFilter filter : filters) {
        if (!filter.isOk(desire)) {
          continue outer;
        }
      }
    }
    handler.next(desire,iterator);
  }
}
 

Example 41

From project b3log-latke, under directory /latke-gae/src/main/java/org/b3log/latke/repository/gae/.

Source file: GAETransaction.java

  19 
vote

/** 
 * Commits this transaction with  {@value #COMMIT_RETRIES} times of retries.<p> If the transaction committed, clears all transaction cache. If the  {@link #clearQueryCache flag} is {@code true}, clears global  cache regions. </p> <p> <b>Throws</b>:<br/> {@link java.util.ConcurrentModificationException} - if commits failed</p>
 * @see #COMMIT_RETRIES
 * @see #cache
 * @see PageCaches#removeAll() 
 */
@Override public void commit(){
  int retries=COMMIT_RETRIES;
  while (true) {
    try {
      appEngineDatastoreTx.commit();
      for (      final Entry<String,JSONObject> cached : cache.entrySet()) {
        final String cacheKey=GAERepository.CACHE_KEY_PREFIX + cached.getKey();
        final JSONObject value=cached.getValue();
        if (null == value) {
          GAERepository.CACHE.remove(cacheKey);
        }
 else {
          GAERepository.CACHE.put(cacheKey,value);
        }
      }
      cache.clear();
      GAERepository.TX.set(null);
      if (clearQueryCache) {
        PageCaches.removeAll();
      }
      break;
    }
 catch (    final ConcurrentModificationException e) {
      if (retries == 0) {
        throw e;
      }
      --retries;
      LOGGER.log(Level.WARNING,"Retrying to commit this transaction[id={0}, app={1}]",new Object[]{appEngineDatastoreTx.getId(),appEngineDatastoreTx.getApp()});
    }
  }
}
 

Example 42

From project Carnivore, under directory /org/rsg/carnivore/cache/.

Source file: SpeedometerCache.java

  19 
vote

public void pruneToFrame(){
  try {
    Iterator<?> iterator=iterator();
    while (iterator.hasNext()) {
      TimestampedObject to=(TimestampedObject)iterator.next();
      if (to.timestamp < (TimeUtilities.currentTime() - frame)) {
        iterator.remove();
      }
    }
  }
 catch (  ConcurrentModificationException e) {
    try {
      Thread.sleep(100);
      pruneToFrame();
    }
 catch (    InterruptedException ie) {
      ie.printStackTrace();
    }
  }
}
 

Example 43

From project chromattic, under directory /common/src/test/java/org/chromattic/test/common/collection/.

Source file: FilterIteratorTestCase.java

  19 
vote

public void testConcurrentModification1(){
  LinkedList<Integer> tmp=new LinkedList<Integer>(integers);
  Bilto iterator=new Bilto(tmp.iterator());
  tmp.removeLast();
  try {
    iterator.hasNext();
    fail();
  }
 catch (  ConcurrentModificationException e) {
  }
  try {
    iterator.next();
    fail();
  }
 catch (  ConcurrentModificationException e) {
  }
  try {
    iterator.remove();
    fail();
  }
 catch (  ConcurrentModificationException e) {
  }
}
 

Example 44

From project dawn-tango, under directory /org.dawb.tango.extensions/src/org/dawb/tango/extensions/console/.

Source file: TangoSpecPartitioner.java

  19 
vote

public synchronized void moveCommand(final int direction){
  if (undoStack.isEmpty())   return;
  if (stackNavigation == null)   stackNavigation=undoStack.listIterator();
  try {
    String cmd="";
    if (direction == -1) {
      if (stackNavigation.hasNext()) {
        cmd=stackNavigation.next();
      }
 else {
        return;
      }
    }
 else {
      if (stackNavigation.hasPrevious()) {
        cmd=stackNavigation.previous();
      }
    }
    clearCommand();
    safeAppend(cmd);
    setCaretLocation(false);
  }
 catch (  ConcurrentModificationException ce) {
    stackNavigation=null;
  }
}
 

Example 45

From project Diver, under directory /org.eclipse.zest.custom.sequence/src/org/eclipse/zest/custom/sequence/visuals/.

Source file: MessageBasedSequenceVisuals.java

  19 
vote

@Override protected void doRunInUIThread(SimpleProgressMonitor monitor) throws InvocationTargetException {
  chart.getSequenceControl().setCursor(chart.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
  callStack=new HashSet<Activation>();
  MessageBasedSequenceVisuals.this.refreshing=true;
  monitor.beginTask("Refreshing Chart",5001);
  ArrayList<UMLItem> newSelection=new ArrayList<UMLItem>();
  for (  UMLItem item : currentSelection) {
    if (!item.isDisposed()) {
      newSelection.add(item);
    }
  }
  monitor.worked(1);
  readAndDispatch();
  try {
    updateChart(monitor);
    selectionDecorator.refresh();
  }
 catch (  ConcurrentModificationException e) {
    callStack.clear();
    monitor.done();
  }
  MessageBasedSequenceVisuals.this.refreshing=false;
  chart.getSequenceControl().setCursor(null);
}
 

Example 46

From project DTRules, under directory /dtrules-engine/src/main/java/com/dtrules/interpreter/.

Source file: RArray.java

  19 
vote

/** 
 * Implements the execution behavior of an RArray
 */
public void execute(DTState state) throws RulesException {
  if (code == null) {
    code=array.toArray(new IRObject[0]);
    pair.code=code;
    array=null;
    pair.array=null;
  }
  for (int cnt=0; cnt < code.length; cnt++) {
    IRObject obj=code[cnt];
    try {
      obj.arrayExecute(state);
    }
 catch (    ConcurrentModificationException e) {
      String ps=generatePostfix(cnt);
      RulesException re=new RulesException("access error",array.get(cnt).postFix(),e.toString() + "\r\n" + "This happens generally when you have attempted to modify an array\r\n "+ "which is in the context because you are iterating over its contents\r\n"+ "with a ForAll operator."+ "");
      re.setPostfix(ps);
      throw re;
    }
catch (    RuntimeException e) {
      String ps=generatePostfix(cnt);
      RulesException re=new RulesException("runtime error","RArray",e.toString());
      re.setPostfix(ps);
      throw re;
    }
catch (    RulesException e) {
      String ps=generatePostfix(cnt);
      e.setPostfix(ps);
      throw e;
    }
  }
}
 

Example 47

From project EasySOA, under directory /easysoa-registry/easysoa-registry-rest/src/main/java/org/easysoa/rest/servicefinder/.

Source file: ServiceFinderComponent.java

  19 
vote

public void unregisterContribution(Object contribution,String extensionPoint,ComponentInstance contributor) throws Exception {
synchronized (strategies) {
    if (extensionPoint.equals(EXTENSTION_POINT_STRATEGIES)) {
      ServiceFinderStrategyDescriptor finderDescriptor=(ServiceFinderStrategyDescriptor)contribution;
      if (finderDescriptor.enabled) {
        Class<?> finderClass=Class.forName(finderDescriptor.implementation.trim());
        try {
          for (          ServiceFinderStrategy finder : strategies) {
            if (finder.getClass().equals(finderClass)) {
              strategies.remove(finder);
            }
          }
        }
 catch (        ConcurrentModificationException e) {
          log.warn("Failed to unregister contribution: " + e.getMessage());
        }
      }
    }
  }
}
 

Example 48

From project eclipse-integration-cloudfoundry, under directory /org.cloudfoundry.ide.eclipse.server.tests/src/org/cloudfoundry/ide/eclipse/server/tests/sts/util/.

Source file: ManagedTestSuite.java

  19 
vote

private void dumpSystemInfo(){
  try {
    Properties p=System.getProperties();
    if (Platform.isRunning()) {
      p.put("build.system",Platform.getOS() + "-" + Platform.getOSArch()+ "-"+ Platform.getWS());
    }
 else {
      p.put("build.system","standalone");
    }
    String info="System: ${os.name} ${os.version} (${os.arch}) / ${build.system} / ${java.vendor} ${java.vm.name} ${java.version}";
    for (    Entry<Object,Object> entry : p.entrySet()) {
      info=info.replaceFirst(Pattern.quote("${" + entry.getKey() + "}"),entry.getValue().toString());
    }
    System.err.println(info);
    System.err.print("Proxy : " + CloudFoundryTestUtil.getProxy("google.com",IProxyData.HTTP_PROXY_TYPE) + " (Platform)");
    try {
      System.err.print(" / " + ProxySelector.getDefault().select(new URI("http://google.com")) + " (Java)");
    }
 catch (    URISyntaxException e) {
    }
    System.err.println();
    System.err.println();
  }
 catch (  ConcurrentModificationException e) {
    e.printStackTrace();
  }
}
 

Example 49

From project eclipse-integration-commons, under directory /org.springsource.ide.eclipse.commons.tests.util/src/org/springsource/ide/eclipse/commons/tests/util/.

Source file: ManagedTestSuite.java

  19 
vote

private void dumpSystemInfo(){
  try {
    if (Platform.isRunning() && CommonsNetPlugin.getProxyService() != null && CommonsNetPlugin.getProxyService().isSystemProxiesEnabled() && !CommonsNetPlugin.getProxyService().hasSystemProxies()) {
      System.err.println("Forcing manual proxy configuration");
      CommonsNetPlugin.getProxyService().setSystemProxiesEnabled(false);
      CommonsNetPlugin.getProxyService().setProxiesEnabled(true);
    }
    Properties p=System.getProperties();
    if (Platform.isRunning()) {
      p.put("build.system",Platform.getOS() + "-" + Platform.getOSArch()+ "-"+ Platform.getWS());
    }
 else {
      p.put("build.system","standalone");
    }
    String info="System: ${os.name} ${os.version} (${os.arch}) / ${build.system} / ${java.vendor} ${java.vm.name} ${java.version}";
    for (    Entry<Object,Object> entry : p.entrySet()) {
      info=info.replaceFirst(Pattern.quote("${" + entry.getKey() + "}"),entry.getValue().toString());
    }
    System.err.println(info);
    System.err.print("Proxy : " + WebUtil.getProxy("google.com",IProxyData.HTTP_PROXY_TYPE) + " (Platform)");
    try {
      System.err.print(" / " + ProxySelector.getDefault().select(new URI("http://google.com")) + " (Java)");
    }
 catch (    URISyntaxException e) {
    }
    System.err.println();
    System.err.println();
  }
 catch (  ConcurrentModificationException e) {
    e.printStackTrace();
  }
}
 

Example 50

From project eclipse-integration-gradle, under directory /org.springsource.ide.eclipse.gradle.core.test/src/org/springsource/ide/eclipse/gradle/core/test/util/.

Source file: ManagedTestSuite.java

  19 
vote

private void dumpSystemInfo(){
  try {
    Properties p=System.getProperties();
    if (Platform.isRunning()) {
      p.put("build.system",Platform.getOS() + "-" + Platform.getOSArch()+ "-"+ Platform.getWS());
    }
 else {
      p.put("build.system","standalone");
    }
    String info="System: ${os.name} ${os.version} (${os.arch}) / ${build.system} / ${java.vendor} ${java.vm.name} ${java.version}";
    for (    Entry<Object,Object> entry : p.entrySet()) {
      info=info.replaceFirst(Pattern.quote("${" + entry.getKey() + "}"),entry.getValue().toString());
    }
    System.err.println();
    System.err.println();
  }
 catch (  ConcurrentModificationException e) {
    e.printStackTrace();
  }
}
 

Example 51

From project Hphoto, under directory /src/test/org/apache/hadoop/hbase/.

Source file: MultiRegionTable.java

  19 
vote

private static void compact(final MiniHBaseCluster cluster,final HRegionInfo r) throws IOException {
  LOG.info("Starting compaction");
  for (  MiniHBaseCluster.RegionServerThread thread : cluster.regionThreads) {
    SortedMap<Text,HRegion> regions=thread.getRegionServer().onlineRegions;
    for (int i=0; i < 10; i++) {
      try {
        for (        HRegion online : regions.values()) {
          if (online.getRegionName().toString().equals(r.getRegionName().toString())) {
            online.compactStores();
          }
        }
        break;
      }
 catch (      ConcurrentModificationException e) {
        LOG.warn("Retrying because ..." + e.toString() + " -- one or "+ "two should be fine");
        continue;
      }
    }
  }
}
 

Example 52

From project JaamSim, under directory /com/sandwell/JavaSimulation/.

Source file: Util.java

  19 
vote

public static String propertyFormatObject(Object value){
  String ret="";
  if (value == null)   ret="<null>";
 else   if (value instanceof Appearance && ((Appearance)value).getColoringAttributes() != null) {
    ret=((Appearance)value).getColoringAttributes().toString();
  }
 else   if (value instanceof double[]) {
    ret=propertyFormatDoubleArray((double[])value);
  }
 else {
    try {
      ret=value.toString();
    }
 catch (    ConcurrentModificationException e) {
      return "";
    }
  }
  return ret;
}
 

Example 53

From project jdcbot, under directory /src/org/elite/jdcbot/framework/.

Source file: MultiHubsAdapter.java

  19 
vote

public int getTotalHubsConnectedToAsOps(){
  try {
    int count=0;
    for (    jDCBot bot : bots) {
      if (bot.isOp())       count++;
    }
    return count;
  }
 catch (  ConcurrentModificationException cme) {
    logger.warn("ConcurrentModificationException so sending TotalHubsConnectedToCount" + "instead of TotalHubsConnectedToAsOps");
    return getTotalHubsConnectedToCount();
  }
}
 

Example 54

From project jena-tdb, under directory /src/test/java/com/hp/hpl/jena/tdb/store/.

Source file: TestConcurrentAccess.java

  19 
vote

@Test(expected=ConcurrentModificationException.class) public void mrswGraph2(){
  Model m=create().getDefaultModel();
  Resource r=m.createResource("x");
  ExtendedIterator<Statement> iter1=m.listStatements(r,null,(RDFNode)null);
  assertNotNull(iter1.next());
  Triple t=SSE.parseTriple("(<y> <p> 99)");
  m.getGraph().add(t);
  iter1.hasNext();
}
 

Example 55

From project jpcap, under directory /src/java/net/sourceforge/jpcap/client/.

Source file: PacketVisualizationCanvas.java

  19 
vote

/** 
 * Repaint all the hosts and communications on this canvas.
 */
public void paint(Graphics g){
  super.paint(g);
  width=super.getWidth();
  height=super.getHeight();
  Iterator hIterator=hostMap.values().iterator();
  while (hIterator.hasNext()) {
    try {
      HostRenderer hs=(HostRenderer)hIterator.next();
      hs.paint();
    }
 catch (    ConcurrentModificationException e) {
      break;
    }
  }
  Iterator cIterator=commMap.values().iterator();
  while (cIterator.hasNext()) {
    try {
      CommRenderer cs=(CommRenderer)cIterator.next();
      cs.paint();
    }
 catch (    ConcurrentModificationException e) {
      break;
    }
  }
}
 

Example 56

From project juzu, under directory /core/src/test/java/inject/constructorthrowsruntime/.

Source file: ConstructorThrowsRuntimeTestCase.java

  19 
vote

@Test public void test() throws Exception {
  init();
  bootstrap.declareBean(Bean.class,null,null,null);
  boot();
  try {
    getBean(Bean.class);
    throw failure("Was expecting exception");
  }
 catch (  InvocationTargetException e) {
    assertInstanceOf(ConcurrentModificationException.class,e.getCause());
  }
}
 

Example 57

From project kevoree-library, under directory /android/org.kevoree.library.android.osmdroid/src/main/java/org/osmdroid/tileprovider/modules/.

Source file: MapTileModuleProviderBase.java

  19 
vote

private MapTileRequestState nextTile(){
synchronized (mPending) {
    MapTile result=null;
    Iterator<MapTile> iterator=mPending.keySet().iterator();
    while (iterator.hasNext()) {
      try {
        final MapTile tile=iterator.next();
        if (!mWorking.containsKey(tile)) {
          result=tile;
        }
      }
 catch (      final ConcurrentModificationException e) {
        if (DEBUGMODE) {
          logger.warn("ConcurrentModificationException break: " + (result != null));
        }
        if (result != null) {
          break;
        }
 else {
          iterator=mPending.keySet().iterator();
        }
      }
    }
    if (result != null) {
      mWorking.put(result,mPending.get(result));
    }
    return (result != null ? mPending.get(result) : null);
  }
}
 

Example 58

From project l2jserver2, under directory /l2jserver2-gameserver/l2jserver2-gameserver-core/src/main/java/com/l2jserver/game/ai/desires/.

Source file: DesireQueue.java

  19 
vote

/** 
 * Iterates over desires, you have to provide iteration handler and optionally filters.<br> <br> Handlers and filters can't call following methods: <ul> <li> {@link #addDesire(Desire)}</li> <li> {@link #poll()}</li> <li> {@link #removeDesire(Desire)}</li> </ul> <p/> However, method  {@link #clear() can be called}.
 * @param handler DesireIterationhandler that will be called on the iteration
 * @param filters optional filters that will prevent passing unneeded desires to the handler
 * @throws java.util.ConcurrentModificationException only if called handler or filter modified this queue
 * @see com.l2jserver.game.ai.desires.DesireIteratorFilter
 * @see com.l2jserver.game.ai.desires.DesireIteratorFilter#isOk(Desire)
 * @see com.l2jserver.game.ai.desires.DesireIteratorHandler
 * @see com.l2jserver.game.ai.desires.DesireIteratorHandler#next(Desire,java.util.Iterator)
 */
public synchronized void iterateDesires(DesireIteratorHandler handler,DesireIteratorFilter... filters) throws ConcurrentModificationException {
  if (queue == null) {
    return;
  }
  Iterator<Desire> iterator=queue.iterator();
  outer:   while (iterator.hasNext()) {
    Desire desire=iterator.next();
    if (filters != null && filters.length > 0) {
      for (      DesireIteratorFilter filter : filters) {
        if (!filter.isOk(desire)) {
          continue outer;
        }
      }
    }
    handler.next(desire,iterator);
  }
}
 

Example 59

From project mylyn.context, under directory /org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/.

Source file: InterestDecoratorLightweight.java

  19 
vote

public void decorate(Object element,IDecoration decoration){
  if (ContextCore.getContextManager() != null && !ContextCore.getContextManager().isContextActive()) {
    return;
  }
  AbstractContextStructureBridge bridge=null;
  try {
    if (ContextCorePlugin.getDefault() == null) {
      return;
    }
    bridge=ContextCore.getStructureBridge(element);
  }
 catch (  ConcurrentModificationException cme) {
  }
  try {
    if (!"org.eclipse.mylyn.internal.tasks.core.TaskTask".equals(element.getClass().getName())) {
      IInteractionElement node=null;
      if (element instanceof InteractionContextRelation) {
        decoration.setForegroundColor(ColorMap.RELATIONSHIP);
      }
 else       if (element instanceof IInteractionElement) {
        node=(IInteractionElement)element;
      }
 else {
        if (bridge != null && bridge.getContentType() != null) {
          node=ContextCore.getContextManager().getElement(bridge.getHandleIdentifier(element));
        }
      }
      if (node != null) {
        decoration.setForegroundColor(ContextUi.getForeground(node));
        if (bridge != null && bridge.canBeLandmark(node.getHandleIdentifier()) && node.getInterest().isLandmark() && !node.getInterest().isPropagated() && !node.getInterest().isPredicted()) {
          decoration.setFont(CommonFonts.BOLD);
        }
      }
    }
  }
 catch (  Exception e) {
    StatusHandler.log(new Status(IStatus.ERROR,ContextUiPlugin.ID_PLUGIN,"Decoration failed",e));
  }
}
 

Example 60

From project mylyn.docs.intent.main, under directory /plugins/org.eclipse.mylyn.docs.intent.client.ui.ide/src/org/eclipse/mylyn/docs/intent/client/ui/ide/navigator/.

Source file: UpdateProblemsViewJob.java

  19 
vote

/** 
 * {@inheritDoc}
 */
@Override protected IStatus run(IProgressMonitor monitor){
  Resource statusResource=adapter.getResource(IntentLocations.COMPILATION_STATUS_INDEX_PATH);
  Resource intentDocumentResource=adapter.getResource(IntentLocations.INTENT_INDEX);
  String platformString=intentDocumentResource.getURI().toPlatformString(true);
  IFile intentDocumentFile=(IFile)ResourcesPlugin.getWorkspace().getRoot().findMember(platformString);
  if (intentDocumentFile != null && !(statusResource.getContents().isEmpty())) {
    try {
      if (project.isAccessible()) {
        project.deleteMarkers("org.eclipse.core.resources.problemmarker",false,IResource.DEPTH_INFINITE);
      }
    }
 catch (    CoreException e) {
      IntentLogger.getInstance().log(LogType.WARNING,"Intent - failed to delete markers of project " + project.getName(),e);
    }
    CompilationStatusManager statusManager=statusQuery.getOrCreateCompilationStatusManager();
    try {
      for (      CompilationStatus status : statusManager.getCompilationStatusList()) {
        createMarkerFromStatus(status);
      }
    }
 catch (    ConcurrentModificationException e) {
      IntentLogger.getInstance().log(LogType.WARNING,"Error while updating problem view",e);
    }
  }
  return Status.OK_STATUS;
}
 

Example 61

From project mylyn.incubator, under directory /org.eclipse.mylyn.sandbox.dev/src/org/eclipse/mylyn/internal/sandbox/dev/.

Source file: InterestDebuggingDecorator.java

  19 
vote

public void decorate(Object element,IDecoration decoration){
  AbstractContextStructureBridge bridge=null;
  try {
    if (ContextCorePlugin.getDefault() == null) {
      return;
    }
    bridge=ContextCore.getStructureBridge(element);
  }
 catch (  ConcurrentModificationException cme) {
  }
  try {
    IInteractionElement node=null;
    if (element instanceof InteractionContextRelation) {
      decoration.setForegroundColor(ColorMap.RELATIONSHIP);
    }
 else     if (element instanceof IInteractionElement) {
      node=(IInteractionElement)element;
    }
 else {
      if (bridge != null && bridge.getContentType() != null) {
        node=ContextCore.getContextManager().getElement(bridge.getHandleIdentifier(element));
      }
    }
    if (node != null) {
      decoration.addSuffix(" {" + node.getInterest().getValue() + " ["+ node.getInterest().getEncodedValue()+ "] "+ "}");
    }
  }
 catch (  Exception e) {
    StatusHandler.log(new Status(IStatus.WARNING,MylynDevPlugin.ID_PLUGIN,"Decoration failed",e));
  }
}
 

Example 62

From project narya, under directory /core/src/main/java/com/threerings/presents/dobj/.

Source file: DSet.java

  19 
vote

/** 
 * Returns an iterator over the entries of this set. It does not support modification (nor iteration while modifications are being made to the set). It should not be kept around as it can quickly become out of date.
 */
public Iterator<E> iterator(){
  if (_size < 0 || _size > _entries.length || (_size > 0 && _entries[_size - 1] == null)) {
    log.warning("DSet in a bad way","size",_size,"entries",_entries,new Exception());
  }
  return new Iterator<E>(){
    public boolean hasNext(){
      checkComodification();
      return (_index < _size);
    }
    public E next(){
      checkComodification();
      return _entries[_index++];
    }
    public void remove(){
      throw new UnsupportedOperationException();
    }
    protected void checkComodification(){
      if (_modCount != _expectedModCount) {
        throw new ConcurrentModificationException();
      }
      if (_ssize != _size) {
        log.warning("Size changed during iteration","ssize",_ssize,"nsize",_size,"entries",_entries,new Exception());
      }
    }
    protected int _index=0;
    protected int _ssize=_size;
    protected int _expectedModCount=_modCount;
  }
;
}
 

Example 63

From project Non-Dairy-Soy-Plugin, under directory /src/net/venaglia/nondairy/util/.

Source file: TinySet.java

  19 
vote

@Override public Iterator<E> iterator(){
  if (delegate != null) {
    return delegate.iterator();
  }
  return new Iterator<E>(){
    boolean ready=single != null;
    int expectedMod=mod;
    @Override public boolean hasNext(){
      if (mod != expectedMod) {
        throw new ConcurrentModificationException();
      }
      return ready;
    }
    @Override public E next(){
      if (mod != expectedMod) {
        throw new ConcurrentModificationException();
      }
      if (!ready) {
        throw new NoSuchElementException();
      }
      ready=false;
      return single;
    }
    @Override public void remove(){
      if (mod != expectedMod) {
        throw new ConcurrentModificationException();
      }
      if (ready || single == null) {
        throw new IllegalStateException();
      }
      single=null;
      expectedMod=++mod;
    }
  }
;
}
 

Example 64

From project QView, under directory /QView-suite/MQProject/src/org/qview/gui/nbexplorer/.

Source file: PropertiesNotifier.java

  19 
vote

public static void changed(){
  ChangeEvent ev=new ChangeEvent(PropertiesNotifier.class);
  Iterator it=listeners.iterator();
  while (it.hasNext()) {
    try {
      ((ChangeListener)it.next()).stateChanged(ev);
    }
 catch (    ConcurrentModificationException ex) {
      break;
    }
  }
}
 

Example 65

From project rewrite, under directory /api/src/main/java/org/ocpsoft/rewrite/bind/.

Source file: Bindings.java

  19 
vote

/** 
 * Submit the given value to all registered  {@link Binding} instances of all given {@link Bindable} instances.Perform this by adding individual  {@link BindingOperation} instances via{@link EvaluationContext#addPreOperation(org.ocpsoft.rewrite.config.Operation)}
 * @return false if validation fails.
 */
public static boolean enqueuePreOperationSubmissions(final Rewrite event,final EvaluationContext context,final Map<? extends Bindable,? extends Object> map){
  List<Operation> operations=new ArrayList<Operation>();
  for (  Entry<? extends Bindable,? extends Object> entry : map.entrySet()) {
    Bindable parameter=entry.getKey();
    Object value=entry.getValue();
    List<Binding> bindings=parameter.getBindings();
    try {
      for (      Binding binding : bindings) {
        try {
          if (binding instanceof Evaluation) {
            Object convertedValue=binding.convert(event,context,value);
            if (binding.validate(event,context,convertedValue)) {
              binding.submit(event,context,value);
            }
 else             return false;
          }
 else {
            Object convertedValue=binding.convert(event,context,value);
            if (binding.validate(event,context,convertedValue)) {
              convertedValue=binding.convert(event,context,convertedValue);
              operations.add(new BindingOperation(binding,convertedValue));
            }
 else             return false;
          }
        }
 catch (        Exception e) {
          throw new RewriteException("Failed to bind value [" + value + "] to binding ["+ binding+ "]",e);
        }
      }
    }
 catch (    ConcurrentModificationException e) {
      e.printStackTrace();
    }
  }
  for (  Operation operation : operations) {
    context.addPreOperation(operation);
  }
  return true;
}
 

Example 66

From project scisoft-ui, under directory /uk.ac.diamond.scisoft.analysis.rcp/src/uk/ac/diamond/scisoft/analysis/rcp/plotting/sideplot/.

Source file: Fitting1D.java

  19 
vote

@Override protected IStatus run(IProgressMonitor monitor){
  try {
    for (    FittedPeakData peakData : currentPeakList) {
      if (monitor.isCanceled()) {
        newList.clear();
        return Status.CANCEL_STATUS;
      }
      APeak peak=peakData.getFittedPeak();
      double min=peak.getPosition() - 2 * peak.getFWHM();
      double max=peak.getPosition() + 2 * peak.getFWHM();
      try {
        List<CompositeFunction> functions=Generic1DFitter.fitPeakFunctions(createXData(min,max),sliceDataSet(min,max),peak,optimiser,smooth,1);
        if (functions != null && !functions.isEmpty()) {
          List<APeak> fittedPeaks=new ArrayList<APeak>(functions.size());
          for (          CompositeFunction compositeFunction : functions) {
            fittedPeaks.add((APeak)compositeFunction.getFunction(0));
          }
          newList.addAll(fittedPeaks);
        }
      }
 catch (      Throwable t) {
        logger.info("exception trying to refit peaks {} - no problem usually",t);
      }
    }
  }
 catch (  ConcurrentModificationException e) {
    logger.debug("This was caused by the fitting continuing after the job was canceled");
  }
  if (monitor.isCanceled())   return Status.CANCEL_STATUS;
  UIJob updatePlot=new UIJob("Update Plot"){
    @Override public IStatus runInUIThread(    IProgressMonitor monitor){
      fittedPeakList.clear();
      addPeaksToList(newList,colorDraggedFitted);
      return Status.OK_STATUS;
    }
  }
;
  updatePlot.schedule();
  return Status.OK_STATUS;
}
 

Example 67

From project snaptree, under directory /src/test/java/jsr166tests/jtreg/util/LinkedList/.

Source file: ComodifiedRemove.java

  19 
vote

public static void main(String[] args){
  List list=new LinkedList();
  Object o1=new Integer(1);
  list.add(o1);
  ListIterator e=list.listIterator();
  e.next();
  Object o2=new Integer(2);
  list.add(o2);
  try {
    e.remove();
  }
 catch (  ConcurrentModificationException cme) {
    return;
  }
  throw new RuntimeException("LinkedList ListIterator.remove() comodification check failed.");
}