Skip to content

Commit 43727e7

Browse files
committed
[Core] Keep processing commands if submit future completes exceptionally
1 parent 195b300 commit 43727e7

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

sensorhub-core/src/main/java/org/sensorhub/api/command/IStreamingControlInterface.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ public default DataEncoding getCommandEncoding()
107107
* are then sent via the dedicated event channel, using the same task ID,
108108
* to provide status updates to the caller.
109109
* </p><p>
110-
* The future should only complete exceptionally if there is an unexpected error.
111-
* All errors associated to the processing of the command by the receiver system
112-
* should be reported via a status object instead.
110+
* The future should only complete exceptionally if there is an unexpected error
111+
* or internal error that should not be reported to the caller. Otherwise, all
112+
* errors associated to the processing of the command by the receiver system
113+
* should be reported in the status object instead.
113114
* </p>
114115
* @param command Command data (with ID set)
115116
* @return A future that will be completed normally when the system is ready to

sensorhub-core/src/main/java/org/sensorhub/impl/system/SystemDriverTransactionHandler.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ protected void connectControlInput(IStreamingControlInterface controlInput, Comm
365365
{
366366
csHandler.connectCommandReceiver(new Subscriber<CommandEvent>() {
367367
Subscription sub;
368-
static final String ERROR_MESSAGE = "Error sending command to {}. Canceling command receiver subscription";
368+
static final String ERROR_MESSAGE = "Error dispatching command to {}. ";
369+
static final String DISPATCH_STOP_MESSAGE = "No more commands will be processed.";
369370

370371
@Override
371372
public void onSubscribe(Subscription sub)
@@ -388,14 +389,16 @@ public void onNext(CommandEvent event)
388389
})
389390
.exceptionally(e -> {
390391
DefaultSystemRegistry.log.error(ERROR_MESSAGE, csHandler.csInfo.getFullName(), e);
391-
sub.cancel();
392-
csHandler.sendStatus(event.getCorrelationID(), CommandStatus.failed(event.getCommand().getID(), "Internal error processing command"));
392+
csHandler.sendStatus(event.getCorrelationID(),
393+
CommandStatus.failed(event.getCommand().getID(), "Internal error processing command"));
394+
sub.request(1);
393395
return null; // return type is Void
394396
});
395397
}
396398
catch (Exception e)
397399
{
398-
DefaultSystemRegistry.log.error(ERROR_MESSAGE, csHandler.csInfo.getFullName(), e);
400+
DefaultSystemRegistry.log.error(ERROR_MESSAGE + DISPATCH_STOP_MESSAGE,
401+
csHandler.csInfo.getFullName(), e);
399402
sub.cancel();
400403
}
401404
});
@@ -404,8 +407,8 @@ public void onNext(CommandEvent event)
404407
@Override
405408
public void onError(Throwable e)
406409
{
407-
DefaultSystemRegistry.log.error("Error dispatching commands to {}. "
408-
+ "No more commands will be processed.", csHandler.csInfo.getFullName(), e);
410+
DefaultSystemRegistry.log.error(ERROR_MESSAGE + DISPATCH_STOP_MESSAGE,
411+
csHandler.csInfo.getFullName(), e);
409412
}
410413

411414
@Override

0 commit comments

Comments
 (0)