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

JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 2859769448 [api] Make memory size serialization locale independent 
(#10597)
2859769448 is described below

commit 2859769448cabc81c129d94c1e456dfaec9df38c
Author: chenjian2664 <[email protected]>
AuthorDate: Fri Oct 16 13:07:09 2026 +0800

    [api] Make memory size serialization locale independent (#10597)
---
 .../java/org/apache/paimon/options/MemorySize.java |  4 +-
 .../org/apache/paimon/options/MemorySizeTest.java  | 49 ++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/paimon-api/src/main/java/org/apache/paimon/options/MemorySize.java 
b/paimon-api/src/main/java/org/apache/paimon/options/MemorySize.java
index 3f041776a8..439cd346ca 100644
--- a/paimon-api/src/main/java/org/apache/paimon/options/MemorySize.java
+++ b/paimon-api/src/main/java/org/apache/paimon/options/MemorySize.java
@@ -169,8 +169,10 @@ public class MemorySize implements java.io.Serializable, 
Comparable<MemorySize>
                         .orElse(BYTES);
 
         return String.format(
+                Locale.ROOT,
                 "%d %s",
-                bytes / highestIntegerUnit.getMultiplier(), 
highestIntegerUnit.getUnits()[1]);
+                bytes / highestIntegerUnit.getMultiplier(),
+                highestIntegerUnit.getUnits()[1]);
     }
 
     public String toHumanReadableString() {
diff --git 
a/paimon-api/src/test/java/org/apache/paimon/options/MemorySizeTest.java 
b/paimon-api/src/test/java/org/apache/paimon/options/MemorySizeTest.java
new file mode 100644
index 0000000000..0f4334f00c
--- /dev/null
+++ b/paimon-api/src/test/java/org/apache/paimon/options/MemorySizeTest.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.paimon.options;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+import java.util.Locale;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link MemorySize}. */
+class MemorySizeTest {
+
+    @ParameterizedTest
+    @ValueSource(strings = {"0 bytes", "123 bytes", "1 kb", "2 mb", "3 gb"})
+    void testLocaleIndependentRoundTrip(String value) {
+        Locale originalLocale = Locale.getDefault(Locale.Category.FORMAT);
+        try {
+            Locale.setDefault(Locale.Category.FORMAT, new Locale("ar", "EG"));
+            MemorySize size = MemorySize.parse(value);
+            assertThat(size.toString()).isEqualTo(value);
+
+            ConfigOption<MemorySize> option =
+                    
ConfigOptions.key("memory-size").memoryType().noDefaultValue();
+            Options options = new Options();
+            options.set(option, size);
+            assertThat(options.get(option)).isEqualTo(size);
+        } finally {
+            Locale.setDefault(Locale.Category.FORMAT, originalLocale);
+        }
+    }
+}

Reply via email to