Skip to content

Commit cebd287

Browse files
authored
chore: Remove System.Net.Http reference on .NET Framework. Resolves #2750 (#2751)
* chore: Remove System.Net.Http reference on .NET Framework * Fix unit test
1 parent 27cc7e1 commit cebd287

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Agent/NewRelic/Agent/Core/DataTransport/ConnectionManager.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
using System.IO;
1111
using System.Linq;
1212
using System.Net;
13+
#if !NETFRAMEWORK
1314
using System.Net.Http;
15+
#endif
1416
using System.Net.Sockets;
1517

1618
namespace NewRelic.Agent.Core.DataTransport
@@ -107,12 +109,14 @@ private void Connect()
107109
{
108110
HandleHttpErrorResponse(ex);
109111
}
112+
#if !NETFRAMEWORK // Only available in System.Net.Http
110113
// Occurs when the agent is unable to connect to APM. The request failed due to an underlying
111114
// issue such as network connectivity, DNS failure, server certificate validation or timeout.
112115
catch (HttpRequestException)
113116
{
114117
ScheduleRestart();
115118
}
119+
#endif
116120
// Occurs when the agent connects to APM but the connection gets aborted by the collector
117121
catch (SocketException)
118122
{
@@ -168,7 +172,7 @@ public T SendDataRequest<T>(string method, params object[] data)
168172
}
169173
}
170174

171-
#endregion Synchronized methods
175+
#endregion Synchronized methods
172176

173177
#region Helper methods
174178

tests/Agent/UnitTests/Core.UnitTest/DataTransport/ConnectionManagerTests.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,12 @@ public void AttemptAutoStart_SchedulesConnectAsynchronously_IfAutoStartIsOnAndSy
8585
[Test]
8686
[TestCase("ForceRestartException")]
8787
[TestCase("HttpException")]
88-
[TestCase("HttpRequestException")]
8988
[TestCase("SocketException")]
9089
[TestCase("IOException")]
9190
[TestCase("OperationCanceledException")]
91+
#if !NETFRAMEWORK
92+
[TestCase("HttpRequestException")]
93+
#endif
9294
public void AttemptAutoStart_SchedulesReconnect_IfCertainExceptionOccurs(string execeptionType)
9395
{
9496
Exception ex = null;

0 commit comments

Comments
 (0)