Skip to content

Commit

Permalink
Remove unused local variables
Browse files Browse the repository at this point in the history
  • Loading branch information
findepi committed Aug 23, 2024
1 parent f8a423c commit 1524ad7
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public EnumMap<PolarisCredentialProperty, String> getSubscopedCreds(
} catch (IOException e) {
throw new RuntimeException("Unable to refresh GCP credentials", e);
}
AccessToken sourceCredentialsAccessToken = this.sourceCredentials.getAccessToken();

CredentialAccessBoundary accessBoundary =
generateAccessBoundaryRules(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void testValidateAccessToLocationsWithWildcard() {
}
},
Clock.systemUTC());
try (CallContext cc =
try (CallContext ignored =
CallContext.setCurrentContext(CallContext.of(() -> "realm", polarisCallContext))) {
Map<String, Map<PolarisStorageActions, PolarisStorageIntegration.ValidationResult>> result =
storage.validateAccessToLocations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,13 @@ public void testCacheGenerateNewEntries() {
int cacheSize = 0;
// different catalog will generate new cache entries
for (PolarisEntity entity : entityList) {
Map<String, String> res =
storageCredentialCache.getOrGenerateSubScopeCreds(
metaStoreManager,
callCtx,
entity,
true,
new HashSet<>(Arrays.asList("s3://bucket1/path", "s3://bucket2/path")),
new HashSet<>(Arrays.asList("s3://bucket/path")));
storageCredentialCache.getOrGenerateSubScopeCreds(
metaStoreManager,
callCtx,
entity,
true,
new HashSet<>(Arrays.asList("s3://bucket1/path", "s3://bucket2/path")),
new HashSet<>(Arrays.asList("s3://bucket/path")));
Assertions.assertThat(storageCredentialCache.getEstimatedSize()).isEqualTo(++cacheSize);
}
// update the entity's storage config, since StorageConfig changed, cache will generate new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ public List<PolarisEntity> listAssigneePrincipalRolesForCatalogRole(
PolarisAuthorizableOperation.LIST_ASSIGNEE_PRINCIPAL_ROLES_FOR_CATALOG_ROLE;
authorizeBasicCatalogRoleOperationOrThrow(op, catalogName, catalogRoleName);

PolarisEntity catalogEntity =
CatalogEntity ignored =
findCatalogByName(catalogName)
.orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName));
PolarisEntity catalogRoleEntity =
Expand Down Expand Up @@ -1700,7 +1700,7 @@ private boolean grantPrivilegeOnTableLikeToRole(
TableIdentifier identifier,
PolarisEntitySubType subType,
PolarisPrivilege privilege) {
PolarisEntity catalogEntity =
CatalogEntity ignored =
findCatalogByName(catalogName)
.orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName));
PolarisEntity catalogRoleEntity =
Expand Down Expand Up @@ -1739,7 +1739,7 @@ private boolean revokePrivilegeOnTableLikeFromRole(
TableIdentifier identifier,
PolarisEntitySubType subType,
PolarisPrivilege privilege) {
PolarisEntity catalogEntity =
CatalogEntity ignored =
findCatalogByName(catalogName)
.orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName));
PolarisEntity catalogRoleEntity =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import java.util.function.Supplier;
import org.apache.iceberg.BaseMetadataTable;
import org.apache.iceberg.BaseTable;
import org.apache.iceberg.BaseTransaction;
import org.apache.iceberg.MetadataUpdate;
import org.apache.iceberg.PartitionSpec;
import org.apache.iceberg.SortOrder;
Expand Down Expand Up @@ -962,8 +961,6 @@ public void commitTransaction(CommitTransactionRequest commitTransactionRequest)
Transaction transaction =
Transactions.newTransaction(
change.identifier().toString(), ((BaseTable) table).operations());
BaseTransaction.TransactionTable txTable =
(BaseTransaction.TransactionTable) transaction.table();
CatalogHandlers.updateTable(baseCatalog, change.identifier(), change);
return transaction;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,16 @@ public static void setup(

@AfterAll
public static void deletePrincipalRole() {
try (Response deletePrResponse =
EXT.client()
.target(
String.format(
"http://localhost:%d/api/management/v1/principal-roles/%s",
EXT.getLocalPort(), PRINCIPAL_ROLE_NAME))
.request("application/json")
.header("Authorization", "Bearer " + userToken)
.header(REALM_PROPERTY_KEY, realm)
.delete()) {}
EXT.client()
.target(
String.format(
"http://localhost:%d/api/management/v1/principal-roles/%s",
EXT.getLocalPort(), PRINCIPAL_ROLE_NAME))
.request("application/json")
.header("Authorization", "Bearer " + userToken)
.header(REALM_PROPERTY_KEY, realm)
.delete()
.close();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import io.polaris.core.entity.PrincipalRoleEntity;
import io.polaris.core.persistence.PolarisEntityManager;
import io.polaris.core.persistence.PolarisMetaStoreManager;
import io.polaris.core.persistence.PolarisTreeMapStore;
import io.polaris.core.persistence.resolver.PolarisResolutionManifest;
import io.polaris.core.storage.cache.StorageCredentialCache;
import io.polaris.service.catalog.BasePolarisCatalog;
Expand Down Expand Up @@ -142,7 +141,6 @@ public abstract class PolarisAuthzTestBase {
@SuppressWarnings("unchecked")
public void before() {
PolarisDiagnostics diagServices = new PolarisDefaultDiagServiceImpl();
PolarisTreeMapStore backingStore = new PolarisTreeMapStore(diagServices);
InMemoryPolarisMetaStoreManagerFactory managerFactory =
new InMemoryPolarisMetaStoreManagerFactory();
managerFactory.setStorageIntegrationProvider(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,10 @@ public void tearDown() {
try (Response response = newRequest("http://localhost:%d/api/management/v1/catalogs").get()) {
response.readEntity(Catalogs.class).getCatalogs().stream()
.forEach(
catalog -> {
try (Response innerResponse =
newRequest(
"http://localhost:%d/api/management/v1/catalogs/" + catalog.getName())
.delete()) {}
});
catalog ->
newRequest("http://localhost:%d/api/management/v1/catalogs/" + catalog.getName())
.delete()
.close());
}
try (Response response = newRequest("http://localhost:%d/api/management/v1/principals").get()) {
response.readEntity(Principals.class).getPrincipals().stream()
Expand All @@ -120,11 +118,10 @@ public void tearDown() {
!principal.getName().equals(PolarisEntityConstants.getRootPrincipalName()))
.forEach(
principal -> {
try (Response innerResponse =
newRequest(
"http://localhost:%d/api/management/v1/principals/"
+ principal.getName())
.delete()) {}
newRequest(
"http://localhost:%d/api/management/v1/principals/" + principal.getName())
.delete()
.close();
});
}
try (Response response =
Expand All @@ -137,11 +134,11 @@ public void tearDown() {
.equals(PolarisEntityConstants.getNameOfPrincipalServiceAdminRole()))
.forEach(
principalRole -> {
try (Response innerResponse =
newRequest(
"http://localhost:%d/api/management/v1/principal-roles/"
+ principalRole.getName())
.delete()) {}
newRequest(
"http://localhost:%d/api/management/v1/principal-roles/"
+ principalRole.getName())
.delete()
.close();
});
}
}
Expand Down Expand Up @@ -212,21 +209,6 @@ public void testListCatalogsUnauthorized() {

@Test
public void testCreateCatalog() {
AwsStorageConfigInfo awsConfigModel =
AwsStorageConfigInfo.builder()
.setRoleArn("arn:aws:iam::123456789012:role/my-role")
.setExternalId("externalId")
.setUserArn("userArn")
.setStorageType(StorageConfigInfo.StorageTypeEnum.S3)
.setAllowedLocations(List.of("s3://my-old-bucket/path/to/data"))
.build();
Catalog catalog =
PolarisCatalog.builder()
.setType(Catalog.TypeEnum.INTERNAL)
.setName("my-catalog")
.setProperties(new CatalogProperties("s3://my-bucket/path/to/data"))
.setStorageConfigInfo(awsConfigModel)
.build();
try (Response response =
newRequest("http://localhost:%d/api/management/v1/catalogs")
.post(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ public void testCreateTableDirectAllSufficientPrivileges() {

@Test
public void testCreateTableDirectInsufficientPermissions() {
final TableIdentifier newtable = TableIdentifier.of(NS2, "newtable");
final CreateTableRequest createRequest =
CreateTableRequest.builder().withName("newtable").withSchema(SCHEMA).build();

Expand Down Expand Up @@ -789,7 +788,6 @@ public void testRegisterTableInsufficientPermissions() {
// To get a handy metadata file we can use one from another table.
final String metadataLocation = newWrapper().loadTable(TABLE_NS1_1, "all").metadataLocation();

final TableIdentifier newtable = TableIdentifier.of(NS2, "newtable");
final RegisterTableRequest registerRequest =
new RegisterTableRequest() {
@Override
Expand Down Expand Up @@ -1342,8 +1340,6 @@ public void testCreateViewAllSufficientPrivileges() {

@Test
public void testCreateViewInsufficientPermissions() {
final TableIdentifier newview = TableIdentifier.of(NS2, "newview");

final CreateViewRequest createRequest =
ImmutableCreateViewRequest.builder()
.name("newview")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void before(
assertThat(response)
.returns(Response.Status.OK.getStatusCode(), Response::getStatus);
CatalogRole catalogRole = response.readEntity(CatalogRole.class);
try (Response assignResponse =
try (Response ignore =
EXT.client()
.target(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,29 +178,29 @@ public void afterAll(ExtensionContext extensionContext) throws Exception {
adminSecrets.getMainSecret(),
realm);

try (Response deletePrResponse =
dropwizard
.client()
.target(
String.format(
"http://localhost:%d/api/management/v1/principal-roles/%s",
dropwizard.getLocalPort(), "catalog-admin"))
.request("application/json")
.header("Authorization", "Bearer " + userToken)
.header(REALM_PROPERTY_KEY, realm)
.delete()) {}

try (Response deleteResponse =
dropwizard
.client()
.target(
String.format(
"http://localhost:%d/api/management/v1/principals/%s",
dropwizard.getLocalPort(), "snowman"))
.request("application/json")
.header("Authorization", "Bearer " + userToken)
.header(REALM_PROPERTY_KEY, realm)
.delete()) {}
dropwizard
.client()
.target(
String.format(
"http://localhost:%d/api/management/v1/principal-roles/%s",
dropwizard.getLocalPort(), "catalog-admin"))
.request("application/json")
.header("Authorization", "Bearer " + userToken)
.header(REALM_PROPERTY_KEY, realm)
.delete()
.close();

dropwizard
.client()
.target(
String.format(
"http://localhost:%d/api/management/v1/principals/%s",
dropwizard.getLocalPort(), "snowman"))
.request("application/json")
.header("Authorization", "Bearer " + userToken)
.header(REALM_PROPERTY_KEY, realm)
.delete()
.close();
}

// FIXME - this would be better done with a Credentials-specific annotation processor so
Expand Down

0 comments on commit 1524ad7

Please sign in to comment.