Unhandled exception from runOnce
command called from a Trigger if it creates further Triggers.
#7734
Labels
type: bug
Something isn't working.
Describe the bug
A clear and concise description of what the bug is.
arising from this code:
when
m_testerController
is connected causingbindButtons()
to be run.Expected behavior
The
bindButtons
method binds the buttons without incurring an exception.Desktop (please complete the following information):
Project Version: 2025.2.1
VS Code Version: 1.94.2
WPILib Extension Version: 2025.2.1
C++ Extension Version: 1.23.2
Java Extension Version: 1.38.0
Java Debug Extension Version: 0.58.2024090204
Java Dependencies Extension Version 0.24.1
Java Version: 17
Java Location: /home/hauser/wpilib/2025/jdk
Vendor Libraries:
PathplannerLib (2025.2.1)
CTRE-Phoenix (v5) (5.35.1)
CTRE-Phoenix (v6) (25.2.1)
REVLib (2025.0.2)
ReduxLib (2025.0.1)
Studica (2025.0.1)
ThriftyLib (2025.0.1)
WPILib-New-Commands (1.0.0)
maplesim (0.3.1)
photonlib (v2025.1.1)
YAGSL (2025.2.2)
Additional context
For a couple of seasons I've had this as
var bindCommand = Commands.run(this::bindButtons)
. It has worked fine, but this year I noticed that the command was left running after doing its job -- it should have beenrunOnce
. But on changing it torunOnce
it suffered theConcurrentModificationException
as shown above.I think that the problem is that when a Command is scheduled from a Trigger, the Command's
start
method is called from the Trigger processing loop; andCommands.runOnce
places the method to be run as thestart
method of the Command that it constructs. Usingvar bindCommand(Commands.run(this::bindButtons).until(true));
instead, the error does not happen becausethis::bindButtons
is placed as theexecute
method of the constructed command where it is called from the Scheduler loop.I'm not sure this needs to be fixed -- at this level of the system small changes may well affect other edge-case behaviors. But at least it is now noted and a work-around provided.
The text was updated successfully, but these errors were encountered: