Skip to content

System.NullReferenceException if InProcess collector doesn't subscribe to TestCaseStart/TestCaseEnd #2289

Closed
@MarcoRossignoli

Description

@MarcoRossignoli

If an InProcess collector doesn't subscribe to TestCaseStart or TestCaseEnd connection between datacollector process and host is not setup(--datacollectionport 0)

This lead to null ref exception when we try to read from network stream on host side

public void SendTestCaseStart(TestCaseStartEventArgs e)
{
this.communicationManager.SendMessage(MessageType.DataCollectionTestStart, e);
var message = this.communicationManager.ReceiveMessage();

ends to

but binaryReader is null

TpTrace Error: 0 : 4716, 13, 2020/01/04, 15:33:28.899, 5909922957355, testhost.dll, TestCaseEventsHandler.RaiseTestCaseStart: Exception occurred while calling handler of type Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.ProxyOutOfProcDataCollectionManager for TestCaseStartEventArgs: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.SocketCommunicationManager.ReceiveRawMessage()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.SocketCommunicationManager.ReceiveMessage()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.DataCollectionTestCaseEventSender.SendTestCaseStart(TestCaseStartEventArgs e)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection.ProxyOutOfProcDataCollectionManager.TriggerTestCaseStart(Object sender, TestCaseStartEventArgs e)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at Microsoft.VisualStudio.TestPlatform.Utilities.MulticastDelegateUtilities.SafeInvoke(Delegate delegates, Object sender, EventArgs args, String traceDisplayName)

Write side doesn't have problem because is correctly null handled

cc: @vagisha-nidhi @AbhitejJohn @singhsarab

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions