Skip to content

Commit

Permalink
[HOPS-520] fix UsersGroups.getGroupsFromDB() to always commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
berthoug authored and Gautier Berthou committed Jul 4, 2018
1 parent 81bc673 commit 1a1e935
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,9 @@ private static Pair<User, List<Group>> getGroupsFromDB(final String userName)
(UsersOperationsType.GET_USER_GROUPS) {
@Override
public Object performTask() throws StorageException, IOException {
Pair<User, List<Group>> result = null;
boolean transactionActive = connector.isTransactionActive();

if (!transactionActive) {
connector.beginTransaction();
}
Expand All @@ -269,17 +270,15 @@ public Object performTask() throws StorageException, IOException {
User user = userId == null ? userDataAccess.getUser(userName) :
userDataAccess.getUser(userId);

if (user == null) {
return null;
if (user != null) {
List<Group> groups = userGroupDataAccess.getGroupsForUser(user.getId());
result = new Pair<User, List<Group>>(user, groups);
}

List<Group> groups = userGroupDataAccess.getGroupsForUser(user.getId());

if (!transactionActive) {
connector.commit();
}

return new Pair<User, List<Group>>(user, groups);
return result;
}
};

Expand Down

0 comments on commit 1a1e935

Please sign in to comment.