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 673e8f1700b0b1..47f5c9ec8fa6ec 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 @@ -212,13 +212,15 @@ private void updateTableRefInfos() throws AnalysisException { * analyzeProperties */ public void analyzeProperties() throws AnalysisException { + Map 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) { @@ -226,13 +228,11 @@ public void analyzeProperties() throws AnalysisException { } timeoutMs = timeoutMs * 1000; - properties.remove(PROP_TIMEOUT); + copiedProperties.remove(PROP_TIMEOUT); } else { timeoutMs = Config.backup_job_default_timeout_ms; } - Map 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 bc8a8f091e9080..4d2e982747a24a 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.nereids.trees.plans.commands.info.TableRefInfo; 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 void testValidateNormal() { 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 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()); + } }