org.activiti.engine.ActivitiOptimisticLockingException Java Examples
The following examples show how to use
org.activiti.engine.ActivitiOptimisticLockingException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StandaloneTaskTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testOptimisticLockingThrownOnMultipleUpdates() { Task task = taskService.newTask(); taskService.saveTask(task); String taskId = task.getId(); // first modification Task task1 = taskService.createTaskQuery().taskId(taskId).singleResult(); Task task2 = taskService.createTaskQuery().taskId(taskId).singleResult(); task1.setDescription("first modification"); taskService.saveTask(task1); // second modification on the initial instance task2.setDescription("second modification"); try { taskService.saveTask(task2); fail("should get an exception here as the task was modified by someone else."); } catch (ActivitiOptimisticLockingException expected) { // exception was thrown as expected } taskService.deleteTask(taskId, true); }
Example #2
Source File: DbSqlSession.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void flushUpdates(List<PersistentObject> updatedObjects) { for (PersistentObject updatedObject : updatedObjects) { String updateStatement = dbSqlSessionFactory.getUpdateStatement(updatedObject); updateStatement = dbSqlSessionFactory.mapStatement(updateStatement); if (updateStatement == null) { throw new ActivitiException("no update statement for " + updatedObject.getClass() + " in the ibatis mapping files"); } LOGGER.debug("updating: {}", updatedObject); int updatedRecords = sqlSession.update(updateStatement, updatedObject); if (updatedRecords != 1) { throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently"); } // See https://activiti.atlassian.net/browse/ACT-1290 if (updatedObject instanceof HasRevision) { ((HasRevision) updatedObject).setRevision(((HasRevision) updatedObject).getRevisionNext()); } } updatedObjects.clear(); }
Example #3
Source File: DbSqlSession.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void execute() { if (persistentObjects.isEmpty()) { return; } String bulkDeleteStatement = dbSqlSessionFactory.getBulkDeleteStatement(persistentObjectClass); bulkDeleteStatement = dbSqlSessionFactory.mapStatement(bulkDeleteStatement); if (bulkDeleteStatement == null) { throw new ActivitiException("no bulk delete statement for " + persistentObjectClass + " in the mapping files"); } // It only makes sense to check for optimistic locking exceptions for objects that actually have a revision if (persistentObjects.get(0) instanceof HasRevision) { int nrOfRowsDeleted = sqlSession.delete(bulkDeleteStatement, persistentObjects); if (nrOfRowsDeleted < persistentObjects.size()) { throw new ActivitiOptimisticLockingException("One of the entities " + persistentObjectClass + " was updated by another transaction concurrently while trying to do a bulk delete"); } } else { sqlSession.delete(bulkDeleteStatement, persistentObjects); } }
Example #4
Source File: DbSqlSession.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void execute() { String deleteStatement = dbSqlSessionFactory.getDeleteStatement(persistentObject.getClass()); deleteStatement = dbSqlSessionFactory.mapStatement(deleteStatement); if (deleteStatement == null) { throw new ActivitiException("no delete statement for " + persistentObject.getClass() + " in the ibatis mapping files"); } // It only makes sense to check for optimistic locking exceptions for objects that actually have a revision if (persistentObject instanceof HasRevision) { int nrOfRowsDeleted = sqlSession.delete(deleteStatement, persistentObject); if (nrOfRowsDeleted == 0) { throw new ActivitiOptimisticLockingException(persistentObject + " was updated by another transaction concurrently"); } } else { sqlSession.delete(deleteStatement, persistentObject); } }
Example #5
Source File: ExecutionEntityManager.java From flowable-engine with Apache License 2.0 | 6 votes |
public void updateProcessInstanceLockTime(String processInstanceId) { CommandContext commandContext = Context.getCommandContext(); Date expirationTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime(); int lockMillis = commandContext.getProcessEngineConfiguration().getAsyncExecutorAsyncJobLockTimeInMillis(); GregorianCalendar lockCal = new GregorianCalendar(); lockCal.setTime(expirationTime); lockCal.add(Calendar.MILLISECOND, lockMillis); HashMap<String, Object> params = new HashMap<>(); params.put("id", processInstanceId); params.put("lockTime", lockCal.getTime()); params.put("expirationTime", expirationTime); int result = getDbSqlSession().update("updateProcessInstanceLockTime", params); if (result == 0) { throw new ActivitiOptimisticLockingException("Could not lock process instance"); } }
Example #6
Source File: RetryInterceptor.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public <T> T execute(CommandConfig config, Command<T> command) { long waitTime = waitTimeInMs; int failedAttempts = 0; do { if (failedAttempts > 0) { LOGGER.info("Waiting for {}ms before retrying the command.", waitTime); waitBeforeRetry(waitTime); waitTime *= waitIncreaseFactor; } try { // try to execute the command return next.execute(config, command); } catch (ActivitiOptimisticLockingException e) { LOGGER.info("Caught optimistic locking exception: {}", e.getMessage(), e); } failedAttempts++; } while (failedAttempts <= numOfRetries); throw new ActivitiException(numOfRetries + " retries failed with ActivitiOptimisticLockingException. Giving up."); }
Example #7
Source File: AsyncJobUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
protected static void unlockJobIsNeeded(final JobEntity job, final CommandExecutor commandExecutor) { try { if (job.isExclusive()) { commandExecutor.execute(new UnlockExclusiveJobCmd(job)); } } catch (ActivitiOptimisticLockingException optimisticLockingException) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Optimistic locking exception while unlocking the job. If you have multiple async executors running against the same database, " + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. " + "Exception message: {}", optimisticLockingException.getMessage()); } } catch (Throwable t) { LOGGER.error("Error while unlocking exclusive job {}", job.getId(), t); } }
Example #8
Source File: IdentityServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testGroupOptimisticLockingException() { Group group = identityService.newGroup("group"); identityService.saveGroup(group); Group group1 = identityService.createGroupQuery().singleResult(); Group group2 = identityService.createGroupQuery().singleResult(); group1.setName("name one"); identityService.saveGroup(group1); try { group2.setName("name two"); identityService.saveGroup(group2); fail("Expected an exception"); } catch (ActivitiOptimisticLockingException e) { // Expected an exception } identityService.deleteGroup(group.getId()); }
Example #9
Source File: IdentityServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testUserOptimisticLockingException() { User user = identityService.newUser("kermit"); identityService.saveUser(user); User user1 = identityService.createUserQuery().singleResult(); User user2 = identityService.createUserQuery().singleResult(); user1.setFirstName("name one"); identityService.saveUser(user1); try { user2.setFirstName("name two"); identityService.saveUser(user2); fail("Expected an exception"); } catch (ActivitiOptimisticLockingException e) { // Expected an exception } identityService.deleteUser(user.getId()); }
Example #10
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testUserTaskOptimisticLocking() { runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task1 = taskService.createTaskQuery().singleResult(); Task task2 = taskService.createTaskQuery().singleResult(); task1.setDescription("test description one"); taskService.saveTask(task1); try { task2.setDescription("test description two"); taskService.saveTask(task2); fail("Expecting exception"); } catch(ActivitiOptimisticLockingException e) { // Expected exception } }
Example #11
Source File: IdentityServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testGroupOptimisticLockingException() { Group group = identityService.newGroup("group"); identityService.saveGroup(group); Group group1 = identityService.createGroupQuery().singleResult(); Group group2 = identityService.createGroupQuery().singleResult(); group1.setName("name one"); identityService.saveGroup(group1); try { group2.setName("name two"); identityService.saveGroup(group2); fail("Expected an exception"); } catch (ActivitiOptimisticLockingException e) { // Expected an exception } identityService.deleteGroup(group.getId()); }
Example #12
Source File: IdentityServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testUserOptimisticLockingException() { User user = identityService.newUser("kermit"); identityService.saveUser(user); User user1 = identityService.createUserQuery().singleResult(); User user2 = identityService.createUserQuery().singleResult(); user1.setFirstName("name one"); identityService.saveUser(user1); try { user2.setFirstName("name two"); identityService.saveUser(user2); fail("Expected an exception"); } catch (ActivitiOptimisticLockingException e) { // Expected an exception } identityService.deleteUser(user.getId()); }
Example #13
Source File: ExecuteAsyncRunnable.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void executeJob() { try { processEngineConfiguration.getCommandExecutor().execute(new ExecuteAsyncJobCmd(jobId)); } catch (final ActivitiOptimisticLockingException e) { handleFailedJob(e); if (log.isDebugEnabled()) { log.debug("Optimistic locking exception during job execution. If you have multiple async executors running against the same database, " + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor threads running against the same database. " + "Exception message: {}", e.getMessage()); } } catch (Throwable exception) { handleFailedJob(exception); // Finally, Throw the exception to indicate the ExecuteAsyncJobCmd failed String message = "Job " + jobId + " failed"; log.error(message, exception); } }
Example #14
Source File: ExecuteAsyncRunnable.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void unlockJobIfNeeded() { try { if (job.isExclusive()) { processEngineConfiguration.getCommandExecutor().execute(new UnlockExclusiveJobCmd(job)); } } catch (ActivitiOptimisticLockingException optimisticLockingException) { if (log.isDebugEnabled()) { log.debug("Optimistic locking exception while unlocking the job. If you have multiple async executors running against the same database, " + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. " + "Exception message: {}", optimisticLockingException.getMessage()); } } catch (Throwable t) { log.error("Error while unlocking exclusive job " + job.getId(), t); } }
Example #15
Source File: StandaloneTaskTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testOptimisticLockingThrownOnMultipleUpdates() { Task task = taskService.newTask(); taskService.saveTask(task); String taskId = task.getId(); // first modification Task task1 = taskService.createTaskQuery().taskId(taskId).singleResult(); Task task2 = taskService.createTaskQuery().taskId(taskId).singleResult(); task1.setDescription("first modification"); taskService.saveTask(task1); // second modification on the initial instance task2.setDescription("second modification"); try { taskService.saveTask(task2); fail("should get an exception here as the task was modified by someone else."); } catch (ActivitiOptimisticLockingException expected) { // exception was thrown as expected } taskService.deleteTask(taskId, true); }
Example #16
Source File: DbSqlSession.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void flushDeleteEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToDelete) { for (Entity entity : entitiesToDelete) { String deleteStatement = dbSqlSessionFactory.getDeleteStatement(entity.getClass()); deleteStatement = dbSqlSessionFactory.mapStatement(deleteStatement); if (deleteStatement == null) { throw new ActivitiException("no delete statement for " + entity.getClass() + " in the ibatis mapping files"); } // It only makes sense to check for optimistic locking exceptions // for objects that actually have a revision if (entity instanceof HasRevision) { int nrOfRowsDeleted = sqlSession.delete(deleteStatement, entity); if (nrOfRowsDeleted == 0) { throw new ActivitiOptimisticLockingException(entity + " was updated by another transaction concurrently"); } } else { sqlSession.delete(deleteStatement, entity); } } }
Example #17
Source File: TaskServiceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" }) public void testUserTaskOptimisticLocking() { runtimeService.startProcessInstanceByKey("oneTaskProcess"); Task task1 = taskService.createTaskQuery().singleResult(); Task task2 = taskService.createTaskQuery().singleResult(); task1.setDescription("test description one"); taskService.saveTask(task1); try { task2.setDescription("test description two"); taskService.saveTask(task2); fail("Expecting exception"); } catch (ActivitiOptimisticLockingException e) { // Expected exception } }
Example #18
Source File: RetryInterceptor.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public <T> T execute(CommandConfig config, Command<T> command) { long waitTime = waitTimeInMs; int failedAttempts = 0; do { if (failedAttempts > 0) { log.info("Waiting for {}ms before retrying the command.", waitTime); waitBeforeRetry(waitTime); waitTime *= waitIncreaseFactor; } try { // try to execute the command return next.execute(config, command); } catch (ActivitiOptimisticLockingException e) { log.info("Caught optimistic locking exception: " + e); } failedAttempts++; } while (failedAttempts <= numOfRetries); throw new ActivitiException(numOfRetries + " retries failed with ActivitiOptimisticLockingException. Giving up."); }
Example #19
Source File: DbSqlSession.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
protected void flushUpdates() { for (Entity updatedObject : updatedObjects) { String updateStatement = dbSqlSessionFactory.getUpdateStatement(updatedObject); updateStatement = dbSqlSessionFactory.mapStatement(updateStatement); if (updateStatement == null) { throw new ActivitiException("no update statement for " + updatedObject.getClass() + " in the ibatis mapping files"); } log.debug("updating: {}", updatedObject); int updatedRecords = sqlSession.update(updateStatement, updatedObject); if (updatedRecords == 0) { throw new ActivitiOptimisticLockingException(updatedObject + " was updated by another transaction concurrently"); } // See https://activiti.atlassian.net/browse/ACT-1290 if (updatedObject instanceof HasRevision) { ((HasRevision) updatedObject).setRevision(((HasRevision) updatedObject).getRevisionNext()); } } updatedObjects.clear(); }
Example #20
Source File: EndEventTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void run() { try { taskService.complete(taskId); succeeded = true; } catch (ActivitiOptimisticLockingException ae) { // Exception is expected for one of the threads } }
Example #21
Source File: DefaultActiviti5CompatibilityHandler.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void handleActivitiException(org.activiti5.engine.ActivitiException e) { if (e instanceof org.activiti5.engine.delegate.BpmnError) { org.activiti5.engine.delegate.BpmnError activiti5BpmnError = (org.activiti5.engine.delegate.BpmnError) e; throw new BpmnError(activiti5BpmnError.getErrorCode(), activiti5BpmnError.getMessage()); } else if (e instanceof org.activiti5.engine.ActivitiClassLoadingException) { throw new ActivitiClassLoadingException(e.getMessage(), e.getCause()); } else if (e instanceof org.activiti5.engine.ActivitiObjectNotFoundException) { org.activiti5.engine.ActivitiObjectNotFoundException activiti5ObjectNotFoundException = (org.activiti5.engine.ActivitiObjectNotFoundException) e; throw new ActivitiObjectNotFoundException(activiti5ObjectNotFoundException.getMessage(), activiti5ObjectNotFoundException.getObjectClass(), activiti5ObjectNotFoundException.getCause()); } else if (e instanceof org.activiti5.engine.ActivitiOptimisticLockingException) { throw new ActivitiOptimisticLockingException(e.getMessage()); } else if (e instanceof org.activiti5.engine.ActivitiIllegalArgumentException) { throw new ActivitiIllegalArgumentException(e.getMessage(), e.getCause()); } else { if (e.getCause() instanceof org.activiti5.engine.ActivitiClassLoadingException) { throw new ActivitiException(e.getMessage(), new ActivitiClassLoadingException(e.getCause().getMessage(), e.getCause().getCause())); } else if (e.getCause() instanceof org.activiti5.engine.impl.javax.el.PropertyNotFoundException) { throw new ActivitiException(e.getMessage(), new PropertyNotFoundException(e.getCause().getMessage(), e.getCause().getCause())); } else if (e.getCause() instanceof org.activiti5.engine.ActivitiException) { throw new ActivitiException(e.getMessage(), new ActivitiException(e.getCause().getMessage(), e.getCause().getCause())); } else { throw new ActivitiException(e.getMessage(), e.getCause()); } } }
Example #22
Source File: CompetingSignalsTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void run() { try { runtimeService.trigger(executionId); } catch (ActivitiOptimisticLockingException e) { this.exception = e; } log.debug("{} ends", getName()); }
Example #23
Source File: EndEventTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void run() { try { taskService.complete(taskId); succeeded = true; } catch (ActivitiOptimisticLockingException ae) { // Exception is expected for one of the threads } }
Example #24
Source File: CommandContext.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
protected void logException() { if (exception instanceof JobNotFoundException || exception instanceof ActivitiTaskAlreadyClaimedException) { // reduce log level, because this may have been caused because of job deletion due to cancelActiviti="true" log.info("Error while closing command context", exception); } else if (exception instanceof ActivitiOptimisticLockingException) { // reduce log level, as normally we're not interested in logging this exception log.debug("Optimistic locking exception : " + exception); } else { log.error("Error while closing command context", exception); } }
Example #25
Source File: MybatisExecutionDataManager.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void updateProcessInstanceLockTime(String processInstanceId, Date lockDate, Date expirationTime) { HashMap<String, Object> params = new HashMap<String, Object>(); params.put("id", processInstanceId); params.put("lockTime", lockDate); params.put("expirationTime", expirationTime); int result = getDbSqlSession().update("updateProcessInstanceLockTime", params); if (result == 0) { throw new ActivitiOptimisticLockingException("Could not lock process instance"); } }
Example #26
Source File: WorkflowController.java From oneops with Apache License 2.0 | 4 votes |
/** * Poke sub process. * * @param processId the process id */ public void checkSyncWait(String processId, String executionId){ List<Execution> subExecutions = runtimeService.createExecutionQuery().processInstanceId(processId).activityId("pwo").list(); if (subExecutions.size()>0) { List<Execution> execsSyncWait = runtimeService.createExecutionQuery() .processInstanceId(processId) .activityId("subSync").list(); logger.info("Number of subprocesses - " + subExecutions.size()); logger.info("Number of subprocesses waiting in sync block - " + execsSyncWait.size()); if (execsSyncWait.size() == subExecutions.size()) { logger.info("All sub processes waiting in sync block, will poke all of them now."); int pokesCounter = 0; for (Execution syncExec : execsSyncWait) { boolean needReTry = true; for (int i=1; i<=STEP_FINISH_RETRIES && needReTry; i++) { needReTry = false; logger.info("Poking sync sub process with id - " + syncExec.getId()); try { runtimeService.signal(syncExec.getId()); pokesCounter++; } catch (ActivitiOptimisticLockingException aole) { //this is ok, some other process beat this on completion logger.warn(aole); } catch (ActivitiObjectNotFoundException aonfe) { //other process beats us on this just ignore logger.warn(aonfe); } catch (PersistenceException pe) { pe.printStackTrace(); logger.error(pe.getMessage()); //woraround of activi bug when multiple instances of the same var is created String[] badVars = {"wostate", "wo"}; for (String varName : badVars) { runtimeService.removeVariableLocal(syncExec.getId(), varName); runtimeService.removeVariableLocal(syncExec.getId(), varName); } needReTry = true; } } } logger.info(">>>>>>Completed " + pokesCounter + " subprocesses out of " + execsSyncWait.size() + " waiting!"); signalSubJoin(processId); } } }
Example #27
Source File: AsyncJobUtil.java From flowable-engine with Apache License 2.0 | 4 votes |
public static void executeJob(final JobEntity job, final CommandExecutor commandExecutor) { try { if (job.isExclusive()) { commandExecutor.execute(new LockExclusiveJobCmd(job)); } } catch (Throwable lockException) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Could not lock exclusive job. Unlocking job so it can be acquired again. Caught exception: {}", lockException.getMessage()); } unacquireJob(commandExecutor, job); return; } try { commandExecutor.execute(new Command<Void>() { @Override public Void execute(CommandContext commandContext) { new ExecuteAsyncJobCmd(job).execute(commandContext); if (job.isExclusive()) { new UnlockExclusiveJobCmd(job).execute(commandContext); } return null; } }); } catch (final ActivitiOptimisticLockingException e) { handleFailedJob(job, e, commandExecutor); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Optimistic locking exception during job execution. If you have multiple async executors running against the same database, " + "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." + "This is expected behavior in a clustered environment. " + "You can ignore this message if you indeed have multiple job executor threads running against the same database. " + "Exception message: {}", e.getMessage()); } } catch (Throwable exception) { handleFailedJob(job, exception, commandExecutor); // Finally, Throw the exception to indicate the ExecuteAsyncJobCmd failed String message = "Job " + job.getId() + " failed"; LOGGER.error(message, exception); } }
Example #28
Source File: RetryInterceptorTest.java From flowable-engine with Apache License 2.0 | 4 votes |
public Void execute(CommandContext commandContext) { throw new ActivitiOptimisticLockingException(""); }
Example #29
Source File: OptimisticLockingExceptionTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
@Test @Deployment(resources = { "org/activiti/engine/test/concurrency/CompetingJoinTest.testCompetingJoins.bpmn20.xml" }) public void testOptimisticLockExceptionForConcurrentJoin() throws Exception { // The optimistic locking exception should happen for this test to be useful. // But with concurrency, you never know. Hence why this test is repeated 10 time to make sure the chance for // the optimistic exception happening is as big as possible. boolean optimisticLockingExceptionHappenedOnce = false; for (int i=0; i<10; i++) { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("CompetingJoinsProcess"); Execution execution1 = runtimeService.createExecutionQuery().activityId("wait1").processInstanceId(processInstance.getId()).singleResult(); Execution execution2 = runtimeService.createExecutionQuery().activityId("wait2").processInstanceId(processInstance.getId()).singleResult(); TestTriggerableThread t1 = new TestTriggerableThread(processEngine, execution1.getId()); TestTriggerableThread t2 = new TestTriggerableThread(processEngine, execution2.getId()); // Start the two trigger threads. They will wait at the barrier t1.start(); t2.start(); // Wait at the barrier, until all threads are at the barrier OptimisticLockingTestCommandContextCloseListener.TEST_BARRIER_BEFORE_CLOSE.await(); long totalWaitTime = 0; while (t1.getException() == null && t2.getException() == null && runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count() == 1) { Thread.sleep(250L); totalWaitTime += 250L; if (totalWaitTime >= 5000L) { break; } } // Either the transactions just happened to be aligned perfectly and no problem occurred (process instance ended) // Or the process instance wasn't ended and one of the two threads has an exception // Optimistic locking exception happened, yay. We can stop the test. if ( (t1.getException() != null && t1.getException() instanceof ActivitiOptimisticLockingException) || (t2.getException() != null && t2.getException() instanceof ActivitiOptimisticLockingException)) { optimisticLockingExceptionHappenedOnce = true; break; } boolean processInstanceEnded = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).count() == 0; Assert.assertTrue(processInstanceEnded); } Assert.assertTrue(optimisticLockingExceptionHappenedOnce); }
Example #30
Source File: RetryInterceptorTest.java From activiti6-boot2 with Apache License 2.0 | 2 votes |
public Void execute(CommandContext commandContext) { counter.incrementAndGet(); throw new ActivitiOptimisticLockingException(""); }