-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Current Behavior
Fcli was originally designed as a single-threaded CLI application, but with the recent additions of MCP server and upcoming JSON-RPC server capabilities, some code will need to be updated to avoid race conditions and global state persisting between separate in-process command invocations.
At the time of writing, the following potential hazards exist:
- A thread-unsafe
HashMapcache inActionSpelFunctions - A static
ObjectNodeshared across all action runs inActionRunnerVars - Unsynchronised concurrent
parseArgs()on the shared rootCommandLine - Unsynchronised concurrent writes into
LogMaskHelper - The
System.out/System.errsnapshot-swap-restore race inOutputHelper/NonClosingOutHandler
Note that some other static/shared state exists in fcli, but currently this is only initialized when fcli starts up, not during individual requests through MCP/RPC calls:
FortifyCLIDynamicInitializer— only called once per process at startup (DefaultFortifyCLIRunner.run()), never byFcliCommandExecutor.envPrefix,DebugHelper.debugEnabled,LogMaskHelper.logMaskLevelare set once at startup.FortifyCLIDefaultValueProvider.envPrefix— not registered on the executionCommandLinecreated byFcliCommandExecutor; only on the startupCommandLine.StdIoMaskHelper.INSTANCE—install()/uninstall()called only at process startup; methods aresynchronized; no per-command hazard at the method level.FoDRetryStrategyThreadLocal — correctness neutral; instance-scoped anyway (may want to clean up ThreadLocal after use to avoid minor memory leak).
Expected Behavior
All code in fcli should be thread-safe and store per-execution state instead of global state where applicable.
Steps To Reproduce
No response
Environment
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working