**Build scan:**
https://gradle-enterprise.elastic.co/s/ydjw53ofin5xe/tests/:x-pack:plugin:security:test/org.elasticsearch.xpack.security.authz.store.CompositeRolesStoreTests/testRolesWhenDlsFlsLicensed

**Reproduction line:**
```
./gradlew ':x-pack:plugin:security:test' --tests "org.elasticsearch.xpack.security.authz.store.CompositeRolesStoreTests.testRolesWhenDlsFlsLicensed" -Dtests.seed=4D31E5D210B6F655 -Dtests.locale=th-TH-u-nu-thai-x-lvariant-TH -Dtests.timezone=Africa/Malabo -Druntime.java=20
```

**Applicable branches:**
main

**Reproduces locally?:**
Yes

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.security.authz.store.CompositeRolesStoreTests&tests.test=testRolesWhenDlsFlsLicensed

**Failure excerpt:**
```
java.lang.NullPointerException: (No message provided)

  at __randomizedtesting.SeedInfo.seed([4D31E5D210B6F655:FEBA916BDED268EB]:0)
  at java.util.Objects.requireNonNull(Objects.java:233)
  at org.elasticsearch.xpack.core.security.authz.store.ReservedRolesStore.accept(ReservedRolesStore.java:1018)
  at org.elasticsearch.xpack.security.authz.store.RoleDescriptorStore.lambda$loadRoleDescriptorsAsync$14(RoleDescriptorStore.java:262)
  at org.elasticsearch.xpack.core.common.IteratingActionListener.run(IteratingActionListener.java:117)
  at org.elasticsearch.xpack.security.authz.store.RoleDescriptorStore.loadRoleDescriptorsAsync(RoleDescriptorStore.java:283)
  at org.elasticsearch.xpack.security.authz.store.RoleDescriptorStore.roleDescriptors(RoleDescriptorStore.java:229)
  at org.elasticsearch.xpack.security.authz.store.RoleDescriptorStore.resolveRoleNames(RoleDescriptorStore.java:172)
  at org.elasticsearch.xpack.security.authz.store.RoleDescriptorStore.resolveNamedRoleReference(RoleDescriptorStore.java:89)
  at org.elasticsearch.xpack.core.security.authz.store.RoleReference$NamedRoleReference.resolve(RoleReference.java:71)
  at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.buildRoleFromRoleReference(CompositeRolesStore.java:278)
  at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.lambda$buildRole$1(RoleReferenceIntersection.java:53)
  at java.lang.Iterable.forEach(Iterable.java:75)
  at org.elasticsearch.xpack.core.security.authz.store.RoleReferenceIntersection.buildRole(RoleReferenceIntersection.java:53)
  at org.elasticsearch.xpack.security.authz.store.CompositeRolesStore.getRole(CompositeRolesStore.java:213)
  at org.elasticsearch.xpack.security.authz.store.CompositeRolesStoreTests.getRoleForRoleNames(CompositeRolesStoreTests.java:2755)
  at org.elasticsearch.xpack.security.authz.store.CompositeRolesStoreTests.testRolesWhenDlsFlsLicensed(CompositeRolesStoreTests.java:381)
  at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
  at java.lang.reflect.Method.invoke(Method.java:578)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.invoke(RandomizedRunner.java:1758)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$8.evaluate(RandomizedRunner.java:946)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$9.evaluate(RandomizedRunner.java:982)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$10.evaluate(RandomizedRunner.java:996)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleSetupTeardownChained$1.evaluate(TestRuleSetupTeardownChained.java:48)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleThreadAndTestName$1.evaluate(TestRuleThreadAndTestName.java:45)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.forkTimeoutingTask(ThreadLeakControl.java:843)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$3.evaluate(ThreadLeakControl.java:490)
  at com.carrotsearch.randomizedtesting.RandomizedRunner.runSingleTest(RandomizedRunner.java:955)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$5.evaluate(RandomizedRunner.java:840)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$6.evaluate(RandomizedRunner.java:891)
  at com.carrotsearch.randomizedtesting.RandomizedRunner$7.evaluate(RandomizedRunner.java:902)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleStoreClassName$1.evaluate(TestRuleStoreClassName.java:38)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.NoShadowingOrOverridesOnMethodsRule$1.evaluate(NoShadowingOrOverridesOnMethodsRule.java:40)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at org.apache.lucene.tests.util.TestRuleAssertionsRequired$1.evaluate(TestRuleAssertionsRequired.java:53)
  at org.apache.lucene.tests.util.AbstractBeforeAfterRule$1.evaluate(AbstractBeforeAfterRule.java:43)
  at org.apache.lucene.tests.util.TestRuleMarkFailure$1.evaluate(TestRuleMarkFailure.java:44)
  at org.apache.lucene.tests.util.TestRuleIgnoreAfterMaxFailures$1.evaluate(TestRuleIgnoreAfterMaxFailures.java:60)
  at org.apache.lucene.tests.util.TestRuleIgnoreTestSuites$1.evaluate(TestRuleIgnoreTestSuites.java:47)
  at com.carrotsearch.randomizedtesting.rules.StatementAdapter.evaluate(StatementAdapter.java:36)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl$StatementRunner.run(ThreadLeakControl.java:390)
  at com.carrotsearch.randomizedtesting.ThreadLeakControl.lambda$forkTimeoutingTask$0(ThreadLeakControl.java:850)
  at java.lang.Thread.run(Thread.java:1623)

```
x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java
assertThat(role.application().getApplicationNames(), empty());
        assertThat(role.cluster().privileges(), empty());
        assertThat(role.indices(), is(IndicesPermission.NONE));
        final InternalUser internalUser = InternalUsers.getUser(roleName);
        assertThat(internalUser, notNullValue());
        if (internalUser.getLocalClusterRoleDescriptor().isPresent()) {
            Role internalRole = compositeRolesStore.getInternalUserRole(internalUser);
            assertThat(internalRole, notNullValue());
            assertThat(role, not(internalRole));
        }
        final Role[] internalRoles = InternalUsers.get()
            .stream()
            .filter(u -> u.getLocalClusterRoleDescriptor().isPresent())
            .map(compositeRolesStore::getInternalUserRole)
            .toArray(Role[]::new);
        
        assertThat(internalRoles, arrayWithSize(greaterThan(1)));
        assertThat(role, not(is(oneOf(internalRoles))));
    }
    public void testGetRolesForSystemUserThrowsException() {
        final FileRolesStore fileRolesStore = mock(FileRolesStore.class);
        doCallRealMethod().when(fileRolesStore).accept(anySet(), anyActionListener());
        final NativeRolesStore nativeRolesStore = mock(NativeRolesStore.class);
        doCallRealMethod().when(nativeRolesStore).accept(anySet(), anyActionListener());
        when(fileRolesStore.roleDescriptors(anySet())).thenReturn(Collections.emptySet());
        doAnswer((invocationOnMock) -> {
            @SuppressWarnings("unchecked")
            ActionListener<RoleRetrievalResult> callback = (ActionListener<RoleRetrievalResult>) invocationOnMock.getArguments()[1];
            callback.onResponse(RoleRetrievalResult.failure(new RuntimeException("intentionally failed!")));
            return null;