You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/19 19:15:52 UTC

[GitHub] [pulsar-dotpulsar] jvmdc opened a new pull request, #108: Retain original stack trace when exception happens in Producer

jvmdc opened a new pull request, #108:
URL: https://github.com/apache/pulsar-dotpulsar/pull/108

   Currently if an exception happens in the Producer, the stack trace will look like this:
   ```
         System.Net.Sockets.SocketException (11001): No such host is known.
            at DotPulsar.Internal.Producer`1.ChoosePartitions(MessageMetadata metadata, CancellationToken cancellationToken)
            at DotPulsar.Internal.Producer`1.Send(MessageMetadata metadata, TMessage message, CancellationToken cancellationToken)
            [... My own code here...]
   ```
   There is no functionality in the ChoosePartitions method that generates a SocketException, making the stack trace a bit useless.
   
   This PR throws the exception stored in the `_throw` variable using ExceptionDispatchInfo thus retaining the original stack trace. In the case of the SocketException above, this becomes:
   
   ```
   System.Net.Sockets.SocketException (11001): No such host is known.
            at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
            at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
            at System.Threading.Tasks.ValueTask.ValueTaskSourceAsTask.<>c.<.cctor>b__4_0(Object state)
         --- End of stack trace from previous location ---
            at System.Net.Sockets.TcpClient.CompleteConnectAsync(Task task)
            at DotPulsar.Internal.Connector.GetStream(String host, Int32 port)
            at DotPulsar.Internal.Connector.Connect(Uri serviceUrl)
            at DotPulsar.Internal.ConnectionPool.EstablishNewConnection(PulsarUrl url, CancellationToken cancellationToken)
            at DotPulsar.Internal.ConnectionPool.GetConnection(PulsarUrl url, CancellationToken cancellationToken)
            at DotPulsar.Internal.ConnectionPool.GetConnection(Uri serviceUrl, CancellationToken cancellationToken)
            at DotPulsar.Internal.ConnectionPool.FindConnectionForTopic(String topic, CancellationToken cancellationToken)
            at DotPulsar.Internal.Producer`1.GetNumberOfPartitions(String topic, CancellationToken cancellationToken)
            at DotPulsar.Internal.Producer`1.Monitor()
            at DotPulsar.Internal.Executor.Execute(Func`1 func, CancellationToken cancellationToken)
            at DotPulsar.Internal.Executor.Execute(Func`1 func, CancellationToken cancellationToken)
            at DotPulsar.Internal.Producer`1.Setup()
            at DotPulsar.Internal.Producer`1.ChoosePartitions(MessageMetadata metadata, CancellationToken cancellationToken)
            at DotPulsar.Internal.Producer`1.Send(MessageMetadata metadata, TMessage message, CancellationToken cancellationToken)
            [... My own code here...]
   ```
   which points to where the error actually happens :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-dotpulsar] blankensteiner merged pull request #108: Retain original stack trace when exception happens in Producer

Posted by GitBox <gi...@apache.org>.
blankensteiner merged PR #108:
URL: https://github.com/apache/pulsar-dotpulsar/pull/108


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org