File tree Expand file tree Collapse file tree
tools/codeowners-utils/Azure.Sdk.Tools.CodeownersUtils/Utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ private static string GetUrlContents(string url)
5757 using HttpClient client = new HttpClient ( ) ;
5858 while ( attempts <= maxRetries )
5959 {
60+ HttpResponseMessage response = null ;
6061 try
6162 {
62- HttpResponseMessage response = client . GetAsync ( url ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
63+ response = client . GetAsync ( url ) . ConfigureAwait ( false ) . GetAwaiter ( ) . GetResult ( ) ;
6364 if ( response . StatusCode == HttpStatusCode . OK )
6465 {
6566 // This writeline is probably unnecessary but good to have if there are previous attempts that failed
@@ -76,13 +77,19 @@ private static string GetUrlContents(string url)
7677 // HttpRequestException means the request failed due to an underlying issue such as network connectivity,
7778 // DNS failure, server certificate validation or timeout.
7879 Console . WriteLine ( $ "GetUrlContents attempt number { attempts } . HttpRequestException trying to fetch { url } . Exception message = { httpReqEx . Message } ") ;
79- if ( attempts == maxRetries )
80- {
81- // At this point the retries have been exhausted, let this rethrow
82- throw ;
83- }
80+
81+ }
82+
83+ // Skip retries on a NotFound response
84+ if ( response ? . StatusCode == HttpStatusCode . NotFound )
85+ {
86+ return null ;
87+ }
88+
89+ if ( attempts < maxRetries )
90+ {
91+ System . Threading . Thread . Sleep ( delayTimeInMs ) ;
8492 }
85- System . Threading . Thread . Sleep ( delayTimeInMs ) ;
8693 attempts ++ ;
8794 }
8895 // This will only get hit if the final retry is non-OK status code
You can’t perform that action at this time.
0 commit comments