This is an automated email from the ASF dual-hosted git repository.

dimas pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 95ebdd359 Remove commons-lang3 dependency (#2456)
95ebdd359 is described below

commit 95ebdd359ed0956ddc7a771c37683f9a3ecb0176
Author: Christopher Lambert <xn...@gmx.de>
AuthorDate: Thu Aug 28 03:56:45 2025 +0200

    Remove commons-lang3 dependency (#2456)
    
    outside of tests we can replace the functionality with jdk11 and guava.
    also stop using `org.assertj.core.util` as its a non-public api.
---
 .../it/test/PolarisRestCatalogViewAwsIntegrationTest.java    |  2 +-
 .../it/test/PolarisRestCatalogViewAzureIntegrationTest.java  |  2 +-
 .../it/test/PolarisRestCatalogViewGcpIntegrationTest.java    |  2 +-
 polaris-core/build.gradle.kts                                |  1 -
 .../storage/azure/AzureCredentialStorageIntegrationTest.java |  2 +-
 .../apache/polaris/service/admin/PolarisAdminService.java    | 12 ++++++------
 .../polaris/service/auth/DefaultActiveRolesProvider.java     |  4 ++--
 .../apache/polaris/service/auth/DefaultAuthenticator.java    |  4 ++--
 .../main/java/org/apache/polaris/service/auth/JWTBroker.java |  5 ++---
 .../polaris/service/catalog/iceberg/IcebergCatalog.java      |  4 ++--
 .../polaris/service/catalog/io/ExceptionMappingFileIO.java   |  4 ++--
 .../polaris/service/exception/IcebergExceptionMapper.java    |  4 ++--
 .../org/apache/polaris/service/task/TaskFileIOSupplier.java  |  5 +----
 .../service/catalog/iceberg/IcebergCatalogAdapterTest.java   |  2 +-
 14 files changed, 24 insertions(+), 29 deletions(-)

diff --git 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAwsIntegrationTest.java
 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAwsIntegrationTest.java
index d6b7e39cb..63471c92b 100644
--- 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAwsIntegrationTest.java
+++ 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAwsIntegrationTest.java
@@ -18,12 +18,12 @@
  */
 package org.apache.polaris.service.it.test;
 
+import com.google.common.base.Strings;
 import java.util.List;
 import java.util.Optional;
 import java.util.stream.Stream;
 import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
-import org.assertj.core.util.Strings;
 
 /** Runs PolarisRestCatalogViewIntegrationTest on AWS. */
 public class PolarisRestCatalogViewAwsIntegrationTest
diff --git 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAzureIntegrationTest.java
 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAzureIntegrationTest.java
index 4a4eef984..9d2c4d84a 100644
--- 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAzureIntegrationTest.java
+++ 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewAzureIntegrationTest.java
@@ -18,11 +18,11 @@
  */
 package org.apache.polaris.service.it.test;
 
+import com.google.common.base.Strings;
 import java.util.List;
 import java.util.stream.Stream;
 import org.apache.polaris.core.admin.model.AzureStorageConfigInfo;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
-import org.assertj.core.util.Strings;
 
 /** Runs PolarisRestCatalogViewIntegrationTest on Azure. */
 public class PolarisRestCatalogViewAzureIntegrationTest
diff --git 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewGcpIntegrationTest.java
 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewGcpIntegrationTest.java
index f1c4a762a..3dea04e61 100644
--- 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewGcpIntegrationTest.java
+++ 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogViewGcpIntegrationTest.java
@@ -18,11 +18,11 @@
  */
 package org.apache.polaris.service.it.test;
 
+import com.google.common.base.Strings;
 import java.util.List;
 import java.util.stream.Stream;
 import org.apache.polaris.core.admin.model.GcpStorageConfigInfo;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
-import org.assertj.core.util.Strings;
 
 /** Runs PolarisRestCatalogViewIntegrationTest on GCP. */
 public class PolarisRestCatalogViewGcpIntegrationTest
diff --git a/polaris-core/build.gradle.kts b/polaris-core/build.gradle.kts
index f5a889241..9a5beb35c 100644
--- a/polaris-core/build.gradle.kts
+++ b/polaris-core/build.gradle.kts
@@ -42,7 +42,6 @@ dependencies {
   runtimeOnly("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
 
   implementation(libs.caffeine)
-  implementation(libs.commons.lang3)
   implementation(libs.commons.codec)
   implementation(libs.guava)
   implementation(libs.slf4j.api)
diff --git 
a/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java
 
b/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java
index 768f4c330..d1783baed 100644
--- 
a/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java
+++ 
b/polaris-core/src/test/java/org/apache/polaris/service/storage/azure/AzureCredentialStorageIntegrationTest.java
@@ -32,6 +32,7 @@ import 
com.azure.storage.file.datalake.DataLakeFileSystemClient;
 import com.azure.storage.file.datalake.DataLakeFileSystemClientBuilder;
 import com.azure.storage.file.datalake.models.DataLakeStorageException;
 import com.azure.storage.file.datalake.models.PathItem;
+import com.google.common.base.Strings;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.lang.annotation.ElementType;
@@ -52,7 +53,6 @@ import 
org.apache.polaris.core.storage.azure.AzureCredentialsStorageIntegration;
 import org.apache.polaris.core.storage.azure.AzureStorageConfigurationInfo;
 import org.assertj.core.api.Assertions;
 import org.assertj.core.api.Assumptions;
-import org.assertj.core.util.Strings;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtensionContext;
 import org.junit.jupiter.params.ParameterizedTest;
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
index 69f1c1006..d4c1892dc 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
@@ -21,6 +21,7 @@ package org.apache.polaris.service.admin;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 
+import com.google.common.base.Strings;
 import jakarta.annotation.Nonnull;
 import jakarta.annotation.Nullable;
 import jakarta.validation.constraints.NotNull;
@@ -37,7 +38,6 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.stream.Stream;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.iceberg.catalog.Namespace;
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.exceptions.AlreadyExistsException;
@@ -907,14 +907,14 @@ public class PolarisAdminService {
       // additionalProperties while neglecting to "echo" the 
default-base-location from the
       // fetched catalog, it's most user-friendly to treat a null or empty 
default-base-location
       // as meaning no intended change to the default-base-location.
-      if (StringUtils.isNotEmpty(newDefaultBaseLocation)) {
-        // New base location is already in the updated properties; we'll also 
potentially
-        // plumb it into the logic for setting an updated 
StorageConfigurationInfo.
-        defaultBaseLocation = newDefaultBaseLocation;
-      } else {
+      if (Strings.isNullOrEmpty(newDefaultBaseLocation)) {
         // No default-base-location present at all in the properties of the 
update request,
         // so we must restore it explicitly in the updateBuilder.
         updateBuilder.setDefaultBaseLocation(defaultBaseLocation);
+      } else {
+        // New base location is already in the updated properties; we'll also 
potentially
+        // plumb it into the logic for setting an updated 
StorageConfigurationInfo.
+        defaultBaseLocation = newDefaultBaseLocation;
       }
     }
     if (updateRequest.getStorageConfigInfo() != null) {
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultActiveRolesProvider.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultActiveRolesProvider.java
index 003b37bcd..a27d57476 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultActiveRolesProvider.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultActiveRolesProvider.java
@@ -18,6 +18,7 @@
  */
 package org.apache.polaris.service.auth;
 
+import com.google.common.base.Throwables;
 import io.smallrye.common.annotation.Identifier;
 import jakarta.enterprise.context.RequestScoped;
 import jakarta.inject.Inject;
@@ -25,7 +26,6 @@ import java.util.List;
 import java.util.Set;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.iceberg.exceptions.NotAuthorizedException;
 import org.apache.iceberg.exceptions.ServiceFailureException;
 import org.apache.polaris.core.PolarisCallContext;
@@ -61,7 +61,7 @@ public class DefaultActiveRolesProvider implements 
ActiveRolesProvider {
       LOGGER.error(
           "Expected an PersistedPolarisPrincipal, but got {}: {}",
           principal.getClass().getName(),
-          ExceptionUtils.getStackTrace(new ServiceFailureException("Invalid 
principal type")));
+          Throwables.getStackTraceAsString(new 
ServiceFailureException("Invalid principal type")));
       throw new NotAuthorizedException("Unable to authenticate");
     }
     List<PrincipalRoleEntity> activeRoles =
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultAuthenticator.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultAuthenticator.java
index 6808c2341..149ae1874 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultAuthenticator.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/auth/DefaultAuthenticator.java
@@ -18,12 +18,12 @@
  */
 package org.apache.polaris.service.auth;
 
+import com.google.common.base.Throwables;
 import io.smallrye.common.annotation.Identifier;
 import jakarta.enterprise.context.RequestScoped;
 import jakarta.inject.Inject;
 import java.util.HashSet;
 import java.util.Set;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.iceberg.exceptions.NotAuthorizedException;
 import org.apache.iceberg.exceptions.ServiceFailureException;
 import org.apache.polaris.core.auth.PolarisPrincipal;
@@ -81,7 +81,7 @@ public class DefaultAuthenticator implements Authenticator {
       LOGGER
           .atError()
           .addKeyValue("errMsg", e.getMessage())
-          .addKeyValue("stackTrace", ExceptionUtils.getStackTrace(e))
+          .addKeyValue("stackTrace", Throwables.getStackTraceAsString(e))
           .log("Unable to authenticate user with token");
       throw new ServiceFailureException("Unable to fetch principal entity");
     }
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/auth/JWTBroker.java 
b/runtime/service/src/main/java/org/apache/polaris/service/auth/JWTBroker.java
index c591ca123..559ba2bc5 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/auth/JWTBroker.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/auth/JWTBroker.java
@@ -28,7 +28,6 @@ import java.time.temporal.ChronoUnit;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
 import org.apache.iceberg.exceptions.NotAuthorizedException;
 import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.entity.PolarisEntityType;
@@ -108,7 +107,7 @@ public abstract class JWTBroker implements TokenBroker {
     if (!TokenType.ACCESS_TOKEN.equals(subjectTokenType)) {
       return new TokenResponse(OAuthTokenErrorResponse.Error.invalid_request);
     }
-    if (StringUtils.isBlank(subjectToken)) {
+    if (subjectToken == null || subjectToken.isBlank()) {
       return new TokenResponse(OAuthTokenErrorResponse.Error.invalid_request);
     }
     DecodedToken decodedToken;
@@ -188,6 +187,6 @@ public abstract class JWTBroker implements TokenBroker {
   }
 
   private String scopes(String scope) {
-    return StringUtils.isNotBlank(scope) ? scope : 
DefaultAuthenticator.PRINCIPAL_ROLE_ALL;
+    return scope == null || scope.isBlank() ? 
DefaultAuthenticator.PRINCIPAL_ROLE_ALL : scope;
   }
 }
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
index 4c0f7af2e..438cf9922 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
@@ -24,6 +24,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Joiner;
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
 import jakarta.annotation.Nonnull;
 import jakarta.annotation.Nullable;
@@ -47,7 +48,6 @@ import java.util.function.Function;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.iceberg.BaseTable;
 import org.apache.iceberg.CatalogProperties;
 import org.apache.iceberg.CatalogUtil;
@@ -165,7 +165,7 @@ public class IcebergCatalog extends BaseMetastoreViewCatalog
             && !(ex instanceof ForbiddenException)
             && !(ex instanceof UnprocessableEntityException)
             && (isStorageProviderRetryableException(ex)
-                || 
isStorageProviderRetryableException(ExceptionUtils.getRootCause(ex)));
+                || 
isStorageProviderRetryableException(Throwables.getRootCause(ex)));
       };
 
   private final StorageCredentialCache storageCredentialCache;
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/io/ExceptionMappingFileIO.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/io/ExceptionMappingFileIO.java
index 4ac718079..809ca446e 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/io/ExceptionMappingFileIO.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/io/ExceptionMappingFileIO.java
@@ -19,9 +19,9 @@
 package org.apache.polaris.service.catalog.io;
 
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
 import java.net.UnknownHostException;
 import java.util.Map;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.iceberg.io.FileIO;
 import org.apache.iceberg.io.InputFile;
 import org.apache.iceberg.io.OutputFile;
@@ -36,7 +36,7 @@ public class ExceptionMappingFileIO implements FileIO {
   }
 
   private void handleException(RuntimeException e) {
-    for (Throwable t : ExceptionUtils.getThrowables(e)) {
+    for (Throwable t : Throwables.getCausalChain(e)) {
       // UnknownHostException isn't a RuntimeException so it's always wrapped
       if (t instanceof UnknownHostException) {
         throw new FileIOUnknownHostException("UnknownHostException during File 
IO", t);
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
index fff99e1f2..6e2dec197 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/exception/IcebergExceptionMapper.java
@@ -23,6 +23,7 @@ import com.azure.core.exception.HttpResponseException;
 import com.google.cloud.BaseServiceException;
 import com.google.cloud.storage.StorageException;
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableSet;
 import jakarta.ws.rs.WebApplicationException;
 import jakarta.ws.rs.core.MediaType;
@@ -34,7 +35,6 @@ import java.util.Collection;
 import java.util.Locale;
 import java.util.Optional;
 import java.util.Set;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.iceberg.exceptions.AlreadyExistsException;
 import org.apache.iceberg.exceptions.CherrypickAncestorCommitException;
 import org.apache.iceberg.exceptions.CleanableFailure;
@@ -156,7 +156,7 @@ public class IcebergExceptionMapper implements 
ExceptionMapper<RuntimeException>
   }
 
   static int mapExceptionToResponseCode(RuntimeException rex) {
-    for (Throwable t : ExceptionUtils.getThrowables(rex)) {
+    for (Throwable t : Throwables.getCausalChain(rex)) {
       // Cloud exceptions can be wrapped by the Iceberg SDK
       Optional<Integer> code = mapCloudExceptionToResponseCode(t);
       if (code.isPresent()) {
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/task/TaskFileIOSupplier.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/task/TaskFileIOSupplier.java
index 44de36210..b21eaebf5 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/task/TaskFileIOSupplier.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/task/TaskFileIOSupplier.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import org.apache.commons.lang3.function.TriFunction;
 import org.apache.iceberg.CatalogProperties;
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.io.FileIO;
@@ -37,8 +36,7 @@ import org.apache.polaris.core.storage.PolarisStorageActions;
 import org.apache.polaris.service.catalog.io.FileIOFactory;
 
 @ApplicationScoped
-public class TaskFileIOSupplier
-    implements TriFunction<TaskEntity, TableIdentifier, CallContext, FileIO> {
+public class TaskFileIOSupplier {
   private final FileIOFactory fileIOFactory;
 
   @Inject
@@ -46,7 +44,6 @@ public class TaskFileIOSupplier
     this.fileIOFactory = fileIOFactory;
   }
 
-  @Override
   public FileIO apply(TaskEntity task, TableIdentifier identifier, CallContext 
callContext) {
     Map<String, String> internalProperties = task.getInternalPropertiesAsMap();
     Map<String, String> properties = new HashMap<>(internalProperties);
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapterTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapterTest.java
index f8f948a66..f5e6a81c3 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapterTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapterTest.java
@@ -19,6 +19,7 @@
 
 package org.apache.polaris.service.catalog.iceberg;
 
+import com.google.common.base.Strings;
 import java.io.IOException;
 import java.lang.reflect.Field;
 import java.util.List;
@@ -41,7 +42,6 @@ import 
org.apache.polaris.core.admin.model.IcebergRestConnectionConfigInfo;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
 import org.apache.polaris.service.TestServices;
 import org.assertj.core.api.Assertions;
-import org.assertj.core.util.Strings;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.Arguments;

Reply via email to