hono icon indicating copy to clipboard operation
hono copied to clipboard

Usage of Future onSuccess/onFailure/onComplete with regards to expected invocation order

Open calohmn opened this issue 3 years ago • 0 comments

Quote from https://vertx.io/docs/vertx-core/java/#_future_results:

Terminal operations like onSuccess, onFailure and onComplete provide no guarantee whatsoever regarding the invocation order of callbacks. Consider a future on which 2 callbacks are registered:

future.onComplete(ar -> {
  // Do something
});
future.onComplete(ar -> {
  // May be invoked first
});

It is possible that the second callback is invoked before the first one.

(more info)

Places in Hono code using these methods and requiring a certain invocation order need to be adapted.

Example of affected code in TenantServiceBasedX509Authentication:

                .onSuccess(authInfo -> span.log("certificate validated successfully"))
                .onFailure(t -> {
                    log.debug("validation of client certificate failed", t);
                    TracingHelper.logError(span, t);
                })
                .onComplete(ar -> span.finish());

calohmn avatar Aug 10 '22 05:08 calohmn