Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ahus1
Copy link
Contributor

@ahus1 ahus1 commented Oct 23, 2025

Closes #43682

@ahus1 ahus1 self-assigned this Oct 23, 2025
@ahus1 ahus1 force-pushed the is-43682-avoid-cache-invalidation-on-non-changes branch from 423c507 to 89839b0 Compare October 23, 2025 16:27
@ahus1 ahus1 force-pushed the is-43682-avoid-cache-invalidation-on-non-changes branch from 89839b0 to b6d5cf4 Compare October 23, 2025 17:21
Signed-off-by: Alexander Schwartz <[email protected]>
@ahus1 ahus1 force-pushed the is-43682-avoid-cache-invalidation-on-non-changes branch from 358f400 to 261b7f5 Compare October 24, 2025 08:21
@ahus1 ahus1 marked this pull request as ready for review October 24, 2025 10:03
@ahus1 ahus1 requested review from a team as code owners October 24, 2025 10:03
Comment on lines 252 to 286
@Override
public void addRequiredAction(RequiredAction action) {
if (updated == null && getRequiredActionsStream().anyMatch(s -> Objects.equals(s, action.name()))) {
return;
}
getDelegateForUpdate();
updated.addRequiredAction(action);
}

@Override
public void removeRequiredAction(RequiredAction action) {
if (getRequiredActionsStream().anyMatch(s -> Objects.equals(s, action.name()))) {
getDelegateForUpdate();
updated.removeRequiredAction(action);
if (updated == null && getRequiredActionsStream().noneMatch(s -> Objects.equals(s, action.name()))) {
return;
}
getDelegateForUpdate();
updated.removeRequiredAction(action);
}

@Override
public void addRequiredAction(String action) {
if (updated == null && getRequiredActionsStream().anyMatch(s -> Objects.equals(s, action))) {
return;
}
getDelegateForUpdate();
updated.addRequiredAction(action);
}

@Override
public void removeRequiredAction(String action) {
if (getRequiredActionsStream().anyMatch(s -> Objects.equals(s, action))) {
getDelegateForUpdate();
updated.removeRequiredAction(action);
if (updated == null && getRequiredActionsStream().noneMatch(s -> Objects.equals(s, action))) {
return;
}
getDelegateForUpdate();
updated.removeRequiredAction(action);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid creating and iterating over streams

    @Override
    public void addRequiredAction(RequiredAction action) {
        if (action == null || updated == null && getCachedRequiredActions().contains(action.name())) {
            return;
        }
        getDelegateForUpdate();
        updated.addRequiredAction(action);
    }

    @Override
    public void removeRequiredAction(RequiredAction action) {
        if (action == null || updated == null && !getCachedRequiredActions().contains(action.name())) {
            return;
        }
        getDelegateForUpdate();
        updated.removeRequiredAction(action);
    }

    @Override
    public void addRequiredAction(String action) {
        if (updated == null && getCachedRequiredActions().contains(action)) {
            return;
        }
        getDelegateForUpdate();
        updated.addRequiredAction(action);
    }

    @Override
    public void removeRequiredAction(String action) {
        if (updated == null && !getCachedRequiredActions().contains(action)) {
            return;
        }
        getDelegateForUpdate();
        updated.removeRequiredAction(action);
    }


    private Set<String> getCachedRequiredActions() {
        return cached.getRequiredActions(keycloakSession, modelSupplier);
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pruivo - please re-review. Thanks!

Signed-off-by: Alexander Schwartz <[email protected]>
@ahus1 ahus1 requested a review from pruivo October 24, 2025 12:52
pruivo
pruivo previously approved these changes Oct 24, 2025
Copy link
Contributor

@pruivo pruivo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'm not going to nitpick :)

@ahus1 ahus1 marked this pull request as draft October 24, 2025 14:39
@ahus1 ahus1 marked this pull request as ready for review October 24, 2025 14:57
@ahus1
Copy link
Contributor Author

ahus1 commented Oct 24, 2025

Let's keep this draft until the backports also work in other branches. In #43697, this run makes me think...

pedroigor
pedroigor previously approved these changes Oct 24, 2025
Signed-off-by: Alexander Schwartz <[email protected]>
@ahus1 ahus1 dismissed stale reviews from pedroigor and pruivo via d1e07d3 October 24, 2025 19:39
@pedroigor pedroigor enabled auto-merge (rebase) October 24, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When syncing roles, the database layer can see deadlocks

3 participants