Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MarcoRossignoli opened this issue Jan 4, 2020 · 1 comment · Fixed by #2290
Assignees
Labels

Comments

@MarcoRossignoli
Copy link
Contributor

MarcoRossignoli commented Jan 4, 2020

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

@MarcoRossignoli
Copy link
Contributor Author

I've got a PR ready, assign to me if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants