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 8d40a33c9 Optimize configuration value casts (#3688) (#3805)
8d40a33c9 is described below

commit 8d40a33c926900b3d38522cf2eae949529b7f2c3
Author: AryanPatel226 <[email protected]>
AuthorDate: Wed Feb 25 01:20:10 2026 +0530

    Optimize configuration value casts (#3688) (#3805)
---
 .../polaris/core/config/PolarisConfiguration.java     | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/config/PolarisConfiguration.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/config/PolarisConfiguration.java
index 7b7090687..22c774ff1 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/config/PolarisConfiguration.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/config/PolarisConfiguration.java
@@ -177,17 +177,24 @@ public abstract class PolarisConfiguration<T> {
       return defaultValue();
     }
 
-    if (defaultValue() instanceof Boolean) {
+    Object defaultValue = defaultValue();
+
+    // If value is already the same type as the default, no conversion needed
+    if (defaultValue.getClass().isInstance(value)) {
+      return cast(value);
+    }
+
+    if (defaultValue instanceof Boolean) {
       return cast(Boolean.valueOf(String.valueOf(value)));
-    } else if (defaultValue() instanceof Integer) {
+    } else if (defaultValue instanceof Integer) {
       return cast(Integer.valueOf(String.valueOf(value)));
-    } else if (defaultValue() instanceof Long) {
+    } else if (defaultValue instanceof Long) {
       return cast(Long.valueOf(String.valueOf(value)));
-    } else if (defaultValue() instanceof Double) {
+    } else if (defaultValue instanceof Double) {
       return cast(Double.valueOf(String.valueOf(value)));
-    } else if (defaultValue() instanceof Float) {
+    } else if (defaultValue instanceof Float) {
       return cast(Float.valueOf(String.valueOf(value)));
-    } else if (defaultValue() instanceof List<?>) {
+    } else if (defaultValue instanceof List<?>) {
       return cast(new ArrayList<>((List<?>) value));
     } else {
       return cast(value);

Reply via email to