Skip to content

TcpClient.Connect throws NRE if the Socket is cleared #69493

@MihaZupan

Description

@MihaZupan

After #67951, the Connect_DnsEndPoint_Success(mode: 1) TcpClient outerloop test is failing with an NRE.

System.NullReferenceException : Object reference not set to an instance of an object.
   at System.Net.Sockets.TcpClient.Connect(String hostname, Int32 port) in /_/src/libraries/System.Net.Sockets/src/System/Net/Sockets/TCPClient.cs:line 130
   at System.Net.Sockets.Tests.TcpClientTest.Connect_DnsEndPoint_Success(Int32 mode) in /_/src/libraries/System.Net.Sockets/tests/FunctionalTests/TcpClientTest.cs:line 222
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(Object obj, IntPtr* arguments, Span`1 argsForTemporaryMonoSupport, BindingFlags invokeAttr) in /_/src/coreclr/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.CoreCLR.cs:line 387

The _clientSocket is only initialized during the ctor, so the Connect ends up failing if the user clears the Client socket manually.

cc: @wfurt

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions