Skip to content

Commit

Permalink
Issue 49783: UserManager Optimistic Concurrency Exception (#5278)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-jeckels authored Feb 28, 2024
1 parent d1f2249 commit d9a3d30
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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

0 comments on commit d9a3d30

Please sign in to comment.