review Findings

This commit is contained in:
Joerg Heffner 2020-06-29 07:45:33 +02:00 committed by gitgoodjhe
parent 1dfe54c0b6
commit 969d3eeff6
5 changed files with 12 additions and 13 deletions

View File

@ -330,15 +330,11 @@ public interface TaskService {
* *
* @param taskQuery the task query. * @param taskQuery the task query.
* @return the task that got selected and claimed * @return the task that got selected and claimed
* @throws TaskNotFoundException if the task with taskId was not found * @throws InvalidOwnerException if the task is claimed by someone else
* @throws InvalidStateException if the state of the task with taskId is not READY * @throws NotAuthorizedException if the current user has no read permission for the workbasket
* @throws InvalidOwnerException if the task with taskId is claimed by someone else * the task is in
* @throws NotAuthorizedException if the current user has no read permission for the
* workbasket the task is in
*/ */
Task selectAndClaim(TaskQuery taskQuery) Task selectAndClaim(TaskQuery taskQuery) throws NotAuthorizedException, InvalidOwnerException;
throws TaskNotFoundException, NotAuthorizedException, InvalidStateException,
InvalidOwnerException;
/** /**
* Deletes a list of tasks. * Deletes a list of tasks.

View File

@ -1110,6 +1110,8 @@ public class TaskQueryImpl implements TaskQuery {
} }
} }
// optimized query for db2 can't be used for now in case of selectAndClaim because of temporary
// tables and the "for update" clause clashing in db2
public String getLinkToMapperScript() { public String getLinkToMapperScript() {
if (DB.DB2.dbProductId.equals(getDatabaseId()) && !selectAndClaim) { if (DB.DB2.dbProductId.equals(getDatabaseId()) && !selectAndClaim) {
return LINK_TO_MAPPER_DB2; return LINK_TO_MAPPER_DB2;

View File

@ -479,8 +479,7 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public Task selectAndClaim(TaskQuery taskQuery) public Task selectAndClaim(TaskQuery taskQuery)
throws TaskNotFoundException, NotAuthorizedException, InvalidStateException, throws NotAuthorizedException, InvalidOwnerException {
InvalidOwnerException {
if (LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("entry to selectAndClaim(taskQuery = {})", taskQuery); LOGGER.debug("entry to selectAndClaim(taskQuery = {})", taskQuery);
@ -502,6 +501,8 @@ public class TaskServiceImpl implements TaskService {
return claim(taskSummary.getId()); return claim(taskSummary.getId());
} catch (InvalidStateException | TaskNotFoundException e) {
throw new SystemException("Caught exception ", e);
} finally { } finally {
LOGGER.debug("exit from selectAndClaim()"); LOGGER.debug("exit from selectAndClaim()");
taskanaEngine.returnConnection(); taskanaEngine.returnConnection();

View File

@ -50,14 +50,14 @@ class SelectAndClaimTaskAccTest extends AbstractAccTest {
threads[i].join(); threads[i].join();
} }
assertThat(selectedAndClaimedTasks.stream().map(Task::getId)) assertThat(selectedAndClaimedTasks).extracting(Task::getId)
.containsExactlyInAnyOrder( .containsExactlyInAnyOrder(
"TKI:000000000000000000000000000000000003", "TKI:000000000000000000000000000000000003",
"TKI:000000000000000000000000000000000004", "TKI:000000000000000000000000000000000004",
"TKI:000000000000000000000000000000000005", "TKI:000000000000000000000000000000000005",
"TKI:000000000000000000000000000000000006"); "TKI:000000000000000000000000000000000006");
assertThat(selectedAndClaimedTasks.stream().map(Task::getOwner)) assertThat(selectedAndClaimedTasks).extracting(Task::getOwner)
.containsExactlyInAnyOrder("admin", "taskadmin", "teamlead-1", "teamlead-2"); .containsExactlyInAnyOrder("admin", "taskadmin", "teamlead-1", "teamlead-2");
} }

View File

@ -439,7 +439,7 @@ public class TaskController extends AbstractPagingController {
params.remove(EXTERNAL_ID); params.remove(EXTERNAL_ID);
} }
for (int i = 1; i < 17; i++) { for (int i = 1; i <= 16; i++) {
if (params.containsKey(CUSTOM + i)) { if (params.containsKey(CUSTOM + i)) {
String[] customValues = extractCommaSeparatedFields(params.get(CUSTOM + i)); String[] customValues = extractCommaSeparatedFields(params.get(CUSTOM + i));
taskQuery.customAttributeIn(String.valueOf(i), customValues); taskQuery.customAttributeIn(String.valueOf(i), customValues);