Skip to content

Commit ed9452b

Browse files
committed
Fix NullReferenceException
1 parent 56232f5 commit ed9452b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/GitLabApiClient/Internal/Http/GitLabHttpFacade.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Net.Http;
55
using System.Net.Http.Headers;
66
using System.Threading.Tasks;
7+
78
using GitLabApiClient.Internal.Http.Serialization;
89
using GitLabApiClient.Models.Oauth.Requests;
910
using GitLabApiClient.Models.Oauth.Responses;
@@ -22,7 +23,7 @@ internal sealed class GitLabHttpFacade
2223

2324
private GitLabHttpFacade(string hostUrl, RequestsJsonSerializer jsonSerializer, HttpClient httpClient, TimeSpan? clientTimeout = null)
2425
{
25-
_httpClient = httpClient;
26+
_httpClient = httpClient ?? new HttpClient();
2627
_httpClient.BaseAddress = new Uri(hostUrl);
2728
if (clientTimeout.HasValue)
2829
_httpClient.Timeout = clientTimeout.Value;
@@ -50,7 +51,7 @@ public GitLabHttpFacade(string hostUrl, RequestsJsonSerializer jsonSerializer, s
5051

5152
public GitLabHttpFacade(RequestsJsonSerializer jsonSerializer, HttpClient httpClient)
5253
{
53-
_httpClient = httpClient;
54+
_httpClient = httpClient ?? new HttpClient();
5455
Setup(jsonSerializer);
5556
}
5657

0 commit comments

Comments
 (0)