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 3 times, most recently 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!

@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
@ahus1 ahus1 dismissed stale reviews from pedroigor and pruivo via d1e07d3 October 24, 2025 19:39
pedroigor
pedroigor previously approved these changes Oct 24, 2025
@keycloak-github-bot
Copy link

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.federation.ldap.LDAPProvidersIntegrationTest#updateLDAPUsernameTest

Keycloak CI - Base IT (5)

java.lang.AssertionError
	at org.junit.Assert.fail(Assert.java:87)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.junit.Assert.assertNotNull(Assert.java:713)
	at org.junit.Assert.assertNotNull(Assert.java:723)
...

Report flaky test

Copy link

@keycloak-github-bot keycloak-github-bot bot left a comment

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@ahus1 ahus1 marked this pull request as draft October 27, 2025 06:23
auto-merge was automatically disabled October 27, 2025 06:23

Pull request was converted to draft

@ahus1
Copy link
Contributor Author

ahus1 commented Oct 27, 2025

Still some tests failing, needing more time to analyze this.

ahus1 added 5 commits October 31, 2025 16:23
Signed-off-by: Alexander Schwartz <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
@ahus1 ahus1 force-pushed the is-43682-avoid-cache-invalidation-on-non-changes branch from a5b508f to a84a2a9 Compare October 31, 2025 15:28
ahus1 added 2 commits October 31, 2025 18:32
Signed-off-by: Alexander Schwartz <[email protected]>
Signed-off-by: Alexander Schwartz <[email protected]>
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