List of usage examples for java.util ConcurrentModificationException getMessage
public String getMessage()
From source file:be.kdg.repaircafemodel.service.impl.UserServiceImpl.java
/** * Returns user having username/*from w w w . j a v a 2 s .c o m*/ * * @param username * @return * @throws be.kdg.repaircafemodel.service.exceptions.UserServiceException */ @Override public User getUser(String username) throws UserServiceException { try { return userDAO.getUser(username); } catch (ConcurrentModificationException ex) { throw new UserServiceException(ex.getMessage()); } }
From source file:jp.co.nemuzuka.core.controller.JsonController.java
/** * ?./* w ww. j a va 2 s .co m*/ * ?commit??ThreadLocal???? * @see org.slim3.controller.Controller#run() */ @Override protected Navigation run() throws Exception { //????????????? String setUpError = requestScope(SETUP_ERROR); if (StringUtils.isNotEmpty(setUpError)) { return null; } Object obj = null; try { obj = execute(); if (obj == null) { throw new AssertionError("execute() must not be null."); } executeCommit(); } catch (ConcurrentModificationException e) { //????????Json???? super.tearDown(); JsonResult result = new JsonResult(); result.setStatus(JsonResult.VERSION_ERR); result.getErrorMsg().add(ApplicationMessage.get("errors.version")); obj = result; } catch (AlreadyExistKeyException e) { //?????????Json???? super.tearDown(); JsonResult result = new JsonResult(); result.setStatus(JsonResult.DUPLICATE_ERR); result.getErrorMsg().add(ApplicationMessage.get("errors.duplicate")); obj = result; } catch (Exception e) { logger.log(Level.SEVERE, e.getMessage(), e); throw e; } return writeJsonObj(obj); }
From source file:de.uniluebeck.itm.spyglass.core.ConfigStore.java
/** * Stores the configuration persistently into the given file. * * This method is synchronized to avoid storing into the same file concurrently. * * @param configFile// w w w.jav a2s .c o m * the file which will contain the configuration data afterwards */ protected synchronized void storeSync(final File configFile) { log.debug("Storing config to file: " + configFile); final StringWriter buf = new StringWriter(); try { // If something happens here, the file will never have been opened. new Persister().write(spyglassConfig, buf); final FileWriter writer = new FileWriter(configFile); writer.write(buf.toString()); writer.close(); } catch (final ConcurrentModificationException e) { // Note: In theory this may lead to StackOverflow. But since under normal circumstances // the chances of hitting this Exception are already pretty small, we probably can risk // it. log.debug("Configuration was modified while the ConfigStore tried to store the config. Trying again...", e); storeSync(configFile); return; } catch (final IOException e) { log.error("Unable to store configuration output: Error while writing the file!", e); } catch (final InterruptedException e) { Thread.currentThread().interrupt(); } catch (final Exception e) { log.error("Unable to store configuration output: " + e.getMessage(), e); } log.debug("Stored config to file: " + configFile + "."); }
From source file:com.aurel.track.json.JSONUtility.java
public static void appendStringList(StringBuilder sb, String name, List<String> list, boolean last) { appendFieldName(sb, name);/* w w w . j ava2 s . c o m*/ sb.append(":["); if (list != null) { try { for (Iterator<String> iterator = list.iterator(); iterator.hasNext();) { String string = iterator.next(); sb.append("\"").append(escape(string)).append("\""); if (iterator.hasNext()) { sb.append(","); } } } catch (ConcurrentModificationException exception) { //if logs are added in the memory appender during serializing the existing logs in serverStatus LOGGER.debug("Creating the string list JSON failed with " + exception.getMessage()); } } sb.append("]"); if (!last) { sb.append(","); } }
From source file:org.apache.jackrabbit.core.ItemImpl.java
/** * {@inheritDoc}//from w w w . j a v a 2 s. co m */ public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException { // check state of this instance sanityCheck(); // synchronize on this session synchronized (session) { /** * build list of transient (i.e. new & modified) states that * should be persisted */ Collection dirty; try { dirty = getTransientStates(); } catch (ConcurrentModificationException e) { String msg = "Concurrent modification; session is closed"; log.error(msg, e); session.logout(); throw e; } if (dirty.size() == 0) { // no transient items, nothing to do here return; } /** * build list of transient descendants in the attic * (i.e. those marked as 'removed') */ Collection removed = getRemovedStates(); /** * build set of item id's which are within the scope of * (i.e. affected by) this save operation */ Set affectedIds = new HashSet(dirty.size() + removed.size()); for (Iterator it = new IteratorChain(dirty.iterator(), removed.iterator()); it.hasNext();) { affectedIds.add(((ItemState) it.next()).getId()); } /** * make sure that this save operation is totally 'self-contained' * and independent; items within the scope of this save operation * must not have 'external' dependencies; * (e.g. moving a node requires that the target node including both * old and new parents are saved) */ for (Iterator it = new IteratorChain(dirty.iterator(), removed.iterator()); it.hasNext();) { ItemState transientState = (ItemState) it.next(); if (transientState.isNode()) { NodeState nodeState = (NodeState) transientState; Set dependentIDs = new HashSet(); if (nodeState.hasOverlayedState()) { NodeState overlayedState = (NodeState) nodeState.getOverlayedState(); NodeId oldParentId = overlayedState.getParentId(); NodeId newParentId = nodeState.getParentId(); if (oldParentId != null) { if (newParentId == null) { // node has been removed, add old parents // to dependencies if (overlayedState.isShareable()) { dependentIDs.addAll(overlayedState.getSharedSet()); } else { dependentIDs.add(oldParentId); } } else { if (!oldParentId.equals(newParentId)) { // node has been moved to a new location, // add old and new parent to dependencies dependentIDs.add(oldParentId); dependentIDs.add(newParentId); } else { // parent id hasn't changed, check whether // the node has been renamed (JCR-1034) if (!affectedIds.contains(newParentId) && stateMgr.hasTransientItemState(newParentId)) { try { NodeState parent = (NodeState) stateMgr .getTransientItemState(newParentId); // check parent's renamed child node entries for (Iterator cneIt = parent.getRenamedChildNodeEntries() .iterator(); cneIt.hasNext();) { ChildNodeEntry cne = (ChildNodeEntry) cneIt.next(); if (cne.getId().equals(nodeState.getId())) { // node has been renamed, // add parent to dependencies dependentIDs.add(newParentId); } } } catch (ItemStateException ise) { // should never get here log.warn("failed to retrieve transient state: " + newParentId, ise); } } } } } } // removed child node entries for (Iterator cneIt = nodeState.getRemovedChildNodeEntries().iterator(); cneIt.hasNext();) { ChildNodeEntry cne = (ChildNodeEntry) cneIt.next(); dependentIDs.add(cne.getId()); } // added child node entries for (Iterator cneIt = nodeState.getAddedChildNodeEntries().iterator(); cneIt.hasNext();) { ChildNodeEntry cne = (ChildNodeEntry) cneIt.next(); dependentIDs.add(cne.getId()); } // now walk through dependencies and check whether they // are within the scope of this save operation Iterator depIt = dependentIDs.iterator(); while (depIt.hasNext()) { NodeId id = (NodeId) depIt.next(); if (!affectedIds.contains(id)) { // JCR-1359 workaround: check whether unresolved // dependencies originate from 'this' session; // otherwise ignore them if (stateMgr.hasTransientItemState(id) || stateMgr.hasTransientItemStateInAttic(id)) { // need to save dependency as well String msg = itemMgr.safeGetJCRPath(id) + " needs to be saved as well."; log.debug(msg); throw new ConstraintViolationException(msg); } } } } } /** * validate access and node type constraints * (this will also validate child removals) */ validateTransientItems(dirty.iterator(), removed.iterator()); // start the update operation try { stateMgr.edit(); } catch (IllegalStateException e) { String msg = "Unable to start edit operation"; log.debug(msg); throw new RepositoryException(msg, e); } boolean succeeded = false; try { // process transient items marked as 'removed' removeTransientItems(removed.iterator()); // process transient items that have change in mixins processShareableNodes(dirty.iterator()); // initialize version histories for new nodes (might generate new transient state) if (initVersionHistories(dirty.iterator())) { // re-build the list of transient states because the previous call // generated new transient state dirty = getTransientStates(); } // process 'new' or 'modified' transient states persistTransientItems(dirty.iterator()); // dispose the transient states marked 'new' or 'modified' // at this point item state data is pushed down one level, // node instances are disconnected from the transient // item state and connected to the 'overlayed' item state. // transient item states must be removed now. otherwise // the session item state provider will return an orphaned // item state which is not referenced by any node instance. for (Iterator it = dirty.iterator(); it.hasNext();) { ItemState transientState = (ItemState) it.next(); // dispose the transient state, it is no longer used stateMgr.disposeTransientItemState(transientState); } // end update operation stateMgr.update(); // update operation succeeded succeeded = true; } catch (StaleItemStateException e) { throw new InvalidItemStateException(e.getMessage()); } catch (ItemStateException e) { throw new RepositoryException("Unable to update item: " + this, e); } finally { if (!succeeded) { // update operation failed, cancel all modifications stateMgr.cancel(); // JCR-288: if an exception has been thrown during // update() the transient changes have already been // applied by persistTransientItems() and we need to // restore transient state, i.e. undo the effect of // persistTransientItems() restoreTransientItems(dirty.iterator()); } } // now it is safe to dispose the transient states: // dispose the transient states marked 'removed'. // item states in attic are removed after store, because // the observation mechanism needs to build paths of removed // items in store(). for (Iterator it = removed.iterator(); it.hasNext();) { ItemState transientState = (ItemState) it.next(); // dispose the transient state, it is no longer used stateMgr.disposeTransientItemStateInAttic(transientState); } } }
From source file:org.libreplan.web.calendars.BaseCalendarEditionController.java
public void onCheckGenerateCode(Event e) { CheckEvent ce = (CheckEvent) e;/*from w w w .j a va 2 s . co m*/ if (ce.isChecked()) { try { baseCalendarModel.setCodeAutogenerated(ce.isChecked()); } catch (ConcurrentModificationException err) { messagesForUser.showMessage(Level.ERROR, err.getMessage()); } } reloadCodeInformation(); }
From source file:org.libreplan.web.costcategories.CostCategoryCRUDController.java
public void onCheckGenerateCode(Event e) { CheckEvent ce = (CheckEvent) e;/* w w w . ja v a 2s . com*/ if (ce.isChecked()) { // we have to auto-generate the code for new objects try { costCategoryModel.setCodeAutogenerated(ce.isChecked()); } catch (ConcurrentModificationException err) { messagesForUser.showMessage(Level.ERROR, err.getMessage()); } } Util.reloadBindings(listCostCategories); Util.reloadBindings(listHourCosts); }
From source file:org.libreplan.web.costcategories.TypeOfWorkHoursCRUDController.java
public void onCheckGenerateCode(Event e) { CheckEvent ce = (CheckEvent) e;// ww w. j av a 2s . c o m if (ce.isChecked()) { try { // we have to auto-generate the code typeOfWorkHoursModel.setCodeAutogenerated(ce.isChecked()); } catch (ConcurrentModificationException err) { messagesForUser.showMessage(Level.ERROR, err.getMessage()); } } Util.reloadBindings(editWindow); }
From source file:org.libreplan.web.expensesheet.ExpenseSheetCRUDController.java
public void onCheckGenerateCode(Event e) { CheckEvent ce = (CheckEvent) e;/*www .j ava2s . c o m*/ if (ce.isChecked()) { // we have to auto-generate the code for new objects try { expenseSheetModel.setCodeAutogenerated(ce.isChecked()); } catch (ConcurrentModificationException err) { messagesForUser.showMessage(Level.ERROR, err.getMessage()); } } Util.reloadBindings(editWindow); reloadExpenseSheetLines(); }
From source file:org.libreplan.web.materials.UnitTypeController.java
public void onCheckGenerateCode(Event e) { CheckEvent ce = (CheckEvent) e;/*w w w. j ava 2s. c o m*/ if (ce.isChecked()) { // We have to auto-generate the code for new objects try { unitTypeModel.setCodeAutogenerated(ce.isChecked()); } catch (ConcurrentModificationException err) { messagesForUser.showMessage(Level.ERROR, err.getMessage()); } } Util.reloadBindings(editWindow); }