Skip to content
Open
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 @@ -116,6 +116,8 @@ public Command getAlternative(final String label) {
}

// return the first command that is not an alias
Command firstAlias = null;

final Iterator<WeakReference<Command>> iterator = commands.iterator();
while (iterator.hasNext()) {
final Command cmd = iterator.next().get();
Expand All @@ -127,10 +129,14 @@ public Command getAlternative(final String label) {
if (cmd.getName().equalsIgnoreCase(label)) {
return cmd;
}

if (firstAlias == null) {
firstAlias = cmd;
}
}

// return the first alias
return commands.get(0).get();
// return the first alias, or null if every reference in this bucket has been collected
return firstAlias;
}

public void executed(final String label, final Command pc) {
Expand Down