Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,27 @@ private void updateTableRefInfos() throws AnalysisException {
* 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) {
ErrorReport.reportAnalysisException(ErrorCode.ERR_COMMON_ERROR, "timeout must be at least 10 min");
}

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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<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());
}
}
Loading