Class RemoteCommandHandler
- All Implemented Interfaces:
CloudRequestHandler
command.execute through the shared acknowledgement and dedupe gate.
Order is fixed by D-16/D-17/S-52: the envelope id is recorded and persisted in the
DedupeLedger first, the request is acknowledged second, and only a first delivery is
handed to CommandExecutionManager for main-thread execution. A redelivered id is
acknowledged again and never executed again; a persistence failure is logged by
AckFirstGate and does not stop the acknowledgement or the first execution.
The capability switch is enforced by AgentMessageRouter before this handler runs;
CommandExecutionManager.execute(java.lang.String, java.lang.String, java.util.concurrent.Executor, com.ultikits.ultitools.manager.CommandExecutionManager.CommandResultSink) keeps its own defensive check. Truncation to the
negotiated commandOutputMaxBytes happens here because only the channel knows the limits
of the accepted welcome; the per-line and per-item schema caps are applied by the manager.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final classAn output array plus whether the byte cap forced lines to be dropped. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate final BooleanSupplierprivate static final com.google.gson.Gsonprivate final DedupeLedgerprivate static final Loggerprivate final Executorprivate final CommandExecutionManagerprivate static final intcommand.result.payload.detailsproperty values and keys maxLength. -
Constructor Summary
ConstructorsConstructorDescriptionRemoteCommandHandler(CommandExecutionManager manager, DedupeLedger ledger, Executor mainThread, BooleanSupplier disabling) -
Method Summary
Modifier and TypeMethodDescriptionprivate static Stringprivate static RemoteCommandHandler.BoundedOutputKeeps as many leading output lines as fit the negotiated cap on the serialized array's UTF-8 size, dropping trailing lines.voidhandle(CloudRequest request, CloudChannel channel) Validates the payload and handles it on the dispatching thread.private static voidinternalError(CloudRequest request, CloudChannel channel, RuntimeException failure) private voidrunUnlessDisabling(Runnable action, CloudRequest request, CloudChannel channel) Runs one step of the acknowledged request unless the plugin is disabling.
-
Field Details
-
LOGGER
-
COMMAND
-
MAX_DETAIL_CHARS
private static final int MAX_DETAIL_CHARScommand.result.payload.detailsproperty values and keys maxLength.- See Also:
-
GSON
private static final com.google.gson.Gson GSON -
manager
-
ledger
-
mainThread
-
disabling
-
-
Constructor Details
-
RemoteCommandHandler
RemoteCommandHandler(CommandExecutionManager manager, DedupeLedger ledger, Executor mainThread, BooleanSupplier disabling)
-
-
Method Details
-
handle
Description copied from interface:CloudRequestHandlerValidates the payload and handles it on the dispatching thread. No Bukkit main-thread scheduling is implied; handlers must schedule such work themselves. Synchronous payload validation failures become correlated invalid_message replies; other runtime failures become internal_error without exposing exception text. Asynchronous failures are the handler's responsibility.- Specified by:
handlein interfaceCloudRequestHandler- Parameters:
request- the parsed envelope with a defensively copied payloadchannel- the reply channel, which may close during processing
-
fitOutput
Keeps as many leading output lines as fit the negotiated cap on the serialized array's UTF-8 size, dropping trailing lines. The cap bounds the array itself, not the whole frame. -
cut
-
runUnlessDisabling
Runs one step of the acknowledged request unless the plugin is disabling. The check is applied twice — once after the acknowledgement, and once on the main thread, for the window between validation and the dispatch itself (D-16's disabling clause). A command the check stops is answered with a failedcommand.result(internal_error, the server is shutting down; maintainer decision of 2026-10-26), never left acknowledged without a result. A command that arrives once disabling started never gets here: the router'sShutdownGateanswers it the same way. -
internalError
private static void internalError(CloudRequest request, CloudChannel channel, RuntimeException failure)
-