Skip to content

Commit bdb70cc

Browse files
authored
Revert "Handle the case where a dns lookup returns an address for an addressf…"
1 parent 1ee7d87 commit bdb70cc

File tree

3 files changed

+9
-84
lines changed

3 files changed

+9
-84
lines changed

projects/client/RabbitMQ.Client/src/client/impl/TcpClientAdapter.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Net.Sockets;
45
using System.Net;
6+
using System.Text;
57
using System.Threading.Tasks;
6-
78
namespace RabbitMQ.Client
89
{
10+
11+
912
/// <summary>
10-
/// Simple wrapper around TcpClient.
13+
/// Simple wrapper around TcpClient.
1114
/// </summary>
1215
public class TcpClientAdapter : ITcpClient
1316
{
@@ -17,18 +20,14 @@ public TcpClientAdapter(Socket socket)
1720
{
1821
if (socket == null)
1922
throw new InvalidOperationException("socket must not be null");
20-
23+
2124
this.sock = socket;
2225
}
2326

2427
public virtual async Task ConnectAsync(string host, int port)
2528
{
2629
var adds = await Dns.GetHostAddressesAsync(host).ConfigureAwait(false);
27-
var ep = adds.FirstOrDefault(a => a.AddressFamily == sock.AddressFamily);
28-
if(ep == default(IPAddress))
29-
{
30-
throw new ArgumentException("No ip address could be resolved for " + host);
31-
}
30+
var ep = adds.First();
3231
#if CORECLR
3332
await sock.ConnectAsync(ep, port);
3433
#else
@@ -72,4 +71,4 @@ public virtual int ReceiveTimeout
7271
}
7372
}
7473
}
75-
}
74+
}

projects/client/Unit/src/unit/TestConnectionFactory.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
//---------------------------------------------------------------------------
4040

4141
using System;
42-
using System.Collections.Generic;
4342
using NUnit.Framework;
4443
using RabbitMQ.Client.Exceptions;
4544

@@ -108,7 +107,7 @@ public void TestCreateConnectionWithClientProvidedNameUsesName()
108107
Assert.AreEqual("some_name", conn.ClientProperties["connection_name"]);
109108
}
110109
}
111-
110+
112111
[Test]
113112
public void TestCreateConnectionWithClientProvidedNameAndAutorecoveryUsesName()
114113
{
@@ -187,14 +186,5 @@ public void TestCreateConnectionUsesInvalidAmqpTcpEndpoint()
187186
using(var conn = cf.CreateConnection(new System.Collections.Generic.List<AmqpTcpEndpoint> { ep })) {}
188187
}, Throws.TypeOf<BrokerUnreachableException>());
189188
}
190-
191-
[Test]
192-
public void TestCreateConnectioUsesValidEndpointWhenMultipleSupplied()
193-
{
194-
var cf = new ConnectionFactory();
195-
var invalidEp = new AmqpTcpEndpoint("not_localhost");
196-
var ep = new AmqpTcpEndpoint("localhost");
197-
using(var conn = cf.CreateConnection(new List<AmqpTcpEndpoint> { invalidEp, ep })) {};
198-
}
199189
}
200190
}

projects/client/Unit/src/unit/TestTcpClientAdapter.cs

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)