Skip to content

Commit

Permalink
fix AsyncOperation Status (#890)
Browse files Browse the repository at this point in the history
* fix error in executeOperation
* update Release Notes
---------

Co-authored-by: Michael Jacoby <michael.jacoby@iosb.fraunhofer.de>
  • Loading branch information
tbischoff2 and mjacoby committed Sep 30, 2024
1 parent bdaf224 commit 20ac5e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ protected InvokeOperationAsyncResponse executeOperation(Reference reference, Inv
OperationHandle operationHandle = new OperationHandle();
handleOperationInvoke(reference, operationHandle, request);

AtomicBoolean operationFinished = new AtomicBoolean(false);
AtomicBoolean timeoutOccured = new AtomicBoolean(false);
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
try {
Expand All @@ -174,17 +175,27 @@ protected InvokeOperationAsyncResponse executeOperation(Reference reference, Inv
request.getInoutputArguments().toArray(new OperationVariable[0]),
(output, inoutput) -> {
if (timeoutOccured.get()) {
LOGGER.debug("executeOperation: timeout already occurred - ignore success");
return;
}
operationFinished.set(true);
handleOperationSuccess(reference, operationHandle, inoutput, output);
},
error -> handleOperationFailure(reference, request.getInoutputArguments(), operationHandle, error));
error -> {
operationFinished.set(true);
handleOperationFailure(reference, request.getInoutputArguments(), operationHandle, error);
});
executor.schedule(() -> {
if (operationFinished.get()) {
LOGGER.debug("executeOperation: operation already finished - ignore timeout");
return;
}
timeoutOccured.set(true);
handleOperationTimeout(reference, request, operationHandle);
}, request.getTimeout().getTimeInMillis(Calendar.getInstance()), TimeUnit.MILLISECONDS);
}
catch (Exception e) {
operationFinished.set(true);
handleOperationFailure(reference, request.getInoutputArguments(), operationHandle, e);
}
finally {
Expand Down
1 change: 1 addition & 0 deletions docs/source/other/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
**Internal changes & bugfixes**
- General
- Model validation no longer throws an error if a model contains multiple instances of exactly the same Identifiable. This is not 100% correct behavior according to the specification as it validates the uniqueness criteria of their ID, however, it helps tremendously when working with existing SMTs as many of them are currently also not 100% standard-compliant and contain such duplicate elements.
- Fixed bug when executing an operation asynchronously. When the timeout has expired, the status of the operation was set to timeout, even if the operation already finished successfully. This does no longer happen - the timeout no longer overwrites the result of the operation.
- Endpoint
- HTTP
- Fixed query modifier `extent` which has not been working as intended
Expand Down

0 comments on commit 20ac5e6

Please sign in to comment.