From 4ee13c944d41f6656a5d7faa1308ac40771e0cb2 Mon Sep 17 00:00:00 2001 From: Pooja Nilangekar Date: Fri, 6 Jun 2025 16:58:59 -0700 Subject: [PATCH 1/2] Fix maxCode generation for ConnectionTypeEnum Previously, the `maxCode` was generated using `AuthenticationType.values()`. It worked fine because Polaris supported the same number of Connection and Authentication types. The enum conversion would break if we add new authenication or connection types independently as in #1805. --- .../org/apache/polaris/core/connection/ConnectionType.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java b/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java index 3c2d4430a9..f2e82ed899 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java @@ -40,8 +40,8 @@ public enum ConnectionType { static { // find max array size int maxCode = - Arrays.stream(AuthenticationType.values()) - .mapToInt(AuthenticationType::getCode) + Arrays.stream(ConnectionType.values()) + .mapToInt(ConnectionType::getCode) .max() .orElse(0); From cb6a6188930bb8c94b458b220f479108268f32d6 Mon Sep 17 00:00:00 2001 From: Pooja Nilangekar Date: Fri, 6 Jun 2025 19:02:59 -0700 Subject: [PATCH 2/2] Apply spotless format changes --- .../org/apache/polaris/core/connection/ConnectionType.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java b/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java index f2e82ed899..56796a95c4 100644 --- a/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java +++ b/polaris-core/src/main/java/org/apache/polaris/core/connection/ConnectionType.java @@ -40,10 +40,7 @@ public enum ConnectionType { static { // find max array size int maxCode = - Arrays.stream(ConnectionType.values()) - .mapToInt(ConnectionType::getCode) - .max() - .orElse(0); + Arrays.stream(ConnectionType.values()).mapToInt(ConnectionType::getCode).max().orElse(0); // allocate mapping array REVERSE_MAPPING_ARRAY = new ConnectionType[maxCode + 1];