Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 49783: UserManager Optimistic Concurrency Exception #5278

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions api/src/org/labkey/api/data/DbScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,9 @@ public Transaction ensureTransaction(TransactionKind transactionKind, Lock... lo
}

/**
* Starts a new transaction using a new Connection.
* Starts a new transaction using a new Connection. Most callers should use ensureTransaction() to join an existing
* transaction in the same database.
*
* The preferred usage pattern is:
* <pre>
* try (DbScope.Transaction transaction = scope.beginTransaction()) {
Expand All @@ -731,7 +733,9 @@ public Transaction beginTransaction(Lock... locks)
}

/**
* Starts a new transaction using a new Connection.
* Starts a new transaction using a new Connection. Most callers should use ensureTransaction() to join an existing
* transaction in the same database.
*
* The preferred usage pattern is:
* <pre>
* try (DbScope.Transaction transaction = scope.beginTransaction()) {
Expand Down
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/security/SecurityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ static void deleteGroup(int groupId)
groupId == Group.groupDevelopers)
throw new IllegalArgumentException("The global groups cannot be deleted.");

try (Transaction transaction = core.getScope().beginTransaction())
try (Transaction transaction = core.getScope().ensureTransaction())
{
Group group = getGroup(groupId);
if (null == group)
Expand Down Expand Up @@ -1516,7 +1516,7 @@ public static void deleteMembers(Group group, Collection<UserPrincipal> membersT
}
core.getSqlDialect().appendInClauseSql(sql, userIds);

try (Transaction transaction = core.getScope().beginTransaction())
try (Transaction transaction = core.getScope().ensureTransaction())
{
new SqlExecutor(core.getSchema()).execute(sql);

Expand Down
4 changes: 2 additions & 2 deletions api/src/org/labkey/api/security/UserManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ public static void deleteUser(int userId) throws UserManagementException
throw new RuntimeException(first);
}

try (Transaction transaction = CORE.getScope().beginTransaction())
try (Transaction transaction = CORE.getScope().ensureTransaction())
{
boolean needToEnsureRootAdmins = SecurityManager.isRootAdmin(user);

Expand Down Expand Up @@ -1017,7 +1017,7 @@ public static void setUserActive(User currentUser, User userToAdjust, boolean ac
throw new RuntimeException(first);
}

try (Transaction transaction = CoreSchema.getInstance().getScope().beginTransaction())
try (Transaction transaction = CoreSchema.getInstance().getScope().ensureTransaction())
{
Table.update(currentUser, CoreSchema.getInstance().getTableInfoPrincipals(),
Collections.singletonMap("Active", active), userId);
Expand Down