{"record":{"id":"e145fcc6ffea0e2a","repo":"juicedata/juicefs","slug":"random-backward-skip-are-mutually-exclusive","errorCode":null,"errorMessage":"random, backward, skip are mutually exclusive","messagePattern":"random, backward, skip are mutually exclusive","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java","lineNumber":244,"sourceCode":"    createControlFile(fs, sizeInBytes, maps);\n    if (compression != null) {\n      LOG.info(\"compressionClass = \" + compression);\n    }\n  }\n\n  private void checkArgs() {\n    if (!testType.equals(\"-read\")) {\n      if (random || backward || skip) {\n        throw new IllegalArgumentException(\"random, backward, skip are only valid under read\");\n      }\n    } else {\n      boolean[] conds = {random, backward, skip};\n      int trueCount = 0;\n      for (boolean cond : conds) {\n        if (cond) {\n          trueCount++;\n          if (trueCount > 1) {\n            throw new IllegalArgumentException(\"random, backward, skip are mutually exclusive\");\n          }\n        }\n      }\n    }\n  }\n\n  private void localRun(TestType testType) throws IOException {\n    IOStatMapper ioer;\n    switch (testType) {\n      case TEST_TYPE_READ:\n        ioer = new ReadMapper();\n        break;\n      case TEST_TYPE_WRITE:\n        ioer = new WriteMapper();\n        fs.delete(getDataDir(config), true);\n        break;\n      case TEST_TYPE_APPEND:\n        ioer = new AppendMapper();","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/bench/TestDFSIO.java#L226-L262","documentation":"checkArgs counts how many of -random, -backward and -skip are enabled for a -read run; more than one throws IllegalArgumentException \"random, backward, skip are mutually exclusive\". The three read modes cannot be combined in a single TestDFSIO run.","triggerScenarios":"Running TestDFSIO -read with two or three of -random, -backward, -skip at once, e.g. 'TestDFSIO -read -random -backward'.","commonSituations":"Merging flags from two example command lines; a loop in a script appending all read-mode flags; confusion between 'backward' and 'skip' semantics.","solutions":["Pick exactly one read mode per run: plain read, -random, -backward, or -skip.","Run multiple separate TestDFSIO invocations if you need results for several modes.","Add a pre-flight check in the benchmark script rejecting flag combinations."],"exampleFix":"// before\nTestDFSIO -read -random -backward -size 1GB\n// after\nTestDFSIO -read -random -size 1GB","handlingStrategy":"validation","validationCode":"long n = java.util.Arrays.stream(args).filter(a -> a.equals(\"-random\")||a.equals(\"-backward\")||a.equals(\"-skip\")).count();\nif (n > 1) throw new IllegalArgumentException(\"use only one of -random, -backward, -skip\");","typeGuard":null,"tryCatchPattern":"try {\n  runTestDFSIO(args);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"mutually exclusive\")) {\n    throw new IllegalArgumentException(\"pick exactly one read mode\", e);\n  }\n  throw e;\n}","preventionTips":["Run each read mode as a separate benchmark invocation.","Avoid copying flags across example command lines.","Enforce the single-mode rule in the benchmark wrapper script."],"tags":["java","cli","benchmark","argument-parsing"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}