Skip to content

Commit cbd8ad4

Browse files
authored
Fix annotations in PolarisEntityManager (#1149)
Following up on #1131: * Fix annotations in `PolarisEntityManager` * Add unit tests for running without `EntityCache`
1 parent f425417 commit cbd8ad4

File tree

4 files changed

+80
-10
lines changed

4 files changed

+80
-10
lines changed

polaris-core/src/main/java/org/apache/polaris/core/persistence/PolarisEntityManager.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import jakarta.annotation.Nonnull;
2222
import jakarta.annotation.Nullable;
23-
import jakarta.inject.Inject;
2423
import jakarta.ws.rs.core.SecurityContext;
2524
import java.util.List;
2625
import org.apache.polaris.core.context.CallContext;
@@ -52,13 +51,12 @@ public class PolarisEntityManager {
5251
/**
5352
* @param metaStoreManager the metastore manager for the current realm
5453
* @param credentialCache the storage credential cache for the current realm
55-
* @param entityCache the entity cache
54+
* @param entityCache the entity cache to use (it may be {@code null}).
5655
*/
57-
@Inject
5856
public PolarisEntityManager(
5957
@Nonnull PolarisMetaStoreManager metaStoreManager,
6058
@Nonnull StorageCredentialCache credentialCache,
61-
@Nonnull EntityCache entityCache) {
59+
@Nullable EntityCache entityCache) {
6260
this.metaStoreManager = metaStoreManager;
6361
this.credentialCache = credentialCache;
6462
this.entityCache = entityCache;

quarkus/service/src/test/java/org/apache/polaris/service/quarkus/catalog/BasePolarisCatalogTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
import com.google.cloud.storage.StorageException;
3232
import com.google.common.collect.ImmutableMap;
3333
import io.quarkus.test.junit.QuarkusMock;
34-
import io.quarkus.test.junit.QuarkusTest;
3534
import io.quarkus.test.junit.QuarkusTestProfile;
36-
import io.quarkus.test.junit.TestProfile;
3735
import jakarta.annotation.Nonnull;
36+
import jakarta.annotation.Nullable;
3837
import jakarta.inject.Inject;
3938
import jakarta.ws.rs.core.SecurityContext;
4039
import java.io.IOException;
@@ -140,9 +139,7 @@
140139
import software.amazon.awssdk.services.sts.model.AssumeRoleResponse;
141140
import software.amazon.awssdk.services.sts.model.Credentials;
142141

143-
@QuarkusTest
144-
@TestProfile(BasePolarisCatalogTest.Profile.class)
145-
public class BasePolarisCatalogTest extends CatalogTests<BasePolarisCatalog> {
142+
public abstract class BasePolarisCatalogTest extends CatalogTests<BasePolarisCatalog> {
146143

147144
public static class Profile implements QuarkusTestProfile {
148145

@@ -195,6 +192,9 @@ public static void setUpMocks() {
195192
QuarkusMock.installMockForType(mock, PolarisStorageIntegrationProviderImpl.class);
196193
}
197194

195+
@Nullable
196+
protected abstract EntityCache createEntityCache(PolarisMetaStoreManager metaStoreManager);
197+
198198
@BeforeEach
199199
@SuppressWarnings("unchecked")
200200
public void before(TestInfo testInfo) {
@@ -212,7 +212,7 @@ public void before(TestInfo testInfo) {
212212
Clock.systemDefaultZone());
213213
entityManager =
214214
new PolarisEntityManager(
215-
metaStoreManager, new StorageCredentialCache(), new EntityCache(metaStoreManager));
215+
metaStoreManager, new StorageCredentialCache(), createEntityCache(metaStoreManager));
216216

217217
callContext = CallContext.of(realmContext, polarisContext);
218218

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.service.quarkus.catalog;
20+
21+
import io.quarkus.test.junit.QuarkusTest;
22+
import io.quarkus.test.junit.TestProfile;
23+
import jakarta.annotation.Nullable;
24+
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
25+
import org.apache.polaris.core.persistence.cache.EntityCache;
26+
27+
@QuarkusTest
28+
@TestProfile(BasePolarisCatalogTest.Profile.class)
29+
public class PolarisCatalogNoEntityCacheTest extends BasePolarisCatalogTest {
30+
31+
@Nullable
32+
@Override
33+
protected EntityCache createEntityCache(PolarisMetaStoreManager metaStoreManager) {
34+
return null;
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.polaris.service.quarkus.catalog;
20+
21+
import io.quarkus.test.junit.QuarkusTest;
22+
import io.quarkus.test.junit.TestProfile;
23+
import jakarta.annotation.Nullable;
24+
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
25+
import org.apache.polaris.core.persistence.cache.EntityCache;
26+
27+
@QuarkusTest
28+
@TestProfile(BasePolarisCatalogTest.Profile.class)
29+
public class PolarisCatalogWithEntityCacheTest extends BasePolarisCatalogTest {
30+
31+
@Nullable
32+
@Override
33+
protected EntityCache createEntityCache(PolarisMetaStoreManager metaStoreManager) {
34+
return new EntityCache(metaStoreManager);
35+
}
36+
}

0 commit comments

Comments
 (0)