theonedev/onedev · error · IllegalArgumentException
Flag {0} is disposed
Error message
Flag {0} is disposed What it means
RevWalk.carry(flag) registers a flag to be carried from child commits to parents. If the flag has already been disposed (its bit was returned to freeFlags via disposeFlag/dispose flag set), the walk refuses to use it and throws this IllegalArgumentException.
Source
Thrown at server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java:1446
MessageFormat.format(JGitText.get().flagsAlreadyCreated,
Integer.valueOf(32 - RESERVED_FLAGS)));
final int m = Integer.lowestOneBit(freeFlags);
freeFlags &= ~m;
return m;
}
/**
* Automatically carry a flag from a child commit to its parents.
* <p>
* A carried flag is copied from the child commit onto its parents when the
* child commit is popped from the lowest level of walk's internal graph.
*
* @param flag
* the flag to carry onto parents, if set on a descendant.
*/
public void carry(RevFlag flag) {
if ((freeFlags & flag.mask) != 0)
throw new IllegalArgumentException(MessageFormat
.format(JGitText.get().flagIsDisposed, flag.name));
if (flag.walker != this)
throw new IllegalArgumentException(MessageFormat
.format(JGitText.get().flagNotFromThis, flag.name));
carryFlags |= flag.mask;
}
/**
* Automatically carry flags from a child commit to its parents.
* <p>
* A carried flag is copied from the child commit onto its parents when the
* child commit is popped from the lowest level of walk's internal graph.
*
* @param set
* the flags to carry onto parents, if set on a descendant.
*/
public void carry(Collection<RevFlag> set) {
for (RevFlag flag : set)View on GitHub (pinned to d44925c47c)
Solutions
- Re-create the flag with revWalk.newFlag(name) and carry the new instance.
- Ensure disposeFlag is only called when the flag will never be used again on this walk.
- Reorder code so carry() happens before any disposal logic.
Example fix
// before
walk.disposeFlag(flag);
walk.carry(flag); // throws
// after
RevFlag flag = walk.newFlag("MINE");
walk.carry(flag);
// dispose only after traversal completes
// walk.disposeFlag(flag); Defensive patterns
Strategy: validation
Validate before calling
boolean isUsable(RevWalk w, RevFlag f) {
return f.walker == w; // a disposed flag's bit is back in w.freeFlags; recreate instead of reusing
} Type guard
RevFlag requireLiveFlag(RevWalk w, RevFlag f) {
if (f.walker != w) throw new IllegalStateException("flag not from this walk or disposed");
return f;
} Try / catch
try {
walk.carry(flag);
} catch (IllegalArgumentException e) {
flag = walk.newFlag(flag.getName());
walk.carry(flag);
} Prevention
- Only call disposeFlag when the flag is permanently finished
- Re-create flags instead of reusing references after disposal
- Order setup (newFlag -> carry) before any teardown logic
When it happens
Trigger: Calling carry(flag) after revWalk.disposeFlag(flag) (or disposeFlagSet) on the same flag; keeping a RevFlag reference past the disposal of its flag and re-registering it later; disposing flags at the end of one traversal then reusing the walk and flag objects in another.
Common situations: Code that disposes flags in a finally block but then calls carry in a later retry of the same walk; shared utility that disposes flags unconditionally after first use.
Understand the failure class
Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.
Related errors
- {0} flags already created
- Flag {0} not from this walk
- Ref name is required when commit hash is specified
- Either commit hash, branch or tag should be specified
- Unable to find commit to import build spec (import project:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/2839e441564d8e34.
Report an issue: GitHub.