Skip to content

Commit

Permalink
fix: command parsing and executing caused console dead lock (#1565)
Browse files Browse the repository at this point in the history
### Motivation
Executing a lot of commands while e.g. services are starting (printing
messages to the console) can lead to dead locks. This issue was probably
introduced with the cloud 2.0 migration. Prior to cloud 2.0 the
framework used to run suggestions on the caller thread. With cloud 2.0 a
shared thread pool for suggestion, parsing and executing can be used.
This then leads to dead locks.

### Modification
Explicitly set the thread pool for parsing & executing only. Suggestions
are processed on the caller thread (thus restoring cloud 1.0 behavior.

### Result
No dead-locks of the console.
  • Loading branch information
0utplay authored Dec 24, 2024
1 parent 9389d89 commit 790ec42
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<property name="ignorePattern" value="^package.*|^import.*|a href|http://|https://|ftp://|//.*"/>
</module>
<module name="TreeWalker">
<property name="skipFileOnJavaParseException" value="true"/>
<property name="javaParseExceptionSeverity" value="info"/>
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
<property name="onCommentFormat" value="CHECKSTYLE.ON"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ final class DefaultCommandManager extends CommandManager<CommandSource> {
* a thread pool with 4 threads.
*/
private DefaultCommandManager() {
var executor = Executors.newFixedThreadPool(4);
super(
ExecutionCoordinator.<CommandSource>builder().executor(Executors.newFixedThreadPool(4)).build(),
ExecutionCoordinator.<CommandSource>builder()
.parsingExecutor(executor)
.executionSchedulingExecutor(executor)
.build(),
CommandRegistrationHandler.nullCommandRegistrationHandler());
this.registerCapability(CloudCapability.StandardCapabilities.ROOT_COMMAND_DELETION);
}
Expand Down

0 comments on commit 790ec42

Please sign in to comment.