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:
[email protected]


Reply via email to