You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/05/25 10:59:40 UTC

[GitHub] [pulsar] BewareMyPower opened a new pull request #7034: [C++] Fix Result can't be serialized to string inside the library

BewareMyPower opened a new pull request #7034:
URL: https://github.com/apache/pulsar/pull/7034


   ### Motivation
   
   When a `Result` was passed to `std::ostream::operator<<` inside the library, the overloaded `operator<<` wouldn't be called. Instead `Result` was treated as a integer. For example, if you subscribed to a topic of a namespace that didn't exist, the error log would be:
   
   > ERROR ClientImpl:384 | Error Checking/Getting Partition Metadata while Subscribing on persistent://mytenant/myns/mytopic -- 5
   
   Giving following code:
   
   ```c++
   namespace pulsar {
       void foo() {
           std::stringstream ss;
           Result result = ResultOk;
           ss << result;  // "0"
       }
   }
   
   void foo() {
       std::stringstream ss;
       Result result = ResultOk;
       ss << result;  // "Ok"
   }
   ```
   `ss << result` inside namespace `pulsar` doesn't call `::operator(ss, result)`. Instead, it calls `pulsar::operator(ss, result)`, which hasn't been overloaded. Because nearly all methods are in namespace `pulsar`, the `LOG_XXX(... << result)` won't call `::operator<<(std::ostream&, Result)`.
   
   ### Modifications
   
   - Change the overloaded `operator<<` for `Result` from global namespace to namespace `pulsar`. 


----------------------------------------------------------------
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.

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



[GitHub] [pulsar] BewareMyPower commented on pull request #7034: [C++] Fix Result can't be serialized to string inside the library

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #7034:
URL: https://github.com/apache/pulsar/pull/7034#issuecomment-633589731






----------------------------------------------------------------
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.

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



[GitHub] [pulsar] merlimat merged pull request #7034: [C++] Fix Result can't be serialized to string inside the library

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #7034:
URL: https://github.com/apache/pulsar/pull/7034


   


----------------------------------------------------------------
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.

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