Skip to content

Fix PolarisAdminServiceTest - #5637

Merged
dimas-b merged 1 commit into
apache:mainfrom
dimas-b:fix-PolarisAdminServiceTest
Sep 28, 2026
Merged

dimas-b merged 1 commit into
apache:mainfrom
dimas-b:fix-PolarisAdminServiceTest

Conversation

@dimas-b

@dimas-b dimas-b commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Fix NPE on AttributeMap in testRotateCredentialsConcurrentModificationThrowsCommitConflictException() caused by overlapped merges of #5504 and #5119

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

Fix NPE on `AttributeMap` in `testRotateCredentialsConcurrentModificationThrowsCommitConflictException()`
caused by overlapped merges of apache#5504 and apache#5119

@ayushtkn ayushtkn left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Even I was fixing this, the error showed on my commit on main, I thought I broke it 😅

Thanx @dimas-b for the quick fix 😀

I tried it this way

diff --git a/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAdminServiceTest.java b/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAdminServiceTest.java
index 427420af78..a5b3aa1bd7 100644
--- a/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAdminServiceTest.java
+++ b/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAdminServiceTest.java
@@ -55,6 +55,7 @@ import org.apache.polaris.core.auth.AuthorizationState;
 import org.apache.polaris.core.auth.PolarisAuthorizer;
 import org.apache.polaris.core.auth.PolarisPrincipal;
 import org.apache.polaris.core.catalog.PolarisCatalogHelpers;
+import org.apache.polaris.core.collection.ImmutableAttributeMap;
 import org.apache.polaris.core.config.BehaviorChangeConfiguration;
 import org.apache.polaris.core.config.FeatureConfiguration;
 import org.apache.polaris.core.config.RealmConfig;
@@ -1086,6 +1087,8 @@ public class PolarisAdminServiceTest {
     when(resolutionManifest.getResolvedTopLevelEntity(
             eq(principalName), eq(PolarisEntityType.PRINCIPAL)))
         .thenReturn(wrapper);
+    when(authenticatedPrincipal.getAttributes())
+        .thenReturn(ImmutableAttributeMap.builder().build());
 
     PolarisPrincipalSecrets currentSecrets =
         new PolarisPrincipalSecrets(100L, "test_client", "main_secret");

@dimas-b

dimas-b commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

@ayushtkn : yeah, I thought about mocking, but given that PolarisPrincipal is actually an "immutable" class with certain non-null validations and expectations, I figured that using its proper .of() method would be more robust.

@dimas-b
dimas-b enabled auto-merge (squash) September 28, 2026 18:24

@vigneshio vigneshio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM..

@dimas-b
dimas-b merged commit ac7d1d3 into apache:main Sep 28, 2026
43 of 45 checks passed
@dimas-b
dimas-b deleted the fix-PolarisAdminServiceTest branch September 28, 2026 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants