This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.36k
stars
2k
forks
source link
Improve logic to avoid block call under non blocking thread #43063
Issues #12500, #35845 and #35215 appear to be due to EventHubsTemplate.doSend performing a block() call. When used by the non-async methods in EventHubsTemplate, or the async methods when a non-parallel Reactor Scheduler is being used, this will work well enough. But when using a parallel Reactor Scheduler, blocking calls are prohibited.
This PR restructures the code in EventHubsTemplate.doSend to not use a blocking call. A test was added first to verify that we could detect this condition by performing one of the existing test cases with Scheduler.parallel(). After the changes to EventHubsTemplate, this test passes.
And fix the same issue for DefaultMessageHandler.handleMessageInternal.
All SDK Contribution checklist:
[x] The pull request does not introduce [breaking changes]
[x] CHANGELOG is updated for new features, bug fixes or other significant changes.
[x] Title of the pull request is clear and informative.
[x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.
Description
Cherry-pick from https://github.com/Azure/azure-sdk-for-java/pull/40772
Issues #12500, #35845 and #35215 appear to be due to
EventHubsTemplate.doSend
performing ablock()
call. When used by the non-async methods inEventHubsTemplate
, or the async methods when a non-parallel ReactorScheduler
is being used, this will work well enough. But when using a parallel ReactorScheduler
, blocking calls are prohibited.This PR restructures the code in
EventHubsTemplate.doSend
to not use a blocking call. A test was added first to verify that we could detect this condition by performing one of the existing test cases withScheduler.parallel()
. After the changes toEventHubsTemplate
, this test passes.And fix the same issue for
DefaultMessageHandler.handleMessageInternal
.All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines