Handle transient ConnectException globally in on-device HTTP tests#11057
Draft
Handle transient ConnectException globally in on-device HTTP tests#11057
Conversation
…Certificate test Agent-Logs-Url: https://github.com/dotnet/android/sessions/1a564216-e64a-43b1-8ce0-919d7bae7020 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
jonathanpeppers
March 30, 2026 21:02
View session
Comment on lines
+290
to
+296
| HttpResponseMessage response; | ||
| try { | ||
| response = await client.GetAsync ("https://corefx-net-tls.azurewebsites.net/EchoClientCertificate.ashx"); | ||
| } catch (HttpRequestException ex) when (ex.InnerException is Java.Net.ConnectException) { | ||
| Assert.Inconclusive ($"Ignoring transient connection failure: {ex.InnerException.Message}"); | ||
| return; | ||
| } |
Member
Contributor
Author
There was a problem hiding this comment.
Good point. Reworked in 78ee6e0 — moved the Java.Net.ConnectException check into the global IgnoreIfConnectionFailed(HttpRequestException) in HttpClientHandlerTestBase (same pattern as the IOException check from 1047b55). The test now delegates to IgnoreIfConnectionFailed via new AggregateException(ex) so all tests benefit from the new check.
Member
There was a problem hiding this comment.
@copilot should you undo the changes in this file then?!?
Contributor
Author
There was a problem hiding this comment.
Yes, reverted in c2364a0. The only change now is the Java.Net.ConnectException check in the global IgnoreIfConnectionFailed(HttpRequestException) in HttpClientHandlerTestBase.
…iled helper Agent-Logs-Url: https://github.com/dotnet/android/sessions/b5e86868-a3b2-488b-ab9c-1f1f9f832db4 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot
AI
changed the title
Handle transient ConnectException in AndroidMessageHandlerSendsClientCertificate test
Handle transient ConnectException globally in on-device HTTP tests
Mar 30, 2026
… global fix Agent-Logs-Url: https://github.com/dotnet/android/sessions/1146d37f-4036-4a89-91ba-6ca76a3adb27 Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a flaky test failure in
AndroidMessageHandlerSendsClientCertificatecaused by transient network connectivity issues when connecting tocorefx-net-tls.azurewebsites.net.Problem
The test
Xamarin.Android.NetTests.AndroidMessageHandlerTests.AndroidMessageHandlerSendsClientCertificate(False)fails intermittently with:This is a transient network error unrelated to the functionality being tested.
Fix
Added
Java.Net.ConnectExceptionhandling to the globalIgnoreIfConnectionFailed(HttpRequestException)method inHttpClientHandlerTestBase, following the same pattern as the existingIOExceptioncheck added in commit 1047b55. This ensures all on-device HTTP tests that use the shared helper methods (RunIgnoringNetworkIssues,ConnectIgnoreFailure,IgnoreIfConnectionFailed) automatically benefit from the new check. No per-test changes are needed.