Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<BasePolarisCatalog> {
public abstract class BasePolarisCatalogTest extends CatalogTests<BasePolarisCatalog> {

public static class Profile implements QuarkusTestProfile {

Expand Down Expand Up @@ -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) {
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Comment on lines +33 to +35
Copy link
Contributor

@eric-maynard eric-maynard Mar 10, 2025

Choose a reason for hiding this comment

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

Non-blocking comment: is using null for this not existing a best practice? In Spark, you would much more commonly see Option used but that's scala.

We already use null like this in many places throughout Polaris, so even if we decide to make a change this PR can go ahead as-is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to using Optional if we have a consensus.

This specific change is just a cleanup effort to align annotations and tests with existing behaviour :)

}
Original file line number Diff line number Diff line change
@@ -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);
}
}