From 65243f80e8340b3fca2a913f3869c0f5fbd4504e Mon Sep 17 00:00:00 2001 From: Yuya Ebihara Date: Tue, 22 Oct 2024 20:06:50 +0900 Subject: [PATCH] Enable errorprone PatternMatchingInstanceof --- build-logic/src/main/kotlin/polaris-java.gradle.kts | 1 + .../catalog/PolarisPassthroughResolutionView.java | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/build-logic/src/main/kotlin/polaris-java.gradle.kts b/build-logic/src/main/kotlin/polaris-java.gradle.kts index 7c5aebac57..c8ef9bbe33 100644 --- a/build-logic/src/main/kotlin/polaris-java.gradle.kts +++ b/build-logic/src/main/kotlin/polaris-java.gradle.kts @@ -44,6 +44,7 @@ tasks.withType(JavaCompile::class.java).configureEach { "MissingOverride", "ModifiedButNotUsed", "OrphanedFormatString", + "PatternMatchingInstanceof", "StringCaseLocaleUsage", ) } diff --git a/polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisPassthroughResolutionView.java b/polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisPassthroughResolutionView.java index 761d82cb58..313e0265f0 100644 --- a/polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisPassthroughResolutionView.java +++ b/polaris-service/src/test/java/org/apache/polaris/service/catalog/PolarisPassthroughResolutionView.java @@ -69,8 +69,7 @@ public PolarisResolvedPathWrapper getResolvedPath(Object key) { PolarisResolutionManifest manifest = entityManager.prepareResolutionManifest(callContext, authenticatedPrincipal, catalogName); - if (key instanceof Namespace) { - Namespace namespace = (Namespace) key; + if (key instanceof Namespace namespace) { manifest.addPath( new ResolverPath(Arrays.asList(namespace.levels()), PolarisEntityType.NAMESPACE), namespace); @@ -88,8 +87,7 @@ public PolarisResolvedPathWrapper getResolvedPath(Object key, PolarisEntitySubTy PolarisResolutionManifest manifest = entityManager.prepareResolutionManifest(callContext, authenticatedPrincipal, catalogName); - if (key instanceof TableIdentifier) { - TableIdentifier identifier = (TableIdentifier) key; + if (key instanceof TableIdentifier identifier) { manifest.addPath( new ResolverPath( PolarisCatalogHelpers.tableIdentifierToList(identifier), @@ -110,8 +108,7 @@ public PolarisResolvedPathWrapper getPassthroughResolvedPath(Object key) { PolarisResolutionManifest manifest = entityManager.prepareResolutionManifest(callContext, authenticatedPrincipal, catalogName); - if (key instanceof Namespace) { - Namespace namespace = (Namespace) key; + if (key instanceof Namespace namespace) { manifest.addPassthroughPath( new ResolverPath(Arrays.asList(namespace.levels()), PolarisEntityType.NAMESPACE), namespace); @@ -129,8 +126,7 @@ public PolarisResolvedPathWrapper getPassthroughResolvedPath( PolarisResolutionManifest manifest = entityManager.prepareResolutionManifest(callContext, authenticatedPrincipal, catalogName); - if (key instanceof TableIdentifier) { - TableIdentifier identifier = (TableIdentifier) key; + if (key instanceof TableIdentifier identifier) { manifest.addPassthroughPath( new ResolverPath( PolarisCatalogHelpers.tableIdentifierToList(identifier),