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 21a7179be9..033730cb9f 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 @@ 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 b7edeb6f3a..7f0b73e9c6 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.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.AssumeRoleResponse; import software.amazon.awssdk.services.sts.model.Credentials; -@QuarkusTest -@TestProfile(BasePolarisCatalogTest.Profile.class) -public class BasePolarisCatalogTest extends CatalogTests { +public abstract class BasePolarisCatalogTest extends CatalogTests { public static class Profile implements QuarkusTestProfile { @@ -195,6 +192,9 @@ public static void setUpMocks() { 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 void before(TestInfo testInfo) { 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 0000000000..5389dcd826 --- /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 0000000000..f408267d07 --- /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); + } +}