This is an automated email from the ASF dual-hosted git repository.

dimas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new cbd8ad4d9 Fix annotations in `PolarisEntityManager` (#1149)
cbd8ad4d9 is described below

commit cbd8ad4d91f1e06f0cbd4916addb67a8dbfc52f1
Author: Dmitri Bourlatchkov <[email protected]>
AuthorDate: Tue Mar 11 11:03:38 2025 -0400

    Fix annotations in `PolarisEntityManager` (#1149)
    
    Following up on #1131:
    
    * Fix annotations in `PolarisEntityManager`
    
    * Add unit tests for running without `EntityCache`
---
 .../core/persistence/PolarisEntityManager.java     |  6 ++--
 .../quarkus/catalog/BasePolarisCatalogTest.java    | 12 ++++----
 .../catalog/PolarisCatalogNoEntityCacheTest.java   | 36 ++++++++++++++++++++++
 .../catalog/PolarisCatalogWithEntityCacheTest.java | 36 ++++++++++++++++++++++
 4 files changed, 80 insertions(+), 10 deletions(-)

diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisEntityManager.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisEntityManager.java
index 21a7179be..033730cb9 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisEntityManager.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisEntityManager.java
@@ -20,7 +20,6 @@ package org.apache.polaris.core.persistence;
 
 import jakarta.annotation.Nonnull;
 import jakarta.annotation.Nullable;
-import jakarta.inject.Inject;
 import jakarta.ws.rs.core.SecurityContext;
 import java.util.List;
 import org.apache.polaris.core.context.CallContext;
@@ -52,13 +51,12 @@ public class PolarisEntityManager {
   /**
    * @param metaStoreManager the metastore manager for the current realm
    * @param credentialCache the storage credential cache for the current realm
-   * @param entityCache the entity cache
+   * @param entityCache the entity cache to use (it may be {@code null}).
    */
-  @Inject
   public PolarisEntityManager(
       @Nonnull PolarisMetaStoreManager metaStoreManager,
       @Nonnull StorageCredentialCache credentialCache,
-      @Nonnull EntityCache entityCache) {
+      @Nullable EntityCache entityCache) {
     this.metaStoreManager = metaStoreManager;
     this.credentialCache = credentialCache;
     this.entityCache = entityCache;
diff --git 
a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/BasePolarisCatalogTest.java
 
b/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/BasePolarisCatalogTest.java
index b7edeb6f3..7f0b73e9c 100644
--- 
a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/BasePolarisCatalogTest.java
+++ 
b/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/BasePolarisCatalogTest.java
@@ -31,10 +31,9 @@ import com.azure.core.exception.HttpResponseException;
 import com.google.cloud.storage.StorageException;
 import com.google.common.collect.ImmutableMap;
 import io.quarkus.test.junit.QuarkusMock;
-import io.quarkus.test.junit.QuarkusTest;
 import io.quarkus.test.junit.QuarkusTestProfile;
-import io.quarkus.test.junit.TestProfile;
 import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
 import jakarta.inject.Inject;
 import jakarta.ws.rs.core.SecurityContext;
 import java.io.IOException;
@@ -140,9 +139,7 @@ import 
software.amazon.awssdk.services.sts.model.AssumeRoleRequest;
 import software.amazon.awssdk.services.sts.model.AssumeRoleResponse;
 import software.amazon.awssdk.services.sts.model.Credentials;
 
-@QuarkusTest
-@TestProfile(BasePolarisCatalogTest.Profile.class)
-public class BasePolarisCatalogTest extends CatalogTests<BasePolarisCatalog> {
+public abstract class BasePolarisCatalogTest extends 
CatalogTests<BasePolarisCatalog> {
 
   public static class Profile implements QuarkusTestProfile {
 
@@ -195,6 +192,9 @@ public class BasePolarisCatalogTest extends 
CatalogTests<BasePolarisCatalog> {
     QuarkusMock.installMockForType(mock, 
PolarisStorageIntegrationProviderImpl.class);
   }
 
+  @Nullable
+  protected abstract EntityCache createEntityCache(PolarisMetaStoreManager 
metaStoreManager);
+
   @BeforeEach
   @SuppressWarnings("unchecked")
   public void before(TestInfo testInfo) {
@@ -212,7 +212,7 @@ public class BasePolarisCatalogTest extends 
CatalogTests<BasePolarisCatalog> {
             Clock.systemDefaultZone());
     entityManager =
         new PolarisEntityManager(
-            metaStoreManager, new StorageCredentialCache(), new 
EntityCache(metaStoreManager));
+            metaStoreManager, new StorageCredentialCache(), 
createEntityCache(metaStoreManager));
 
     callContext = CallContext.of(realmContext, polarisContext);
 
diff --git 
a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/PolarisCatalogNoEntityCacheTest.java
 
b/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/PolarisCatalogNoEntityCacheTest.java
new file mode 100644
index 000000000..5389dcd82
--- /dev/null
+++ 
b/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/PolarisCatalogNoEntityCacheTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.quarkus.catalog;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.TestProfile;
+import jakarta.annotation.Nullable;
+import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
+import org.apache.polaris.core.persistence.cache.EntityCache;
+
+@QuarkusTest
+@TestProfile(BasePolarisCatalogTest.Profile.class)
+public class PolarisCatalogNoEntityCacheTest extends BasePolarisCatalogTest {
+
+  @Nullable
+  @Override
+  protected EntityCache createEntityCache(PolarisMetaStoreManager 
metaStoreManager) {
+    return null;
+  }
+}
diff --git 
a/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/PolarisCatalogWithEntityCacheTest.java
 
b/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/PolarisCatalogWithEntityCacheTest.java
new file mode 100644
index 000000000..f408267d0
--- /dev/null
+++ 
b/quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/PolarisCatalogWithEntityCacheTest.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.polaris.service.quarkus.catalog;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.TestProfile;
+import jakarta.annotation.Nullable;
+import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
+import org.apache.polaris.core.persistence.cache.EntityCache;
+
+@QuarkusTest
+@TestProfile(BasePolarisCatalogTest.Profile.class)
+public class PolarisCatalogWithEntityCacheTest extends BasePolarisCatalogTest {
+
+  @Nullable
+  @Override
+  protected EntityCache createEntityCache(PolarisMetaStoreManager 
metaStoreManager) {
+    return new EntityCache(metaStoreManager);
+  }
+}

Reply via email to