Commit 43dbe78
authored
CNDB-15617: ClienState checks if system before super (#2039)
### What is the issue
`ClientState.isSystem()` only checks the `isInternal` field, which is
false for external client states created via `forExternalCalls(user)`.
This causes the method to return false even when the authenticated user
is `AuthenticatedUser.SYSTEM_USER`.
This leads to incorrect behavior in `isOrdinaryUser()`, which calls
`isSuper()` for `SYSTEM_USER`, triggering expensive database queries via
`Roles.hasSuperuserStatus()`. During system initialization when auth
tables aren't fully ready, this causes `NullPointerException` because
`CassandraRoleManager.loadRoleStatement` may not be initialized yet.
### What does this PR fix and why was it fixed
Change `isSystem()` to check both the internal flag and the user
identity, change `isOrdinaryUser()` to check system users before super
users.1 parent 5e94c3c commit 43dbe78
1 file changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| 611 | + | |
611 | 612 | | |
612 | | - | |
613 | | - | |
| 613 | + | |
| 614 | + | |
614 | 615 | | |
615 | 616 | | |
616 | 617 | | |
| |||
633 | 634 | | |
634 | 635 | | |
635 | 636 | | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
636 | 640 | | |
637 | 641 | | |
638 | 642 | | |
639 | 643 | | |
640 | | - | |
| 644 | + | |
641 | 645 | | |
642 | 646 | | |
643 | 647 | | |
| |||
0 commit comments