You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by w4...@apache.org on 2026/04/03 02:18:12 UTC

(doris) branch master updated: [fix](backup) Fix UnsupportedOperationException in RestoreCommand by copying properties before modification (#61890)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e61837c24eb [fix](backup) Fix UnsupportedOperationException in RestoreCommand by copying properties before modification (#61890)
e61837c24eb is described below

commit e61837c24eb3aae0a54dc32197574de4d5ab8130
Author: walter <ma...@selectdb.com>
AuthorDate: Fri Apr 3 10:18:04 2026 +0800

    [fix](backup) Fix UnsupportedOperationException in RestoreCommand by copying properties before modification (#61890)
    
    The properties map could be an ImmutableMap, so calling remove() on it
    causes UnsupportedOperationException.
---
 .../nereids/trees/plans/commands/RestoreCommand.java     | 12 ++++++------
 .../nereids/trees/plans/commands/RestoreCommandTest.java | 16 ++++++++++++++++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommand.java
index 79c47f94d74..446ee604a8e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommand.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommand.java
@@ -211,13 +211,15 @@ public class RestoreCommand extends Command implements ForwardWithSync {
      * analyzeProperties
      */
     public void analyzeProperties() throws AnalysisException {
+        Map<String, String> copiedProperties = Maps.newHashMap(properties);
+
         // timeout
-        if (properties.containsKey("timeout")) {
+        if (copiedProperties.containsKey(PROP_TIMEOUT)) {
             try {
-                timeoutMs = Long.valueOf(properties.get(PROP_TIMEOUT));
+                timeoutMs = Long.valueOf(copiedProperties.get(PROP_TIMEOUT));
             } catch (NumberFormatException e) {
                 ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR,
-                        "Invalid timeout format: " + properties.get(PROP_TIMEOUT));
+                        "Invalid timeout format: " + copiedProperties.get(PROP_TIMEOUT));
             }
 
             if (timeoutMs * 1000 < MIN_TIMEOUT_MS) {
@@ -225,13 +227,11 @@ public class RestoreCommand extends Command implements ForwardWithSync {
             }
 
             timeoutMs = timeoutMs * 1000;
-            properties.remove(PROP_TIMEOUT);
+            copiedProperties.remove(PROP_TIMEOUT);
         } else {
             timeoutMs = Config.backup_job_default_timeout_ms;
         }
 
-        Map<String, String> copiedProperties = Maps.newHashMap(properties);
-
         // allow load
         allowLoad = eatBooleanProperty(copiedProperties, PROP_ALLOW_LOAD, allowLoad);
 
diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommandTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommandTest.java
index 55956eb0742..8d7212472ed 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommandTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/RestoreCommandTest.java
@@ -29,6 +29,7 @@ import org.apache.doris.mysql.privilege.PrivPredicate;
 import org.apache.doris.nereids.trees.plans.commands.info.LabelNameInfo;
 import org.apache.doris.qe.ConnectContext;
 
+import com.google.common.collect.ImmutableMap;
 import mockit.Expectations;
 import mockit.Mocked;
 import org.apache.commons.collections4.map.HashedMap;
@@ -136,4 +137,19 @@ public class RestoreCommandTest {
         RestoreCommand command5 = new RestoreCommand(labelNameInfo, repoName2, tableRefInfos, properties2, isExclude);
         Assertions.assertThrows(DdlException.class, () -> command5.validate(connectContext));
     }
+
+    @Test
+    public void testAnalyzePropertiesWithImmutableMap() {
+        LabelNameInfo labelNameInfo = new LabelNameInfo(dbName, "label0");
+        Map<String, String> properties = ImmutableMap.of(
+                "timeout", "86400",
+                "backup_timestamp", "2025-06-12-11-15-20");
+
+        RestoreCommand command = new RestoreCommand(labelNameInfo, "testRepo",
+                new ArrayList<>(), properties, false);
+
+        Assertions.assertDoesNotThrow(command::analyzeProperties);
+        Assertions.assertEquals(86400L * 1000, command.getTimeoutMs());
+        Assertions.assertEquals("2025-06-12-11-15-20", command.getBackupTimestamp());
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org