diff --git a/bindings/java/src/test/java/org/apache/opendal/test/behavior/BehaviorExtension.java b/bindings/java/src/test/java/org/apache/opendal/test/behavior/BehaviorExtension.java index 465fda7b208..c27fe583cfb 100644 --- a/bindings/java/src/test/java/org/apache/opendal/test/behavior/BehaviorExtension.java +++ b/bindings/java/src/test/java/org/apache/opendal/test/behavior/BehaviorExtension.java @@ -25,6 +25,7 @@ import java.io.StringWriter; import java.util.HashMap; import java.util.Map; +import java.util.UUID; import lombok.extern.slf4j.Slf4j; import org.apache.opendal.BlockingOperator; import org.apache.opendal.Operator; @@ -53,6 +54,13 @@ public void beforeAll(ExtensionContext context) { config.put(key.substring(prefix.length()), entry.getValue()); } } + + // Use random root unless OPENDAL_DISABLE_RANDOM_ROOT is set to true. + if (!Boolean.parseBoolean(dotenv.get("OPENDAL_DISABLE_RANDOM_ROOT"))) { + final String root = config.getOrDefault("root", "/") + UUID.randomUUID() + "/"; + config.put("root", root); + } + this.operator = Operator.of(scheme, config); this.blockingOperator = BlockingOperator.of(scheme, config);