Closed ArwynFr closed 5 months ago
Hi Adrien! Thank you for created PR!
I've added PR to March'24 milestone. So, it will be released during first days of April. No objections? Or should I prioritize it adding to the current February'24 release? But I guess we have to have some time for debates, discussions and writing tests.
Hey Raman,
As said on the issue, I'm not involved anymore in development of Ocelot-based software. So I personally have no rush in the publication of this PR.
It is a mere hotfix regarding any aspnet 6+ compatibility, to prevent some apps to crash. There is still a long way to go in adopting WebApplicationBuilder and options pattern.
@ArwynFr Could you explain me please? What kind of app crashing do you fix by this tiny PR?
@ArwynFr Could you explain me please? What kind of app crashing do you fix by this tiny PR?
See discussion in #1518
Applications built using a dotnet 6+ with WebApplicationBuilder instead of Host/Startup, and using AddOcelot() override without the IConfiguration parameter will likely fail to start or crash. This is because the method builds the service provider which is expected not to happen with AddXXX methods. This in turns puts the provider in a weird state where resolving services could fail, throw an uncaught exception and provoke failure to start.
@ggnaegi Steeltoe is facing the same problem as Ocelot, but they have chosen to enforce the IConfiguration
, pushing the problem towards the developer instead of solving it. Since we are already passing the configuration instance, upgrading the library won't change much. But it won't help with removing the OcelotBuilder.Configuration neither.
@ggnaegi Steeltoe is facing the same problem as Ocelot, but they have chosen to enforce the
IConfiguration
, pushing the problem towards the developer instead of solving it. Since we are already passing the configuration instance, upgrading the library won't change much. But it won't help with removing the OcelotBuilder.Configuration neither.
@ArwynFr Yes, but they were, at least until version 3.5 using the same
var configuration = services.BuildServiceProvider().GetRequiredService<IConfiguration>();
as ocelot did. Since we know that, why would we keep something potentially hazardous in Ocelot? Yes, IConfiguration shouldn't be null, but we might have some edge cases. It was only some assumptions. We could create a new PR for the library update too.
We could create a new PR for the library update too.
Since it's my first PR to Ocelot, I'd rather have the lib dependency update separated please.
We could create a new PR for the library update too.
Since it's my first PR to Ocelot, I'd rather have the lib dependency update separated please.
Ok, fine
I've tested locally unit tests coverage by commands
dotnet test --collect:"XPlat Code Coverage"
which generated results with 046fc5a0-c6b6-48a5-9442-90302febc4e4
GUIDreportgenerator -reports:"d:\github\Ocelot\ArwynFr\Ocelot\test\Ocelot.UnitTests\TestResults\046fc5a0-c6b6-48a5-9442-90302febc4e4\coverage.cobertura.xml" -targetdir:"d:\github\Ocelot\ArwynFr\Ocelot\test\Ocelot.UnitTests\TestResults" -reporttypes:Html
And I see bad coverage... Also I have totally missed this thing during code review, Adrien 🙃
Report header
Do you like tests? 😉 Our dev process requires unit testing for new code. ⚠️ So, this PR merging will be blocked until added unit tests to cover new methods❕
@raman-m will look into it this weekend
I like these pictures! And you, Adrien? 😉
@ArwynFr Where are you?
@ArwynFr I have no time to wait for a simple action to do. I don't want to delay release too. Merging...
@ArwynFr Thank you for the contribution! This hotfix will be released next week...
Fixes #1518
1518
Proposed Changes
ServiceCollection
by a newServiceProvider
by copying theServiceDescriptor
Beware that this does not fix the problem of Steeltoe discovery client that might still build the service provider. This is just a hotfix, there is still room for a larger refactor of removing the
IConfiguration
from theOcelotBuilder
.