Skip to content

Coding best practices: async vs await improvements #2156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
123c6e8
chore: Ocelot.Configuration.Creator.IHttpHandlerOptionsCreator => Upd…
henriqueholtz Sep 28, 2024
07c024c
chore: Getting rid of ".Result" (using "GetAwaiter().GetResult()" ins…
henriqueholtz Sep 28, 2024
cc37929
test: Getting rid of ".Result" (using "GetAwaiter().GetResult()" inst…
henriqueholtz Sep 28, 2024
d5bc104
chore: Benchmarks => Turning "await app.UseOcelot()" instead of of "a…
henriqueholtz Sep 28, 2024
9b9ec8c
test: Turning "await app.UseOcelot()" instead of of "app.UseOcelot().…
henriqueholtz Sep 28, 2024
fae4354
test: Ocelot.IntegrationTests.AdministrationTests => Turning methods …
henriqueholtz Oct 1, 2024
877814c
perf: Ocelot.UnitTests => Getting rid of "GetAwaiter().GetResult" and…
henriqueholtz Oct 1, 2024
4c06622
test: Ocelot.AcceptanceTests => turning methods as async as possible
henriqueholtz Oct 2, 2024
f095153
test: Fixing the test "should_return_response_200_with_simple_url_whe…
henriqueholtz Oct 2, 2024
2031123
test: Fixing tests from "ConsulConfigurationInConsulTests" + async/aw…
henriqueholtz Oct 2, 2024
551d1b7
test: Fixing some tests after merging
henriqueholtz Oct 5, 2024
ebd5dcb
test: Ocelot.AcceptanceTests => Using asyn/await instead of ".GetAwai…
henriqueholtz Oct 9, 2024
d82f37a
test: Returning the task directly instead of awaiting for it when it'…
henriqueholtz Oct 9, 2024
e708509
test: Undo moving the function "Steps.ThenTheStatusCodeShouldBe(HttpS…
henriqueholtz Oct 9, 2024
4f1ddd1
test: Removing with no usage function "Steps.GivenOcelotIsRunningWith…
henriqueholtz Oct 10, 2024
59bd034
test: Creating method "UntilAsync" and using it to get rid some ".Get…
henriqueholtz Oct 10, 2024
2abdbbf
chore: Reverting renaming (removing the suffix "Async")
henriqueholtz Oct 11, 2024
11c1459
chore: (2th) Reverting renaming (removing the suffix "Async")
henriqueholtz Oct 11, 2024
9bd1214
test: Bringing back the slash I removed with no reason
henriqueholtz Oct 11, 2024
59c3551
chore: Trying to revert fake changes of "test/Ocelot.AcceptanceTests/…
henriqueholtz Oct 12, 2024
63fc393
chore: Undone fake changes
henriqueholtz Oct 12, 2024
61d5436
chore: Undone useless renamed methods
henriqueholtz Oct 12, 2024
056831f
chore: removing unecessary "await task" and just returning it
henriqueholtz Oct 12, 2024
9a6eab8
chore: Undone fake changes "AggregateTests"
henriqueholtz Oct 12, 2024
1cc02f1
chore: FileConfigurationFluentValidatorTests => Undo rename method "W…
henriqueholtz Oct 12, 2024
cb21556
chore: test/Ocelot.AcceptanceTests/AggregateTests => reverting fake c…
henriqueholtz Oct 12, 2024
8343c38
chore: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCa…
henriqueholtz Oct 13, 2024
687a250
test: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCac…
henriqueholtz Oct 13, 2024
9629a94
perf: src/Ocelot.Provider.Consul/Consul => Using async/await instead …
henriqueholtz Oct 13, 2024
b6c3d82
chore: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCa…
henriqueholtz Oct 13, 2024
a38f733
Revert "chore: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewa…
henriqueholtz Oct 13, 2024
0c1b38b
Revert "test: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewar…
henriqueholtz Oct 13, 2024
6896aaf
test: test/Ocelot.UnitTests/CacheManager/OutputCacheMiddlewareRealCac…
henriqueholtz Oct 13, 2024
a9659ed
perf: ConsulFileConfigurationPollerOption.GetDelay => Removing useles…
henriqueholtz Oct 13, 2024
480ba72
chore: Ocelot.UnitTests.Configuration.FileConfigurationSetterTests =>…
henriqueholtz Oct 15, 2024
3655677
Revert "chore: Ocelot.UnitTests.Configuration.FileConfigurationSetter…
henriqueholtz Oct 15, 2024
b11b8ee
Fix build errors
raman-m Oct 16, 2024
a851098
EOL: test/Ocelot.AcceptanceTests/AggregateTests.cs
raman-m Oct 16, 2024
5ea8c89
code review by @raman-m
raman-m Oct 16, 2024
efd5a31
EOL: test/Ocelot.AcceptanceTests/Steps.cs
raman-m Oct 16, 2024
16e495f
Fix build
raman-m Oct 16, 2024
8061814
EOL: test/Ocelot.IntegrationTests/CacheManagerTests.cs
raman-m Oct 16, 2024
5c03c96
EOL: test/Ocelot.IntegrationTests/HeaderTests.cs
raman-m Oct 16, 2024
943d9bb
EOL: test/Ocelot.UnitTests/Configuration/Validation/FileConfiguration…
raman-m Oct 16, 2024
93331c7
EOL: test/Ocelot.UnitTests/Requester/HttpRequesterMiddlewareTests.cs
raman-m Oct 16, 2024
cc4a920
EOL: test/Ocelot.UnitTests/Security/SecurityMiddlewareTests.cs
raman-m Oct 16, 2024
8b10792
Revert the code to read `ValueTask.Result` if completed.
raman-m Oct 16, 2024
6ff1011
Sync call of the async method inside of sync context.
raman-m Oct 16, 2024
5376507
Add docs for Dev Best Practices
raman-m Oct 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions docs/building/devprocess.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Development Process
===================

* The development process works best with `Gitflow <https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow>`_ branching.
Note, Ocelot team doesn't use `GitHub flow <https://docs.github.com/en/get-started/using-github/github-flow>`_ which is faster but not efficient in Ocelot delivery.
* Contributors can do whatever they want on pull requests and feature branches to deliver a feature to **develop** branch.
* Maintainers can do whatever they want on pull requests and merges to **main** will result in packages being released to GitHub and NuGet.
* Finally, users follow :doc:`../building/devprocess`, but maintainers follow this :doc:`../building/releaseprocess`.

Ocelot uses the following process to accept work into a merged commit in develop.


1. User creates an issue or picks up an `existing issue <https://github.com/ThreeMammals/Ocelot/issues>`_ in GitHub.
An issue can be created by converting `discussion <https://github.com/ThreeMammals/Ocelot/discussions>`_ topics if necessary and agreed upon.

2. User creates `a fork <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_ and branches from this
(unless a member of core team, they can just create a branch on the head repo) e.g. ``feature/xxx``, ``bug/xxx`` etc.
It doesn't really matter what the "xxx" is. It might make sense to use the issue number and maybe a short description.

3. When the contributor is happy with their work they can create a pull request against **develop** in GitHub with their changes.

4. The Ocelot team will provide code review the PR and if all is good merge it, else they will suggest feedback that the user will need to act on.
In order to speed up getting a PR the contributor should think about the following:

- Have I covered all my changes with tests at unit and acceptance level?
- Have I updated any documentation that my changes may have affected?
- Does my feature make sense, have I checked all of Ocelot's other features to make sure it doesn't already exist?

In order for a PR to be merged the following must have occured:

- All new code is covered by unit tests.
- All new code has at least 1 acceptance test covering the happy path.
- Tests must have passed locally.
- Build must have green status.
- Build must not have slowed down dramatically.
- The main Ocelot package must not have taken on any non MS dependencies.

6. After the PR is merged to **develop** the Ocelot NuGet packages will not be updated until a release is created!
The final step is to go back to GitHub and close any issues that are now fixed.
**Note**: All linked issues to the PR in **Development** settings (right side PR settings) will be closed automatically while merging the PR.
It is imperative that developer uses the "**Link an issue from this repository**" pop-up dialog of the **Development** settings!

Notes
-----

All PR builds are done with CircleCI, see `Pipelines - ThreeMammals/Ocelot <https://circleci.com/gh/ThreeMammals/Ocelot/>`_.
It is advisable to watch for build status, and if it is failed, trigger new build or ask online maintainers or code reviewers to make sure the current PR build is green.

If anything is unclear or you get stuck in the process, please contact the `Ocelot Core Team <https://github.com/orgs/ThreeMammals/teams/ocelot-core>`_ members or repository maintainers.

.. _dev-best-practices:

Best Practices
--------------

* Ask for code review after Dev Complete stage, and resolve all issues in a provided feedback. Code is complete when solid code, appropriate unit and acceptance tests and docs update are written.
* Organize your development environment in Windows OS utilizing Visual Studio IDE. You can develop in Linux with other IDEs, but we don't recommend that. See more details in :ref:`dev-fun` subsection.
* Ensure you are always online after creation of the PR/issue, so maintainers will contact you as fastest as they can.
Note, if you will be offline for a days, weeks, months, then maintainers have a right to put your work in low priority.
Your intention to contribute should be high which means to be always online and proactive.

.. _dev-fun:

Dev Fun
--------

This is a part of :ref:`dev-best-practices` but it is more funny D)

Line-ending gotchas aka EOL fun
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This issue has persisted since the project's inception in 2016!
Indeed, some lines end with the LF-character from the Linux OS.
Several of our contributors work on Linux and use IDEs like Visual Code, where the default newline character is LF.
Consequently, we have numerous files with inconsistent/mixed EOL characters.

This problem is related to well-known End-of-Line characters dillema in cross-OS development.
For Windows OS the EOL char is ``CRLF`` but for Linux it is ``LF``.
Modern IDEs and Git repos detect inconsistancy of mixed EOLs in source files following own strategies.
But GitHub "Files Changed" tool unfortunately detects a line change in these 2 scenarios: ``CRLF`` to ``LF`` and ``LF`` to ``CRLF`` changes, even there was no actual code change!
Such a pull requests with fictitious ("fake") changes are always hard to review because the focus of the reviwer should be paid to actual code changes.

Please note, if the pull request is full of "fake" changes in **Files Changed** then code reviewer has a right not providing a code review marking PR as draft, or even closing it!

It's our common practice not to alter end-of-line characters.
Additionally, we employ Visual Studio's specific `.editorconfig <https://github.com/ThreeMammals/Ocelot/blob/develop/.editorconfig>`_ IDE analyzer settings for EOL to circumvent these line ending issues.
These settings are exclusive to Visual Studio, which is why we advise rebasing a feature branch onto develop solely using Visual Studio.

Special EOL settings can be provided in ``.gitattributes`` file of the git repository. But we don't handle this currently.

Our current recommendations for addressing the EOL issue are:

* It's preferable to resolve merge conflicts while honoring the changes in the develop branch.
It appears that changes are being collected from the feature branch, even when there are no substantial changes.
However, conflicts should be resolved by applying your changes onto the develop branch using a merging tool.

* If changes from the feature branch are prioritized (despite being insignificant), the merge tool will record them and apply CRLF end-of-line characters based on the rules specified in ``.editorconfig``.
This is where the issue arises.

* When you rename a method in IDE, for instance in Visual Studio, or use another auto-refactoring command, Visual Studio applies the command using the default styling rules in ``.editorconfig``,
which includes `CRLF settings <https://github.com/search?q=repo%3AThreeMammals%2FOcelot%20end_of_line&type=code>`_.
Therefore, applying auto-refactoring commands implicitly changes the EOL characters! This is the source of "fake" changes in PRs.
Please note, Visual Studio analyzers (IDE, StyleCop, etc.) recommends auto-refactoring too which could be applied implicitly.
To maintain the original EOL characters, you must edit the code manually!
So, fictitious ("fake") changes are the result of auto-refactoring commands in IDEs such as Visual Studio, Visual Code, Rider, and others.

* **Our final recommendations: Boot into Windows, use Visual Studio Community (it's free), avoid using auto-refactoring commands, and EOLs should remain unchanged.**
61 changes: 26 additions & 35 deletions docs/building/releaseprocess.rst
Original file line number Diff line number Diff line change
@@ -1,60 +1,51 @@
Release Process
===============

* The release process works best with `Gitflow <https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow>`_ branching.
* Contributors can do whatever they want on PRs and feature branches to deliver a feature to **develop** branch.
* Maintainers can do whatever they want on PRs and merges to **main** will result in packages being released to GitHub and NuGet.
* The release process works best with `Gitflow <https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow>`_ branching.
Note, Ocelot team doesn't use `GitHub flow <https://docs.github.com/en/get-started/using-github/github-flow>`_ which is faster but not efficient in Ocelot delivery.
* Contributors can do whatever they want on pull requests and feature branches to deliver a feature to **develop** branch.
* Maintainers can do whatever they want on pull requests and merges to **main** will result in packages being released to GitHub and NuGet.
* Finally, users follow :doc:`../building/devprocess`, but maintainers follow this :doc:`../building/releaseprocess`.

Ocelot uses the following process to accept work into the NuGet packages.

1. User creates an issue or picks up an `existing issue <https://github.com/ThreeMammals/Ocelot/issues>`_ in GitHub.
An issue can be created by converting `discussion <https://github.com/ThreeMammals/Ocelot/discussions>`_ topics if necessary and agreed upon.
1. Maintainers provide code review of pull request and if all is good merge it, else they will suggest feedback that the user will need to act on.
Extra help to contributors is welcomed via constant Pair Programming sessions: multiple code reviews, fixing code review issues, any problem solving.

2. User creates `a fork <https://docs.github.com/en/get-started/quickstart/fork-a-repo>`_ and branches from this (unless a member of core team, they can just create a branch on the head repo) e.g. ``feature/xxx``, ``bug/xxx`` etc.
It doesn't really matter what the "xxx" is. It might make sense to use the issue number and maybe a short description.

3. When the contributor is happy with their work they can create a pull request against **develop** in GitHub with their changes.

4. The maintainer must follow the `SemVer <https://semver.org/>`_ support for this is provided by `GitVersion <https://gitversion.net/docs/>`_.
2. The maintainer must follow the `SemVer <https://semver.org/>`_ support for this is provided by `GitVersion <https://gitversion.net/docs/>`_.
So if the maintainer needs to make breaking changes, be sure to use the correct commit message, so **GitVersion** uses the correct **SemVer** tags.
Do not manually tag the Ocelot repo: this will break things!

5. The Ocelot team will review the PR and if all is good merge it, else they will suggest feedback that the user will need to act on.

In order to speed up getting a PR the contributor should think about the following:

- Have I covered all my changes with tests at unit and acceptance level?
- Have I updated any documentation that my changes may have affected?
- Does my feature make sense, have I checked all of Ocelot's other features to make sure it doesn't already exist?
3. After the PR is merged to **develop** the Ocelot NuGet packages will not be updated until a release is created.
And, when enough work has been completed to justify a new release, **develop** branch will be merged into **main** as ``release/X.Y.Z`` branch,
the release process will begin which builds the code, versions it, pushes artifacts to GitHub and NuGet packages to NuGet.

In order for a PR to be merged the following must have occured:
4. Release engineer, the owner of integration tokens both on CircleCi and GitHub, automates each release build by the main building script aka ``build.cake``.
Release engineer is responsible for any DevOps at the organization, in any (sub)repositories, supporting the main building script.

- All new code is covered by unit tests.
- All new code has at least 1 acceptance test covering the happy path.
- Tests must have passed locally.
- Build must have green status.
- Build must not have slowed down dramatically.
- The main Ocelot package must not have taken on any non MS dependencies.
5. Release engineer writes `ReleaseNotes.md <https://github.com/ThreeMammals/Ocelot/blob/main/README.md>`_ notifying community about
important artifacts of the release such as new/updated features, fixed bugs, updated documentation, breaking changes, contributors info, version upgrade instructions, etc.

6. After the PR is merged to **develop** the Ocelot NuGet packages will not be updated until a release is created.
6. The final step is to go back to GitHub and close current milestone ensuring the following:

7. When enough work has been completed to justify a new release,
**develop** branch will be merged into **main** as **release/xxx** branch, the release process will begin which builds the code, versions it, pushes artifacts to GitHub and NuGet packages to NuGet.
* all issues in the milestone should be closed, the rest of work of open issues should be moved to the next milestone.
* all pull requests of the milestone should be closed, or moved to the next upcoming release milestone.
* Release Notes should be published to GitHub releases, with extra checking the text.
* Published release must be marked as the latest, if appropriate Nuget packages were successfully uploaded to `NuGet Gallery | ThreeMammals <https://www.nuget.org/profiles/ThreeMammals>`_ account.

8. The final step is to go back to GitHub and close any issues that are now fixed.
**Note**: All linked issues to the PR in **Development** settings (right side PR settings) will be closed automatically while merging the PR.
It is imperative that developer uses the "**Link an issue from this repository**" pop-up dialog of the **Development** settings!
7. Optional support of the major version ``2X.Y.0`` should be provided in such cases as Microsoft official patches, critical Ocelot defects of the major version.
Maintainers release patched versions ``2X.Y.xxx`` as hot-fixing patch-versions.

Notes
-----

All NuGet package builds and releases are done with CircleCI, see `Pipelines - ThreeMammals/Ocelot <https://circleci.com/gh/ThreeMammals/Ocelot/>`_.

Only Tom Pallister (owner) and Ocelot Core Team members (maintainers) can merge releases into **main** at the moment.
This is to ensure there is a final `quality gate <#quality-gates>`_ in place. Tom is mainly looking for security issues on the final merge.
Only `Tom Pallister <https://github.com/TomPallister>`_, `Raman Maksimchuk <https://github.com/raman-m>`_ (owners) and maintainers from `Ocelot Team <https://github.com/orgs/ThreeMammals/teams>`_ can merge releases into `main <https://github.com/ThreeMammals/Ocelot/tree/main>`_ at the moment.
This is to ensure there is a final :ref:`quality-gates` in place.
Maintainers are mainly looking for security issues on the final merge: see Step 7 in the process.

We **do** follow this development and release process!
If anything is unclear or you get stuck in the process, please contact the `Ocelot Core Team <https://github.com/orgs/ThreeMammals/teams/ocelot-core>`_ members or repository maintainers.
.. _quality-gates:

Quality Gates
-------------
Expand Down
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ All **Features** are listed in alphabetical order.
The primary features include :doc:`../features/configuration` and :doc:`../features/routing`.

Additional tips for building Ocelot can be found in the **Building Ocelot** section.
We adhere to a development process outlined in :doc:`../building/releaseprocess`.
We adhere to a :doc:`../building/devprocess` outlined in :doc:`../building/releaseprocess`.

.. admonition:: Table of Contents

Expand Down Expand Up @@ -76,5 +76,6 @@ We adhere to a development process outlined in :doc:`../building/releaseprocess`
building/overview
building/building
building/tests
building/devprocess
building/releaseprocess

6 changes: 5 additions & 1 deletion docs/releasenotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ Contributing

For `ideas <https://github.com/ThreeMammals/Ocelot/discussions/categories/ideas>`_ and `questions <https://github.com/ThreeMammals/Ocelot/discussions/categories/q-a>`_, please post them in the `Ocelot Discussions <https://github.com/ThreeMammals/Ocelot/discussions>`_ space.

Our development process is detailed in the :doc:`../building/releaseprocess` documentation.
Our :doc:`../building/devprocess` is a part of successful :doc:`../building/releaseprocess`.
If you are a new contributor, it is crucial to read :doc:`../building/devprocess` attentively to grasp our methods for efficient and swift feature delivery.
We, as a team, advocate adhering to :ref:`dev-best-practices` throughout the development phase.

We extend our best wishes for your successful contributions to the Ocelot product!
5 changes: 2 additions & 3 deletions src/Ocelot.Provider.Consul/Consul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public virtual async Task<List<Service>> GetAsync()
var nodesTask = _consul.Catalog.Nodes();

await Task.WhenAll(entriesTask, nodesTask);

var entries = entriesTask.Result.Response ?? Array.Empty<ServiceEntry>();
var nodes = nodesTask.Result.Response ?? Array.Empty<Node>();
var entries = (await entriesTask).Response ?? Array.Empty<ServiceEntry>();
var nodes = (await nodesTask).Response ?? Array.Empty<Node>();
if (entries.Length == 0)
{
_logger.LogWarning(() => $"{nameof(Consul)} Provider: No service entries found for '{_configuration.KeyOfServiceInConsul}' service!");
Expand Down
2 changes: 1 addition & 1 deletion src/Ocelot.Provider.Consul/PollConsul.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Task<List<Service>> GetAsync()
try
{
_logger.LogInformation(() => $"Retrieving new client information for service: {ServiceName}...");
_services = _consulServiceDiscoveryProvider.GetAsync().Result;
_services = _consulServiceDiscoveryProvider.GetAsync().GetAwaiter().GetResult();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are within a lock statement, we must adhere to writing only synchronous code. I agree with the change, however...
@ggnaegi, what would occur if we eliminate the lock? Due to the need for precise time capturing, we must prevent other threads from executing because the method modifies the class member _lastUpdateTime on line 59. It appears it's not feasible to convert this method into truly asynchronous, correct?

Copy link
Member

@raman-m raman-m Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an issue!.. We will tackle the issue of lock statements versus synchronous task calls in the future.

return Task.FromResult(_services);
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace Ocelot.Configuration.Creator
/// </summary>
public interface IHttpHandlerOptionsCreator
{
HttpHandlerOptions Create(FileHttpHandlerOptions fileRoute);
HttpHandlerOptions Create(FileHttpHandlerOptions options);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ private int GetDelay()
{
var delay = 1000;

var fileConfig = Task.Run(async () => await _fileConfigurationRepository.Get()).Result;
var fileConfig = _fileConfigurationRepository.Get().GetAwaiter().GetResult(); // sync call, so TODO extend IFileConfigurationPollerOptions interface with 2nd async method
if (fileConfig?.Data?.GlobalConfiguration?.ServiceDiscoveryProvider != null &&
!fileConfig.IsError &&
fileConfig.Data.GlobalConfiguration.ServiceDiscoveryProvider.PollingInterval > 0)
Expand Down
4 changes: 3 additions & 1 deletion src/Ocelot/Request/Mapper/StreamHttpContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ private static async Task CopyAsync(Stream input, Stream output, long announcedC
if (zeroByteReadTask.IsCompletedSuccessfully)
{
// Consume the ValueTask's result in case it is backed by an IValueTaskSource
_ = zeroByteReadTask.Result;
// It is save to read the Result once after the ValueTask has completed, and we've checked for complition by IsCompletedSuccessfully property
// See remarks: https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.valuetask-1.result?view=net-8.0#remarks
_ = zeroByteReadTask.Result; // No need to await the task by .GetAwaiter().GetResult()
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion test/Ocelot.AcceptanceTests/AggregateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ private void GivenOcelotIsRunningWithSpecificAggregatorsRegisteredInDi<TAggregat
s.AddOcelot()
.AddSingletonDefinedAggregator<TAggregator>();
})
.Configure(a => { a.UseOcelot().Wait(); });
.Configure(async b => await b.UseOcelot());

_ocelotServer = new TestServer(_webHostBuilder);
_ocelotClient = _ocelotServer.CreateClient();
Expand Down
Loading