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 2018/01/22 18:17:21 UTC

[GitHub] jai1 closed pull request #1080: ENH: Apply `make format` into C++ client

jai1 closed pull request #1080: ENH: Apply `make format` into C++ client
URL: https://github.com/apache/incubator-pulsar/pull/1080
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-client-cpp/.clang-format b/pulsar-client-cpp/.clang-format
index 76ceab1f1..cb40b5069 100644
--- a/pulsar-client-cpp/.clang-format
+++ b/pulsar-client-cpp/.clang-format
@@ -17,4 +17,9 @@
 
 
 BasedOnStyle: Google
-ColumnLimit: 90
+IndentWidth: 4
+ColumnLimit: 110
+SortIncludes: false
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterEnum: true
diff --git a/pulsar-client-cpp/build-support/clang_format_exclusions.txt b/pulsar-client-cpp/build-support/clang_format_exclusions.txt
index e69de29bb..d3594ec97 100644
--- a/pulsar-client-cpp/build-support/clang_format_exclusions.txt
+++ b/pulsar-client-cpp/build-support/clang_format_exclusions.txt
@@ -0,0 +1,2 @@
+*.pb.h
+*.pb.cc
diff --git a/pulsar-client-cpp/include/pulsar/Authentication.h b/pulsar-client-cpp/include/pulsar/Authentication.h
index 7def5f289..a39f811e5 100644
--- a/pulsar-client-cpp/include/pulsar/Authentication.h
+++ b/pulsar-client-cpp/include/pulsar/Authentication.h
@@ -30,54 +30,56 @@
 
 namespace pulsar {
 
-    class ClientConfiguration;
-    class Authentication;
+class ClientConfiguration;
+class Authentication;
 
-    class AuthenticationDataProvider {
-    public:
-        virtual ~AuthenticationDataProvider();
-        virtual bool hasDataForTls();
-        virtual std::string getTlsCertificates();
-        virtual std::string getTlsPrivateKey();
-        virtual bool hasDataForHttp();
-        virtual std::string getHttpAuthType();
-        virtual std::string getHttpHeaders();
-        virtual bool hasDataFromCommand();
-        virtual std::string getCommandData();
-    protected:
-        AuthenticationDataProvider();
-    };
+class AuthenticationDataProvider {
+   public:
+    virtual ~AuthenticationDataProvider();
+    virtual bool hasDataForTls();
+    virtual std::string getTlsCertificates();
+    virtual std::string getTlsPrivateKey();
+    virtual bool hasDataForHttp();
+    virtual std::string getHttpAuthType();
+    virtual std::string getHttpHeaders();
+    virtual bool hasDataFromCommand();
+    virtual std::string getCommandData();
 
-    typedef boost::shared_ptr<AuthenticationDataProvider> AuthenticationDataPtr;
-    typedef boost::shared_ptr<Authentication> AuthenticationPtr;
-    typedef std::map<std::string, std::string> ParamMap;
+   protected:
+    AuthenticationDataProvider();
+};
 
-    class Authentication {
-    public:
-        virtual ~Authentication();
-        virtual const std::string getAuthMethodName() const = 0;
-        virtual Result getAuthData(AuthenticationDataPtr& authDataContent) const {
-            authDataContent = authData_;
-            return ResultOk;
-        }
-    protected:
-        Authentication();
-        AuthenticationDataPtr authData_;
-        friend class ClientConfiguration;
-    };
+typedef boost::shared_ptr<AuthenticationDataProvider> AuthenticationDataPtr;
+typedef boost::shared_ptr<Authentication> AuthenticationPtr;
+typedef std::map<std::string, std::string> ParamMap;
 
-    class AuthFactory {
-    public:
-        static AuthenticationPtr Disabled();
-        static AuthenticationPtr create(const std::string& dynamicLibPath);
-        static AuthenticationPtr create(const std::string& dynamicLibPath, const std::string& authParamsString);
-        static AuthenticationPtr create(const std::string& dynamicLibPath, ParamMap& params);
+class Authentication {
+   public:
+    virtual ~Authentication();
+    virtual const std::string getAuthMethodName() const = 0;
+    virtual Result getAuthData(AuthenticationDataPtr& authDataContent) const {
+        authDataContent = authData_;
+        return ResultOk;
+    }
 
-    protected:
-        static bool isShutdownHookRegistered_;
-        static std::vector<void *> loadedLibrariesHandles_;
-        static void release_handles();
-    };
+   protected:
+    Authentication();
+    AuthenticationDataPtr authData_;
+    friend class ClientConfiguration;
+};
+
+class AuthFactory {
+   public:
+    static AuthenticationPtr Disabled();
+    static AuthenticationPtr create(const std::string& dynamicLibPath);
+    static AuthenticationPtr create(const std::string& dynamicLibPath, const std::string& authParamsString);
+    static AuthenticationPtr create(const std::string& dynamicLibPath, ParamMap& params);
+
+   protected:
+    static bool isShutdownHookRegistered_;
+    static std::vector<void*> loadedLibrariesHandles_;
+    static void release_handles();
+};
 }
 // namespace pulsar
 
diff --git a/pulsar-client-cpp/include/pulsar/BatchMessageId.h b/pulsar-client-cpp/include/pulsar/BatchMessageId.h
index 1afa5523f..c1d672935 100644
--- a/pulsar-client-cpp/include/pulsar/BatchMessageId.h
+++ b/pulsar-client-cpp/include/pulsar/BatchMessageId.h
@@ -29,17 +29,13 @@ namespace pulsar {
 class PulsarWrapper;
 
 class BatchMessageId : public MessageId {
- public:
+   public:
     BatchMessageId(int64_t ledgerId, int64_t entryId, int batchIndex = -1)
-            : MessageId(ledgerId, entryId),
-              batchIndex_(batchIndex) {
-    }
+        : MessageId(ledgerId, entryId), batchIndex_(batchIndex) {}
 
     BatchMessageId(const MessageId& msgId);
 
-    BatchMessageId()
-            : batchIndex_(-1) {
-    }
+    BatchMessageId() : batchIndex_(-1) {}
 
     virtual void serialize(std::string& result) const;
 
@@ -48,7 +44,7 @@ class BatchMessageId : public MessageId {
     bool operator<=(const BatchMessageId& other) const;
     bool operator==(const BatchMessageId& other) const;
 
-  protected:
+   protected:
     virtual int64_t getBatchIndex() const;
 
     friend class Commands;
@@ -65,7 +61,6 @@ class BatchMessageId : public MessageId {
 
     friend std::ostream& operator<<(std::ostream& s, const BatchMessageId& messageId);
 };
-
 }
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h b/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h
index 78cff0acd..5390b7a6b 100644
--- a/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h
+++ b/pulsar-client-cpp/include/pulsar/BrokerConsumerStats.h
@@ -33,9 +33,10 @@ class PulsarWrapper;
 
 /* @note: isValid() or getXXX() methods are not allowed on an invalid BrokerConsumerStats */
 class BrokerConsumerStats {
- private:
+   private:
     boost::shared_ptr<BrokerConsumerStatsImplBase> impl_;
- public:
+
+   public:
     explicit BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl);
 
     BrokerConsumerStats();
@@ -83,12 +84,12 @@ class BrokerConsumerStats {
     boost::shared_ptr<BrokerConsumerStatsImplBase> getImpl() const;
 
     friend class PulsarWrapper;
-    friend std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats &obj);
+    friend std::ostream &operator<<(std::ostream &os, const BrokerConsumerStats &obj);
 };
-typedef boost::function<void(Result result, BrokerConsumerStats brokerConsumerStats)> BrokerConsumerStatsCallback;
-
+typedef boost::function<void(Result result, BrokerConsumerStats brokerConsumerStats)>
+    BrokerConsumerStatsCallback;
 }
 
 #pragma GCC visibility pop
 
-#endif //PULSAR_CPP_BROKERCONSUMERSTATS_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATS_H
diff --git a/pulsar-client-cpp/include/pulsar/Client.h b/pulsar-client-cpp/include/pulsar/Client.h
index 295980e50..798541439 100644
--- a/pulsar-client-cpp/include/pulsar/Client.h
+++ b/pulsar-client-cpp/include/pulsar/Client.h
@@ -41,18 +41,21 @@ class PulsarFriend;
 class PulsarWrapper;
 
 class Client {
- public:
+   public:
     /**
-     * Create a Pulsar client object connecting to the specified cluster address and using the default configuration.
+     * Create a Pulsar client object connecting to the specified cluster address and using the default
+     * configuration.
      *
      * @param serviceUrl the Pulsar endpoint to use (eg: pulsar://localhost:6650)
      */
     Client(const std::string& serviceUrl);
 
     /**
-     * Create a Pulsar client object connecting to the specified cluster address and using the specified configuration.
+     * Create a Pulsar client object connecting to the specified cluster address and using the specified
+     * configuration.
      *
-     * @param serviceUrl the Pulsar endpoint to use (eg: http://brokerv2-pdev.messaging.corp.gq1.yahoo.com:4080 for Sandbox access)
+     * @param serviceUrl the Pulsar endpoint to use (eg:
+     * http://brokerv2-pdev.messaging.corp.gq1.yahoo.com:4080 for Sandbox access)
      * @param clientConfiguration the client configuration to use
      */
     Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration);
@@ -80,8 +83,7 @@ class Client {
      * @return ResultOk if the producer has been successfully created
      * @return ResultError if there was an error
      */
-    Result createProducer(const std::string& topic, const ProducerConfiguration& conf,
-                          Producer& producer);
+    Result createProducer(const std::string& topic, const ProducerConfiguration& conf, Producer& producer);
 
     void createProducerAsync(const std::string& topic, CreateProducerCallback callback);
 
@@ -98,34 +100,39 @@ class Client {
                         const ConsumerConfiguration& conf, SubscribeCallback callback);
 
     /**
-     * Create a topic reader with given {@code ReaderConfiguration} for reading messages from the specified topic.
+     * Create a topic reader with given {@code ReaderConfiguration} for reading messages from the specified
+     * topic.
      * <p>
-     * The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a
+     * The Reader provides a low-level abstraction that allows for manual positioning in the topic, without
+     * using a
      * subscription. Reader can only work on non-partitioned topics.
      * <p>
      * The initial reader positioning is done by specifying a message id. The options are:
      * <ul>
      * <li><code>MessageId.earliest</code> : Start reading from the earliest message available in the topic
-     * <li><code>MessageId.latest</code> : Start reading from the end topic, only getting messages published after the
+     * <li><code>MessageId.latest</code> : Start reading from the end topic, only getting messages published
+     * after the
      * reader was created
-     * <li><code>MessageId</code> : When passing a particular message id, the reader will position itself on that
+     * <li><code>MessageId</code> : When passing a particular message id, the reader will position itself on
+     * that
      * specific position. The first message to be read will be the message next to the specified messageId.
      * </ul>
      *
      * @param topic
      *            The name of the topic where to read
      * @param startMessageId
-     *            The message id where the reader will position itself. The first message returned will be the one after
+     *            The message id where the reader will position itself. The first message returned will be the
+     * one after
      *            the specified startMessageId
      * @param conf
      *            The {@code ReaderConfiguration} object
      * @return The {@code Reader} object
      */
-     Result createReader(const std::string& topic, const MessageId& startMessageId,
-                       const ReaderConfiguration& conf, Reader& reader);
+    Result createReader(const std::string& topic, const MessageId& startMessageId,
+                        const ReaderConfiguration& conf, Reader& reader);
 
-     void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
-                            const ReaderConfiguration& conf, ReaderCallback callback);
+    void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
+                           const ReaderConfiguration& conf, ReaderCallback callback);
 
     /**
      *
@@ -137,15 +144,15 @@ class Client {
 
     void shutdown();
 
- private:
-    Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration, bool poolConnections);
+   private:
+    Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
+           bool poolConnections);
     Client(const boost::shared_ptr<ClientImpl>);
 
     friend class PulsarFriend;
     friend class PulsarWrapper;
     boost::shared_ptr<ClientImpl> impl_;
 };
-
 }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/ClientConfiguration.h b/pulsar-client-cpp/include/pulsar/ClientConfiguration.h
index e8914a43c..c86b7bc6c 100644
--- a/pulsar-client-cpp/include/pulsar/ClientConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ClientConfiguration.h
@@ -25,8 +25,7 @@ namespace pulsar {
 class PulsarWrapper;
 class ClientConfigurationImpl;
 class ClientConfiguration {
- public:
-
+   public:
     ClientConfiguration();
     ~ClientConfiguration();
     ClientConfiguration(const ClientConfiguration&);
@@ -89,7 +88,8 @@ class ClientConfiguration {
 
     /**
      * Number of concurrent lookup-requests allowed on each broker-connection to prevent overload on broker.
-     * <i>(default: 5000)</i> It should be configured with higher value only in case of it requires to produce/subscribe on
+     * <i>(default: 5000)</i> It should be configured with higher value only in case of it requires to
+     * produce/subscribe on
      * thousands of topic using created {@link PulsarClient}
      *
      * @param concurrentLookupRequest
@@ -116,7 +116,7 @@ class ClientConfiguration {
     ClientConfiguration& setUseTls(bool useTls);
     bool isUseTls() const;
 
-    ClientConfiguration& setTlsTrustCertsFilePath(const std::string &tlsTrustCertsFilePath);
+    ClientConfiguration& setTlsTrustCertsFilePath(const std::string& tlsTrustCertsFilePath);
     std::string getTlsTrustCertsFilePath() const;
 
     ClientConfiguration& setTlsAllowInsecureConnection(bool allowInsecure);
@@ -136,7 +136,7 @@ class ClientConfiguration {
     friend class ClientImpl;
     friend class PulsarWrapper;
 
- private:
+   private:
     const AuthenticationPtr& getAuthPtr() const;
     boost::shared_ptr<ClientConfigurationImpl> impl_;
 };
@@ -144,4 +144,3 @@ class ClientConfiguration {
 
 #pragma GCC visibility pop
 #endif /* PULSAR_CLIENTCONFIGURATION_H_ */
-
diff --git a/pulsar-client-cpp/include/pulsar/CompressionType.h b/pulsar-client-cpp/include/pulsar/CompressionType.h
index 602841876..9dc92be83 100644
--- a/pulsar-client-cpp/include/pulsar/CompressionType.h
+++ b/pulsar-client-cpp/include/pulsar/CompressionType.h
@@ -20,7 +20,8 @@
 #define PULSAR_COMPRESSIONTYPE_H_
 #pragma GCC visibility push(default)
 namespace pulsar {
-enum CompressionType {
+enum CompressionType
+{
     CompressionNone = 0,
     CompressionLZ4 = 1,
     CompressionZLib = 2
diff --git a/pulsar-client-cpp/include/pulsar/Consumer.h b/pulsar-client-cpp/include/pulsar/Consumer.h
index c02c2604a..96aaa9f15 100644
--- a/pulsar-client-cpp/include/pulsar/Consumer.h
+++ b/pulsar-client-cpp/include/pulsar/Consumer.h
@@ -25,7 +25,6 @@
 #include <pulsar/ConsumerConfiguration.h>
 #pragma GCC visibility push(default)
 
-
 namespace pulsar {
 class PulsarWrapper;
 class ConsumerImplBase;
@@ -34,7 +33,7 @@ class PulsarFriend;
  *
  */
 class Consumer {
- public:
+   public:
     /**
      * Construct an uninitialized consumer object
      */
@@ -139,7 +138,8 @@ class Consumer {
      * waiting for the callback to be triggered.
      *
      * @param message the last message in the stream to acknowledge
-     * @return ResultOk if the message was successfully acknowledged. All previously delivered messages for this topic are also acknowledged.
+     * @return ResultOk if the message was successfully acknowledged. All previously delivered messages for
+     * this topic are also acknowledged.
      * @return ResultError if there was a failure
      */
     Result acknowledgeCumulative(const Message& message);
@@ -174,17 +174,22 @@ class Consumer {
     Result resumeMessageListener();
 
     /**
-     * Redelivers all the unacknowledged messages. In Failover mode, the request is ignored if the consumer is not
-     * active for the given topic. In Shared mode, the consumers messages to be redelivered are distributed across all
-     * the connected consumers. This is a non blocking call and doesn't throw an exception. In case the connection
+     * Redelivers all the unacknowledged messages. In Failover mode, the request is ignored if the consumer is
+     * not
+     * active for the given topic. In Shared mode, the consumers messages to be redelivered are distributed
+     * across all
+     * the connected consumers. This is a non blocking call and doesn't throw an exception. In case the
+     * connection
      * breaks, the messages are redelivered after reconnect.
      */
     void redeliverUnacknowledgedMessages();
 
     /**
      * Gets Consumer Stats from broker.
-     * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call expires
-     * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the stats are
+     * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call
+     * expires
+     * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the
+     * stats are
      * still valid.
      *
      * @param brokerConsumerStats - if the function returns ResultOk, this object will contain consumer stats
@@ -195,15 +200,18 @@ class Consumer {
 
     /**
     * Asynchronous call to gets Consumer Stats from broker.
-    * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call expires
-    * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the stats are
+    * The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call
+    * expires
+    * then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the
+    * stats are
     * still valid.
     *
     * @param callback - callback function to get the brokerConsumerStats,
     *                   if result is ResultOk then the brokerConsumerStats will be populated
     */
     void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
-private:
+
+   private:
     typedef boost::shared_ptr<ConsumerImplBase> ConsumerImplBasePtr;
     ConsumerImplBasePtr impl_;
     explicit Consumer(ConsumerImplBasePtr);
@@ -215,7 +223,6 @@ class Consumer {
     friend class ClientImpl;
     friend class ConsumerTest;
 };
-
 }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h b/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h
index 9f600a432..90c4d6d83 100644
--- a/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ConsumerConfiguration.h
@@ -43,7 +43,7 @@ class ConsumerConfigurationImpl;
  * Class specifying the configuration of a consumer.
  */
 class ConsumerConfiguration {
- public:
+   public:
     ConsumerConfiguration();
     ~ConsumerConfiguration();
     ConsumerConfiguration(const ConsumerConfiguration&);
@@ -80,9 +80,12 @@ class ConsumerConfiguration {
      * application calls receive(). Using a higher value could potentially increase the consumer throughput
      * at the expense of bigger memory utilization.
      *
-     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling pre-fetching of
-     * messages. This approach improves the message distribution on shared subscription, by pushing messages only to
-     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can be
+     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling
+     * pre-fetching of
+     * messages. This approach improves the message distribution on shared subscription, by pushing messages
+     * only to
+     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can
+     * be
      * used if the consumer queue size is zero. The receive() function call should not be interrupted when
      * the consumer queue size is zero.
      *
@@ -123,11 +126,9 @@ class ConsumerConfiguration {
     long getBrokerConsumerStatsCacheTimeInMs() const;
     friend class PulsarWrapper;
 
- private:
+   private:
     boost::shared_ptr<ConsumerConfigurationImpl> impl_;
 };
-
 }
 #pragma GCC visibility pop
 #endif /* PULSAR_CONSUMERCONFIGURATION_H_ */
-
diff --git a/pulsar-client-cpp/include/pulsar/ConsumerType.h b/pulsar-client-cpp/include/pulsar/ConsumerType.h
index ead4462e3..28a068d54 100644
--- a/pulsar-client-cpp/include/pulsar/ConsumerType.h
+++ b/pulsar-client-cpp/include/pulsar/ConsumerType.h
@@ -21,23 +21,24 @@
 
 #pragma GCC visibility push(default)
 namespace pulsar {
-    enum ConsumerType {
-        /**
-         * There can be only 1 consumer on the same topic with the same consumerName
-         */
-        ConsumerExclusive,
+enum ConsumerType
+{
+    /**
+     * There can be only 1 consumer on the same topic with the same consumerName
+     */
+    ConsumerExclusive,
 
-        /**
-         * Multiple consumers will be able to use the same consumerName and the messages
-         *  will be dispatched according to a round-robin rotation between the connected consumers
-         */
-        ConsumerShared,
+    /**
+     * Multiple consumers will be able to use the same consumerName and the messages
+     *  will be dispatched according to a round-robin rotation between the connected consumers
+     */
+    ConsumerShared,
 
-        /** Only one consumer is active on the subscription; Subscription can have N consumers
-         *  connected one of which will get promoted to master if the current master becomes inactive
-         */
-        ConsumerFailover
-    };
+    /** Only one consumer is active on the subscription; Subscription can have N consumers
+     *  connected one of which will get promoted to master if the current master becomes inactive
+     */
+    ConsumerFailover
+};
 }
 #pragma GCC visibility pop
-#endif //PULSAR_CPP_CONSUMERTYPE_H
+#endif  // PULSAR_CPP_CONSUMERTYPE_H
diff --git a/pulsar-client-cpp/include/pulsar/DeprecatedException.h b/pulsar-client-cpp/include/pulsar/DeprecatedException.h
index 123edaa5f..c43a4777b 100644
--- a/pulsar-client-cpp/include/pulsar/DeprecatedException.h
+++ b/pulsar-client-cpp/include/pulsar/DeprecatedException.h
@@ -23,13 +23,13 @@
 #include <string>
 
 namespace pulsar {
-    class DeprecatedException: public std::runtime_error {
-    public:
-        explicit DeprecatedException(const std::string& __arg);
+class DeprecatedException : public std::runtime_error {
+   public:
+    explicit DeprecatedException(const std::string& __arg);
 
-    private:
-        static const std::string message_prefix;
-    };
+   private:
+    static const std::string message_prefix;
+};
 }
 
-#endif //DEPRECATED_EXCEPTION_HPP_
+#endif  // DEPRECATED_EXCEPTION_HPP_
diff --git a/pulsar-client-cpp/include/pulsar/Message.h b/pulsar-client-cpp/include/pulsar/Message.h
index 9c134242c..6cc14246e 100644
--- a/pulsar-client-cpp/include/pulsar/Message.h
+++ b/pulsar-client-cpp/include/pulsar/Message.h
@@ -28,20 +28,21 @@
 #pragma GCC visibility push(default)
 
 namespace pulsar {
-    namespace proto {
-        class CommandMessage;
-        class MessageMetadata;
-        class SingleMessageMetadata;
-    }
+namespace proto {
+class CommandMessage;
+class MessageMetadata;
+class SingleMessageMetadata;
+}
 
 class SharedBuffer;
 class MessageBuilder;
 class MessageImpl;
 class PulsarWrapper;
 
-// TODO: When releasing 2.0.0, make all methods virtual and create the virtual destructor for Google Mock tests
+// TODO: When releasing 2.0.0, make all methods virtual and create the virtual destructor for Google Mock
+// tests
 class Message {
- public:
+   public:
     typedef std::map<std::string, std::string> StringMap;
 
     Message();
@@ -96,7 +97,8 @@ class Message {
     /**
      * Get the unique message ID associated with this message.
      *
-     * The message id can be used to univocally refer to a message without having to keep the entire payload in memory.
+     * The message id can be used to univocally refer to a message without having to keep the entire payload
+     * in memory.
      *
      * Only messages received from the consumer will have a message id assigned.
      *
@@ -111,7 +113,8 @@ class Message {
     bool hasPartitionKey() const;
 
     /**
-     * Get the UTC based timestamp in milliseconds referring to when the message was published by the client producer
+     * Get the UTC based timestamp in milliseconds referring to when the message was published by the client
+     * producer
      */
     uint64_t getPublishTimestamp() const;
 
@@ -120,14 +123,15 @@ class Message {
      */
     uint64_t getEventTimestamp() const;
 
-  private:
+   private:
     typedef boost::shared_ptr<MessageImpl> MessageImplPtr;
     MessageImplPtr impl_;
 
     Message(MessageImplPtr& impl);
     Message(const proto::CommandMessage& msg, proto::MessageMetadata& data, SharedBuffer& payload);
     /// Used for Batch Messages
-    Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload, proto::SingleMessageMetadata& singleMetadata);
+    Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload,
+            proto::SingleMessageMetadata& singleMetadata);
     friend class PartitionedProducerImpl;
     friend class PartitionedConsumerImpl;
     friend class MessageBuilder;
@@ -141,7 +145,6 @@ class Message {
     friend std::ostream& operator<<(std::ostream& s, const StringMap& map);
     friend std::ostream& operator<<(std::ostream& s, const Message& msg);
 };
-
 }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/MessageBuilder.h b/pulsar-client-cpp/include/pulsar/MessageBuilder.h
index 7f63fe3ca..48dafd326 100644
--- a/pulsar-client-cpp/include/pulsar/MessageBuilder.h
+++ b/pulsar-client-cpp/include/pulsar/MessageBuilder.h
@@ -28,8 +28,7 @@ namespace pulsar {
 class PulsarWrapper;
 
 class MessageBuilder {
- public:
-
+   public:
     MessageBuilder();
 
     typedef std::map<std::string, std::string> StringMap;
@@ -117,7 +116,8 @@ class MessageBuilder {
      *
      */
     MessageBuilder& create();
- private:
+
+   private:
     MessageBuilder(const MessageBuilder&);
     void checkMetadata();
     static boost::shared_ptr<MessageImpl> createMessageImpl();
@@ -125,7 +125,6 @@ class MessageBuilder {
 
     friend class PulsarWrapper;
 };
-
 }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/MessageId.h b/pulsar-client-cpp/include/pulsar/MessageId.h
index 6fd2d51f8..5bf92247c 100644
--- a/pulsar-client-cpp/include/pulsar/MessageId.h
+++ b/pulsar-client-cpp/include/pulsar/MessageId.h
@@ -32,7 +32,7 @@ class UnAckedMessageTrackerEnabled;
 class PulsarWrapper;
 
 class MessageId {
- public:
+   public:
     MessageId& operator=(const MessageId&);
     MessageId();
     virtual ~MessageId() {}
@@ -61,8 +61,7 @@ class MessageId {
     bool operator<(const MessageId& other) const;
     bool operator==(const MessageId& other) const;
 
- protected:
-
+   protected:
     virtual int64_t getBatchIndex() const;
     friend class ConsumerImpl;
     friend class Message;
@@ -77,13 +76,11 @@ class MessageId {
     MessageId(int64_t, int64_t);
     friend std::ostream& operator<<(std::ostream& s, const MessageId& messageId);
     int64_t ledgerId_;
-    int64_t entryId_ :48;
-    short partition_ :16;
+    int64_t entryId_ : 48;
+    short partition_ : 16;
 };
-
-
 }
 
 #pragma GCC visibility pop
 
-#endif //MESSAGE_ID_H
+#endif  // MESSAGE_ID_H
diff --git a/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h b/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h
index 3b72e86be..21bf10d3f 100644
--- a/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h
+++ b/pulsar-client-cpp/include/pulsar/MessageRoutingPolicy.h
@@ -33,15 +33,16 @@
 namespace pulsar {
 
 class MessageRoutingPolicy {
- public:
+   public:
     virtual ~MessageRoutingPolicy() {}
 
     /** @deprecated
        Use int getPartition(const Message& msg, const TopicMetadata& topicMetadata)
     */
     virtual int getPartition(const Message& msg) {
-        throw DeprecatedException("Use int getPartition(const Message& msg,"
-                                          " const TopicMetadata& topicMetadata)");
+        throw DeprecatedException(
+            "Use int getPartition(const Message& msg,"
+            " const TopicMetadata& topicMetadata)");
     }
 
     virtual int getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
@@ -54,4 +55,4 @@ typedef boost::shared_ptr<MessageRoutingPolicy> MessageRoutingPolicyPtr;
 
 #pragma GCC visibility pop
 
-#endif // PULSAR_MESSAGE_ROUTING_POLICY_HEADER_
+#endif  // PULSAR_MESSAGE_ROUTING_POLICY_HEADER_
diff --git a/pulsar-client-cpp/include/pulsar/Producer.h b/pulsar-client-cpp/include/pulsar/Producer.h
index a091f52be..ff245578f 100644
--- a/pulsar-client-cpp/include/pulsar/Producer.h
+++ b/pulsar-client-cpp/include/pulsar/Producer.h
@@ -30,7 +30,7 @@ class ProducerImplBase;
 class PulsarWrapper;
 class PulsarFriend;
 class Producer {
- public:
+   public:
     /**
      * Construct an uninitialized Producer.
      */
@@ -86,7 +86,8 @@ class Producer {
      * This represent either the automatically assigned or custom sequence id (set on the MessageBuilder) that
      * was published and acknowledged by the broker.
      *
-     * After recreating a producer with the same producer name, this will return the last message that was published in
+     * After recreating a producer with the same producer name, this will return the last message that was
+     * published in
      * the previous producer session, or -1 if there no message was ever published.
      *
      * @return the last sequence id published by this producer
@@ -113,7 +114,7 @@ class Producer {
      */
     void closeAsync(CloseCallback callback);
 
- private:
+   private:
     typedef boost::shared_ptr<ProducerImplBase> ProducerImplBasePtr;
     explicit Producer(ProducerImplBasePtr);
 
@@ -123,7 +124,6 @@ class Producer {
 
     ProducerImplBasePtr impl_;
 };
-
 }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h b/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h
index e64a859eb..4aa990a75 100644
--- a/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ProducerConfiguration.h
@@ -37,8 +37,9 @@ class PulsarWrapper;
  * Class that holds the configuration for a producer
  */
 class ProducerConfiguration {
- public:
-    enum PartitionsRoutingMode {
+   public:
+    enum PartitionsRoutingMode
+    {
         UseSinglePartition,
         RoundRobinDistribution,
         CustomPartition
@@ -80,20 +81,18 @@ class ProducerConfiguration {
     const unsigned int& getBatchingMaxMessages() const;
 
     ProducerConfiguration& setBatchingMaxAllowedSizeInBytes(
-            const unsigned long& batchingMaxAllowedSizeInBytes);
+        const unsigned long& batchingMaxAllowedSizeInBytes);
     const unsigned long& getBatchingMaxAllowedSizeInBytes() const;
 
-    ProducerConfiguration& setBatchingMaxPublishDelayMs(
-            const unsigned long& batchingMaxPublishDelayMs);
+    ProducerConfiguration& setBatchingMaxPublishDelayMs(const unsigned long& batchingMaxPublishDelayMs);
     const unsigned long& getBatchingMaxPublishDelayMs() const;
 
     friend class PulsarWrapper;
 
- private:
+   private:
     struct Impl;
     boost::shared_ptr<ProducerConfigurationImpl> impl_;
 };
 }
 #pragma GCC visibility pop
 #endif /* PULSAR_PRODUCERCONFIGURATION_H_ */
-
diff --git a/pulsar-client-cpp/include/pulsar/Reader.h b/pulsar-client-cpp/include/pulsar/Reader.h
index c57084f98..60df1492c 100644
--- a/pulsar-client-cpp/include/pulsar/Reader.h
+++ b/pulsar-client-cpp/include/pulsar/Reader.h
@@ -24,7 +24,6 @@
 
 #pragma GCC visibility push(default)
 
-
 namespace pulsar {
 class PulsarWrapper;
 class PulsarFriend;
@@ -34,7 +33,7 @@ class ReaderImpl;
  * A Reader can be used to scan through all the messages currently available in a topic.
  */
 class Reader {
- public:
+   public:
     /**
      * Construct an uninitialized reader object
      */
@@ -72,7 +71,7 @@ class Reader {
 
     void closeAsync(ResultCallback callback);
 
-private:
+   private:
     typedef boost::shared_ptr<ReaderImpl> ReaderImplPtr;
     ReaderImplPtr impl_;
     explicit Reader(ReaderImplPtr);
@@ -82,7 +81,6 @@ class Reader {
     friend class ReaderImpl;
     friend class ReaderTest;
 };
-
 }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h b/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h
index 188992ba5..9adc6b5ca 100644
--- a/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h
+++ b/pulsar-client-cpp/include/pulsar/ReaderConfiguration.h
@@ -42,7 +42,7 @@ class ReaderConfigurationImpl;
  * Class specifying the configuration of a consumer.
  */
 class ReaderConfiguration {
- public:
+   public:
     ReaderConfiguration();
     ~ReaderConfiguration();
     ReaderConfiguration(const ReaderConfiguration&);
@@ -63,9 +63,12 @@ class ReaderConfiguration {
      * application calls receive(). Using a higher value could potentially increase the consumer throughput
      * at the expense of bigger memory utilization.
      *
-     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling pre-fetching of
-     * messages. This approach improves the message distribution on shared subscription, by pushing messages only to
-     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can be
+     * Setting the consumer queue size as zero decreases the throughput of the consumer, by disabling
+     * pre-fetching of
+     * messages. This approach improves the message distribution on shared subscription, by pushing messages
+     * only to
+     * the consumers that are ready to process them. Neither receive with timeout nor Partitioned Topics can
+     * be
      * used if the consumer queue size is zero. The receive() function call should not be interrupted when
      * the consumer queue size is zero.
      *
@@ -80,10 +83,9 @@ class ReaderConfiguration {
     void setReaderName(const std::string& readerName);
     const std::string& getReaderName() const;
 
- private:
+   private:
     boost::shared_ptr<ReaderConfigurationImpl> impl_;
 };
-
 }
 #pragma GCC visibility pop
 #endif /* PULSAR_READER_CONFIGURATION_H_ */
diff --git a/pulsar-client-cpp/include/pulsar/Result.h b/pulsar-client-cpp/include/pulsar/Result.h
index 2334b3594..0c53cbbc8 100644
--- a/pulsar-client-cpp/include/pulsar/Result.h
+++ b/pulsar-client-cpp/include/pulsar/Result.h
@@ -28,8 +28,9 @@ namespace pulsar {
 /**
  * Collection of return codes
  */
-enum Result {
-    ResultOk,            /// Operation successful
+enum Result
+{
+    ResultOk,  /// Operation successful
 
     ResultUnknownError,  /// Unknown error happened on broker
 
@@ -41,40 +42,40 @@ enum Result {
     ResultReadError,     /// Failed to read from socket
 
     ResultAuthenticationError,             /// Authentication failed on broker
-    ResultAuthorizationError,  /// Client is not authorized to create producer/consumer
+    ResultAuthorizationError,              /// Client is not authorized to create producer/consumer
     ResultErrorGettingAuthenticationData,  /// Client cannot find authorization data
 
     ResultBrokerMetadataError,     /// Broker failed in updating metadata
     ResultBrokerPersistenceError,  /// Broker failed to persist entry
     ResultChecksumError,           /// Corrupt message checksum failure
 
-    ResultConsumerBusy,  /// Exclusive consumer is already connected
-    ResultNotConnected,  /// Producer/Consumer is not currently connected to broker
+    ResultConsumerBusy,   /// Exclusive consumer is already connected
+    ResultNotConnected,   /// Producer/Consumer is not currently connected to broker
     ResultAlreadyClosed,  /// Producer/Consumer is already closed and not accepting any operation
 
     ResultInvalidMessage,  /// Error in publishing an already used message
 
-    ResultConsumerNotInitialized,  /// Consumer is not initialized
-    ResultProducerNotInitialized,  /// Producer is not initialized
-    ResultTooManyLookupRequestException, /// Too Many concurrent LookupRequest
+    ResultConsumerNotInitialized,         /// Consumer is not initialized
+    ResultProducerNotInitialized,         /// Producer is not initialized
+    ResultTooManyLookupRequestException,  /// Too Many concurrent LookupRequest
 
-    ResultInvalidTopicName,         /// Invalid topic name
+    ResultInvalidTopicName,  /// Invalid topic name
     ResultInvalidUrl,  /// Client Initialized with Invalid Broker Url (VIP Url passed to Client Constructor)
-    ResultServiceUnitNotReady,  /// Service Unit unloaded between client did lookup and producer/consumer got created
+    ResultServiceUnitNotReady,  /// Service Unit unloaded between client did lookup and producer/consumer got
+                                /// created
     ResultOperationNotSupported,
-    ResultProducerBlockedQuotaExceededError,     /// Producer is blocked
+    ResultProducerBlockedQuotaExceededError,      /// Producer is blocked
     ResultProducerBlockedQuotaExceededException,  /// Producer is getting exception
-    ResultProducerQueueIsFull, /// Producer queue is full
-    ResultMessageTooBig, /// Trying to send a messages exceeding the max size
-    ResultTopicNotFound, /// Topic not found
-    ResultSubscriptionNotFound, /// Subscription not found
-    ResultConsumerNotFound, /// Consumer not found
-    ResultUnsupportedVersionError /// Error when an older client/version doesn't support a required feature
+    ResultProducerQueueIsFull,                    /// Producer queue is full
+    ResultMessageTooBig,                          /// Trying to send a messages exceeding the max size
+    ResultTopicNotFound,                          /// Topic not found
+    ResultSubscriptionNotFound,                   /// Subscription not found
+    ResultConsumerNotFound,                       /// Consumer not found
+    ResultUnsupportedVersionError  /// Error when an older client/version doesn't support a required feature
 };
 
 // Return string representation of result code
 const char* strResult(Result result);
-
 }
 
 std::ostream& operator<<(std::ostream& s, pulsar::Result result);
diff --git a/pulsar-client-cpp/include/pulsar/TopicMetadata.h b/pulsar-client-cpp/include/pulsar/TopicMetadata.h
index d541ca9ec..5d67cc073 100644
--- a/pulsar-client-cpp/include/pulsar/TopicMetadata.h
+++ b/pulsar-client-cpp/include/pulsar/TopicMetadata.h
@@ -24,7 +24,7 @@ namespace pulsar {
  * Metadata of a topic that can be used for message routing.
  */
 class TopicMetadata {
-public:
+   public:
     virtual int getNumPartitions() const = 0;
 };
 }
diff --git a/pulsar-client-cpp/lib/Authentication.cc b/pulsar-client-cpp/lib/Authentication.cc
index 805d10074..e38a811ac 100644
--- a/pulsar-client-cpp/lib/Authentication.cc
+++ b/pulsar-client-cpp/lib/Authentication.cc
@@ -34,157 +34,128 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    AuthenticationDataProvider::AuthenticationDataProvider(){
+AuthenticationDataProvider::AuthenticationDataProvider() {}
 
-    }
+AuthenticationDataProvider::~AuthenticationDataProvider() {}
 
-    AuthenticationDataProvider::~AuthenticationDataProvider() {
+bool AuthenticationDataProvider::hasDataForTls() { return false; }
 
-    }
+std::string AuthenticationDataProvider::getTlsCertificates() { return "none"; }
 
-    bool AuthenticationDataProvider::hasDataForTls() {
-        return false;
-    }
+std::string AuthenticationDataProvider::getTlsPrivateKey() { return "none"; }
 
-    std::string AuthenticationDataProvider::getTlsCertificates() {
-        return "none";
-    }
+bool AuthenticationDataProvider::hasDataForHttp() { return false; }
 
-    std::string AuthenticationDataProvider::getTlsPrivateKey() {
-        return "none";
-    }
+std::string AuthenticationDataProvider::getHttpAuthType() { return "none"; }
 
-    bool AuthenticationDataProvider::hasDataForHttp() {
-        return false;
-    }
+std::string AuthenticationDataProvider::getHttpHeaders() { return "none"; }
 
-    std::string AuthenticationDataProvider::getHttpAuthType() {
-        return "none";
-    }
+bool AuthenticationDataProvider::hasDataFromCommand() { return false; }
 
-    std::string AuthenticationDataProvider::getHttpHeaders() {
-        return "none";
-    }
+std::string AuthenticationDataProvider::getCommandData() { return "none"; }
 
-    bool AuthenticationDataProvider::hasDataFromCommand(){
-        return false;
-    }
+Authentication::Authentication() {}
 
-    std::string AuthenticationDataProvider::getCommandData() {
-        return "none";
-    }
+Authentication::~Authentication() {}
 
+class AuthDisabledData : public AuthenticationDataProvider {
+   public:
+    AuthDisabledData(ParamMap& params) {}
+};
 
-    Authentication::Authentication() {
-    }
+class AuthDisabled : public Authentication {
+   public:
+    AuthDisabled(AuthenticationDataPtr& authData) { authData_ = authData; }
 
-    Authentication::~Authentication() {
+    static AuthenticationPtr create(ParamMap& params) {
+        AuthenticationDataPtr authData = AuthenticationDataPtr(new AuthDisabledData(params));
+        return AuthenticationPtr(new AuthDisabled(authData));
     }
 
-    class AuthDisabledData : public AuthenticationDataProvider {
-    public:
-        AuthDisabledData(ParamMap& params){
-        }
-    };
+    const std::string getAuthMethodName() const { return "none"; }
+};
 
-    class AuthDisabled : public Authentication {
-    public:
-        AuthDisabled(AuthenticationDataPtr& authData) {
-            authData_ = authData;
-        }
-
-        static AuthenticationPtr create(ParamMap& params) {
-            AuthenticationDataPtr authData = AuthenticationDataPtr(new AuthDisabledData(params));
-            return AuthenticationPtr(new AuthDisabled(authData));
-        }
-
-        const std::string getAuthMethodName() const {
-            return "none";
-        }
-    };
+AuthenticationPtr AuthFactory::Disabled() {
+    ParamMap params;
+    return AuthDisabled::create(params);
+}
 
+AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath) {
+    ParamMap params;
+    return AuthFactory::create(dynamicLibPath, params);
+}
 
-    AuthenticationPtr AuthFactory::Disabled() {
-        ParamMap params;
-        return AuthDisabled::create(params);
-    }
+boost::mutex mutex;
+std::vector<void*> AuthFactory::loadedLibrariesHandles_;
+bool AuthFactory::isShutdownHookRegistered_ = false;
 
-    AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath) {
-        ParamMap params;
-        return AuthFactory::create(dynamicLibPath, params);
+void AuthFactory::release_handles() {
+    boost::lock_guard<boost::mutex> lock(mutex);
+    for (std::vector<void*>::iterator ite = AuthFactory::loadedLibrariesHandles_.begin();
+         ite != AuthFactory::loadedLibrariesHandles_.end(); ite++) {
+        dlclose(*ite);
     }
+    loadedLibrariesHandles_.clear();
+}
 
-    boost::mutex mutex;
-    std::vector<void*> AuthFactory::loadedLibrariesHandles_;
-    bool AuthFactory::isShutdownHookRegistered_ = false;
-
-    void AuthFactory::release_handles() {
+AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath,
+                                      const std::string& authParamsString) {
+    {
         boost::lock_guard<boost::mutex> lock(mutex);
-        for (std::vector<void*>::iterator ite = AuthFactory::loadedLibrariesHandles_.begin(); ite != AuthFactory::loadedLibrariesHandles_.end();
-             ite++) {
-            dlclose(*ite);
+        if (!AuthFactory::isShutdownHookRegistered_) {
+            atexit(release_handles);
+            AuthFactory::isShutdownHookRegistered_ = true;
         }
-        loadedLibrariesHandles_.clear();
     }
-
-    AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath, const std::string& authParamsString) {
+    Authentication* auth = NULL;
+    void* handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
+    if (handle != NULL) {
         {
             boost::lock_guard<boost::mutex> lock(mutex);
-            if (!AuthFactory::isShutdownHookRegistered_) {
-                atexit(release_handles);
-                AuthFactory::isShutdownHookRegistered_ = true;
-            }
+            loadedLibrariesHandles_.push_back(handle);
         }
-        Authentication *auth = NULL;
-        void *handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
-        if (handle != NULL) {
-            {
-                boost::lock_guard<boost::mutex> lock(mutex);
-                loadedLibrariesHandles_.push_back(handle);
-            }
-            Authentication *(*createAuthentication)(const std::string&);
-            *(void **) (&createAuthentication) = dlsym(handle, "create");
-            if (createAuthentication != NULL) {
-                auth = createAuthentication(authParamsString);
-            } else {
-                ParamMap paramMap;
-                if(!authParamsString.empty()) {
-                    std::vector<std::string> params;
-                    boost::algorithm::split(params, authParamsString, boost::is_any_of(","));
-                    for(int i = 0; i<params.size(); i++) {
-                        std::vector<std::string> kv;
-                        boost::algorithm::split(kv, params[i], boost::is_any_of(":"));
-                        if (kv.size() == 2) {
-                            paramMap[kv[0]] = kv[1];
-                        }
+        Authentication* (*createAuthentication)(const std::string&);
+        *(void**)(&createAuthentication) = dlsym(handle, "create");
+        if (createAuthentication != NULL) {
+            auth = createAuthentication(authParamsString);
+        } else {
+            ParamMap paramMap;
+            if (!authParamsString.empty()) {
+                std::vector<std::string> params;
+                boost::algorithm::split(params, authParamsString, boost::is_any_of(","));
+                for (int i = 0; i < params.size(); i++) {
+                    std::vector<std::string> kv;
+                    boost::algorithm::split(kv, params[i], boost::is_any_of(":"));
+                    if (kv.size() == 2) {
+                        paramMap[kv[0]] = kv[1];
                     }
                 }
-                return AuthFactory::create(dynamicLibPath, paramMap);
             }
+            return AuthFactory::create(dynamicLibPath, paramMap);
         }
-        return AuthenticationPtr(auth);
     }
+    return AuthenticationPtr(auth);
+}
 
-    AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath, ParamMap& params) {
-        {
-            boost::lock_guard<boost::mutex> lock(mutex);
-            if (!AuthFactory::isShutdownHookRegistered_) {
-                atexit(release_handles);
-                AuthFactory::isShutdownHookRegistered_ = true;
-            }
+AuthenticationPtr AuthFactory::create(const std::string& dynamicLibPath, ParamMap& params) {
+    {
+        boost::lock_guard<boost::mutex> lock(mutex);
+        if (!AuthFactory::isShutdownHookRegistered_) {
+            atexit(release_handles);
+            AuthFactory::isShutdownHookRegistered_ = true;
         }
-        Authentication *auth = NULL;
-        void *handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
-        if (handle != NULL) {
-            boost::lock_guard<boost::mutex> lock(mutex);
-            loadedLibrariesHandles_.push_back(handle);
-            Authentication *(*createAuthentication)(ParamMap&);
-            *(void **) (&createAuthentication) = dlsym(handle, "createFromMap");
-            if (createAuthentication != NULL) {
-                auth = createAuthentication(params);
-            }
+    }
+    Authentication* auth = NULL;
+    void* handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
+    if (handle != NULL) {
+        boost::lock_guard<boost::mutex> lock(mutex);
+        loadedLibrariesHandles_.push_back(handle);
+        Authentication* (*createAuthentication)(ParamMap&);
+        *(void**)(&createAuthentication) = dlsym(handle, "createFromMap");
+        if (createAuthentication != NULL) {
+            auth = createAuthentication(params);
         }
-        return AuthenticationPtr(auth);
     }
-
+    return AuthenticationPtr(auth);
+}
 }
diff --git a/pulsar-client-cpp/lib/Backoff.cc b/pulsar-client-cpp/lib/Backoff.cc
index aba88f5fb..76ca99bf9 100644
--- a/pulsar-client-cpp/lib/Backoff.cc
+++ b/pulsar-client-cpp/lib/Backoff.cc
@@ -21,13 +21,12 @@
 namespace pulsar {
 
 Backoff::Backoff(const TimeDuration& initial, const TimeDuration& max, const TimeDuration& mandatoryStop)
-        : initial_(initial),
-          max_(max),
-          next_(initial),
-          mandatoryStopMade_(false),
-          mandatoryStop_(mandatoryStop),
-          randomSeed_(time(NULL)) {
-}
+    : initial_(initial),
+      max_(max),
+      next_(initial),
+      mandatoryStopMade_(false),
+      mandatoryStop_(mandatoryStop),
+      randomSeed_(time(NULL)) {}
 
 TimeDuration Backoff::next() {
     TimeDuration current = next_;
@@ -57,4 +56,4 @@ void Backoff::reset() {
     mandatoryStopMade_ = false;
 }
 
-}  //pulsar - namespace end
+}  // pulsar - namespace end
diff --git a/pulsar-client-cpp/lib/Backoff.h b/pulsar-client-cpp/lib/Backoff.h
index d06b84d88..65b65c07d 100644
--- a/pulsar-client-cpp/lib/Backoff.h
+++ b/pulsar-client-cpp/lib/Backoff.h
@@ -16,12 +16,12 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-#ifndef  _PULSAR_BACKOFF_HEADER_
+#ifndef _PULSAR_BACKOFF_HEADER_
 #define _PULSAR_BACKOFF_HEADER_
 #include <boost/date_time/posix_time/posix_time.hpp>
-#include <stdlib.h>     /* srand, rand */
+#include <stdlib.h> /* srand, rand */
 #include <algorithm>
-#include <time.h>       /* time */
+#include <time.h> /* time */
 
 #pragma GCC visibility push(default)
 
@@ -30,11 +30,12 @@ namespace pulsar {
 typedef boost::posix_time::time_duration TimeDuration;
 
 class Backoff {
- public:
+   public:
     Backoff(const TimeDuration&, const TimeDuration&, const TimeDuration&);
     TimeDuration next();
     void reset();
- private:
+
+   private:
     const TimeDuration initial_;
     const TimeDuration max_;
     TimeDuration next_;
diff --git a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
index bcc25d76b..04485843d 100644
--- a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
+++ b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.cc
@@ -21,12 +21,13 @@
 namespace pulsar {
 DECLARE_LOG_OBJECT()
 
-BatchAcknowledgementTracker::BatchAcknowledgementTracker(const std::string topic, const std::string subscription,
-                               const long consumerId)
-        : greatestCumulativeAckSent_(BatchMessageId()) {
+BatchAcknowledgementTracker::BatchAcknowledgementTracker(const std::string topic,
+                                                         const std::string subscription,
+                                                         const long consumerId)
+    : greatestCumulativeAckSent_(BatchMessageId()) {
     std::stringstream consumerStrStream;
-    consumerStrStream << "BatchAcknowledgementTracker for [" << topic << ", " << subscription
-                      << ", " << consumerId << "] ";
+    consumerStrStream << "BatchAcknowledgementTracker for [" << topic << ", " << subscription << ", "
+                      << consumerId << "] ";
     name_ = consumerStrStream.str();
     LOG_DEBUG(name_ << "Constructed BatchAcknowledgementTracker");
 }
@@ -46,14 +47,17 @@ void BatchAcknowledgementTracker::receivedMessage(const Message& message) {
 
     // ignore message if it is less than the last cumulative ack sent or messageID is already being tracked
     TrackerMap::iterator pos = trackerMap_.find(msgID);
-    if (msgID < greatestCumulativeAckSent_ || pos != trackerMap_.end()
-            || std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
+    if (msgID < greatestCumulativeAckSent_ || pos != trackerMap_.end() ||
+        std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
         return;
     }
     LOG_DEBUG("Initializing the trackerMap_ with Message ID = " << msgID);
 
-    // Since dynamic_set (this version) doesn't have all() function, initializing all bits with 1 and then reseting them to 0 and using any()
-    trackerMap_.insert(pos, TrackerPair(msgID, boost::dynamic_bitset<>(message.impl_->metadata.num_messages_in_batch()).set()));
+    // Since dynamic_set (this version) doesn't have all() function, initializing all bits with 1 and then
+    // reseting them to 0 and using any()
+    trackerMap_.insert(
+        pos,
+        TrackerPair(msgID, boost::dynamic_bitset<>(message.impl_->metadata.num_messages_in_batch()).set()));
 }
 
 void BatchAcknowledgementTracker::deleteAckedMessage(const BatchMessageId& messageId,
@@ -78,36 +82,36 @@ void BatchAcknowledgementTracker::deleteAckedMessage(const BatchMessageId& messa
             }
         }
 
-        // std::remove shifts all to be deleted items to the end of the vector and returns an iterator to the first
+        // std::remove shifts all to be deleted items to the end of the vector and returns an iterator to the
+        // first
         // instance of item, then we erase all elements from this iterator to the end of the list
-        sendList_.erase(
-                std::remove_if(sendList_.begin(), sendList_.end(), SendRemoveCriteria(messageId)),
-                sendList_.end());
+        sendList_.erase(std::remove_if(sendList_.begin(), sendList_.end(), SendRemoveCriteria(messageId)),
+                        sendList_.end());
 
         if (greatestCumulativeAckSent_ < messageId) {
             greatestCumulativeAckSent_ = messageId;
-            LOG_DEBUG(
-                    *this << " The greatestCumulativeAckSent_ is now " << greatestCumulativeAckSent_);
+            LOG_DEBUG(*this << " The greatestCumulativeAckSent_ is now " << greatestCumulativeAckSent_);
         }
     } else {
         // Error - if it is a batch message and found in trackerMap_
         if (trackerMap_.find(messageId) != trackerMap_.end()) {
-            LOG_ERROR(
-                    *this << " - This should not happened - Message should have been removed from trakerMap_ and moved to sendList_ " << messageId);
+            LOG_ERROR(*this << " - This should not happened - Message should have been removed from "
+                               "trakerMap_ and moved to sendList_ "
+                            << messageId);
         }
 
-        sendList_.erase(std::remove(sendList_.begin(), sendList_.end(), messageId),
-                        sendList_.end());
+        sendList_.erase(std::remove(sendList_.begin(), sendList_.end(), messageId), sendList_.end());
     }
 }
 
-bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID, const proto::CommandAck_AckType ackType) {
+bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID,
+                                               const proto::CommandAck_AckType ackType) {
     Lock lock(mutex_);
     TrackerMap::iterator pos = trackerMap_.find(msgID);
-    if (pos == trackerMap_.end() ||
-            std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
+    if (pos == trackerMap_.end() || std::find(sendList_.begin(), sendList_.end(), msgID) != sendList_.end()) {
         LOG_DEBUG(
-                "Batch is ready since message present in sendList_ or not present in trackerMap_ [message ID = " << msgID << "]");
+            "Batch is ready since message present in sendList_ or not present in trackerMap_ [message ID = "
+            << msgID << "]");
         return true;
     }
 
@@ -126,8 +130,8 @@ bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID, cons
     }
     sendList_.push_back(msgID);
     trackerMap_.erase(pos);
-    LOG_DEBUG(
-            "Batch is ready since message all bits are reset in trackerMap_ [message ID = " << msgID << "]");
+    LOG_DEBUG("Batch is ready since message all bits are reset in trackerMap_ [message ID = " << msgID
+                                                                                              << "]");
     return true;
 }
 
@@ -135,7 +139,7 @@ bool BatchAcknowledgementTracker::isBatchReady(const BatchMessageId& msgID, cons
 // - a batch message id < messageId
 // - same messageId if it is the last message in the batch
 const BatchMessageId BatchAcknowledgementTracker::getGreatestCumulativeAckReady(
-        const BatchMessageId& messageId) {
+    const BatchMessageId& messageId) {
     Lock lock(mutex_);
     BatchMessageId messageReadyForCumulativeAck = BatchMessageId();
     TrackerMap::iterator pos = trackerMap_.find(messageId);
@@ -145,7 +149,6 @@ const BatchMessageId BatchAcknowledgementTracker::getGreatestCumulativeAckReady(
         return BatchMessageId();
     }
 
-
     if (pos->second.size() - 1 != messageId.batchIndex_) {
         // Can't cumulatively ack this batch message
         if (pos == trackerMap_.begin()) {
@@ -157,5 +160,4 @@ const BatchMessageId BatchAcknowledgementTracker::getGreatestCumulativeAckReady(
 
     return pos->first;
 }
-
 }
diff --git a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h
index 8734ab242..1bf426ebd 100644
--- a/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h
+++ b/pulsar-client-cpp/lib/BatchAcknowledgementTracker.h
@@ -29,12 +29,12 @@
 #include "LogUtils.h"
 #include <string>
 #include <sstream>
-namespace pulsar{
+namespace pulsar {
 
 class ConsumerImpl;
 
 class BatchAcknowledgementTracker {
- private:
+   private:
     typedef boost::unique_lock<boost::mutex> Lock;
     typedef std::pair<BatchMessageId, boost::dynamic_bitset<> > TrackerPair;
     typedef std::map<BatchMessageId, boost::dynamic_bitset<> > TrackerMap;
@@ -42,17 +42,21 @@ class BatchAcknowledgementTracker {
 
     TrackerMap trackerMap_;
 
-    // SendList is used to reduce the time required to go over the dynamic_bitset and check if the entire batch is acked.
-    // It is useful in cases where the entire batch is acked but cnx is broken. In this case when any of the batch index
-    // is acked again, we just check the sendList to verify that the batch is acked w/o iterating over the dynamic_bitset.
+    // SendList is used to reduce the time required to go over the dynamic_bitset and check if the entire
+    // batch is acked.
+    // It is useful in cases where the entire batch is acked but cnx is broken. In this case when any of the
+    // batch index
+    // is acked again, we just check the sendList to verify that the batch is acked w/o iterating over the
+    // dynamic_bitset.
     std::vector<BatchMessageId> sendList_;
 
     // we don't need to track MessageId < greatestCumulativeAckReceived
     BatchMessageId greatestCumulativeAckSent_;
     std::string name_;
 
- public:
-    BatchAcknowledgementTracker(const std::string topic, const std::string subscription, const long consumerId);
+   public:
+    BatchAcknowledgementTracker(const std::string topic, const std::string subscription,
+                                const long consumerId);
 
     bool isBatchReady(const BatchMessageId& msgID, const proto::CommandAck_AckType ackType);
     const BatchMessageId getGreatestCumulativeAckReady(const BatchMessageId& messageId);
@@ -62,47 +66,40 @@ class BatchAcknowledgementTracker {
 
     void clear();
 
-    inline friend std::ostream& operator<<(std::ostream& os, const BatchAcknowledgementTracker& batchAcknowledgementTracker);
+    inline friend std::ostream& operator<<(std::ostream& os,
+                                           const BatchAcknowledgementTracker& batchAcknowledgementTracker);
 
     // Used for Cumulative acks only
     struct SendRemoveCriteria {
-        private:
+       private:
         const BatchMessageId& messageId_;
 
-        public:
-        SendRemoveCriteria(const BatchMessageId& messageId)
-            : messageId_(messageId) {}
+       public:
+        SendRemoveCriteria(const BatchMessageId& messageId) : messageId_(messageId) {}
 
-        bool operator()(const BatchMessageId &element) const {
-            return (element <= messageId_);
-        }
+        bool operator()(const BatchMessageId& element) const { return (element <= messageId_); }
     };
 
     // Used for Cumulative acks only
     struct TrackerMapRemoveCriteria {
-        private:
+       private:
         const BatchMessageId& messageId_;
 
-        public:
-        TrackerMapRemoveCriteria(const BatchMessageId& messageId)
-            : messageId_(messageId) {}
+       public:
+        TrackerMapRemoveCriteria(const BatchMessageId& messageId) : messageId_(messageId) {}
 
-        bool operator()(std::pair<const pulsar::BatchMessageId, boost::dynamic_bitset<> > &element) const {
+        bool operator()(std::pair<const pulsar::BatchMessageId, boost::dynamic_bitset<> >& element) const {
             return (element.first <= messageId_);
         }
     };
-
 };
 
-std::ostream& operator<<(std::ostream& os,
-                         const BatchAcknowledgementTracker& batchAcknowledgementTracker) {
-    os << "{ " <<  batchAcknowledgementTracker.name_
-            << " [greatestCumulativeAckReceived_-"
-            << batchAcknowledgementTracker.greatestCumulativeAckSent_ << "] [trackerMap size = "
-            << batchAcknowledgementTracker.trackerMap_.size() << " ]}";
+std::ostream& operator<<(std::ostream& os, const BatchAcknowledgementTracker& batchAcknowledgementTracker) {
+    os << "{ " << batchAcknowledgementTracker.name_ << " [greatestCumulativeAckReceived_-"
+       << batchAcknowledgementTracker.greatestCumulativeAckSent_
+       << "] [trackerMap size = " << batchAcknowledgementTracker.trackerMap_.size() << " ]}";
     return os;
 }
-
 }
 
 #endif /* LIB_BATCHACKNOWLEDGEMENTTRACKER_H_ */
diff --git a/pulsar-client-cpp/lib/BatchMessageContainer.cc b/pulsar-client-cpp/lib/BatchMessageContainer.cc
index ed108e93c..847e70ae6 100644
--- a/pulsar-client-cpp/lib/BatchMessageContainer.cc
+++ b/pulsar-client-cpp/lib/BatchMessageContainer.cc
@@ -25,27 +25,28 @@ static ObjectPool<BatchMessageContainer::MessageContainerList, 1000> messageCont
 DECLARE_LOG_OBJECT()
 
 BatchMessageContainer::BatchMessageContainer(ProducerImpl& producer)
-        : maxAllowedNumMessagesInBatch_(producer.conf_.getBatchingMaxMessages()),
-          maxAllowedMessageBatchSizeInBytes_(producer.conf_.getBatchingMaxAllowedSizeInBytes()),
-          topicName_(producer.topic_),
-          producerName_(producer.producerName_),
-          compressionType_(producer.conf_.getCompressionType()),
-          producer_(producer),
-          impl_(messagePool.create()),
-          timer_(producer.executor_->createDeadlineTimer()),
-          batchSizeInBytes_(0),
-          messagesContainerListPtr_(messageContainerListPool.create()),
-          averageBatchSize_(0),
-          numberOfBatchesSent_(0) {
+    : maxAllowedNumMessagesInBatch_(producer.conf_.getBatchingMaxMessages()),
+      maxAllowedMessageBatchSizeInBytes_(producer.conf_.getBatchingMaxAllowedSizeInBytes()),
+      topicName_(producer.topic_),
+      producerName_(producer.producerName_),
+      compressionType_(producer.conf_.getCompressionType()),
+      producer_(producer),
+      impl_(messagePool.create()),
+      timer_(producer.executor_->createDeadlineTimer()),
+      batchSizeInBytes_(0),
+      messagesContainerListPtr_(messageContainerListPool.create()),
+      averageBatchSize_(0),
+      numberOfBatchesSent_(0) {
     messagesContainerListPtr_->reserve(1000);
     LOG_INFO(*this << " BatchMessageContainer constructed");
 }
 
 void BatchMessageContainer::add(const Message& msg, SendCallback sendCallback, bool disableCheck) {
     // disableCheck is needed to avoid recursion in case the batchSizeInKB < IndividualMessageSizeInKB
-    LOG_DEBUG(*this << " Called add function for [message = " << msg << "] [disableCheck = "<<disableCheck << "]");
-    if ( !(disableCheck || hasSpaceInBatch(msg))) {
-        LOG_DEBUG(*this << " Batch is full" );
+    LOG_DEBUG(*this << " Called add function for [message = " << msg << "] [disableCheck = " << disableCheck
+                    << "]");
+    if (!(disableCheck || hasSpaceInBatch(msg))) {
+        LOG_DEBUG(*this << " Batch is full");
         sendMessage();
         add(msg, sendCallback, true);
         return;
@@ -59,9 +60,10 @@ void BatchMessageContainer::add(const Message& msg, SendCallback sendCallback, b
     }
     batchSizeInBytes_ += msg.impl_->payload.readableBytes();
 
-    LOG_DEBUG(*this << " Before serialization payload size in bytes = " <<impl_->payload.readableBytes());
-    Commands::serializeSingleMessageInBatchWithPayload(msg, impl_->payload, maxAllowedMessageBatchSizeInBytes_);
-    LOG_DEBUG(*this << " After serialization payload size in bytes = "<< impl_->payload.readableBytes());
+    LOG_DEBUG(*this << " Before serialization payload size in bytes = " << impl_->payload.readableBytes());
+    Commands::serializeSingleMessageInBatchWithPayload(msg, impl_->payload,
+                                                       maxAllowedMessageBatchSizeInBytes_);
+    LOG_DEBUG(*this << " After serialization payload size in bytes = " << impl_->payload.readableBytes());
 
     messagesContainerListPtr_->push_back(MessageContainer(msg, sendCallback));
 
@@ -77,9 +79,8 @@ void BatchMessageContainer::startTimer() {
     const unsigned long& publishDelayInMs = producer_.conf_.getBatchingMaxPublishDelayMs();
     LOG_DEBUG(*this << " Timer started with expiry after " << publishDelayInMs);
     timer_->expires_from_now(boost::posix_time::milliseconds(publishDelayInMs));
-    timer_->async_wait(
-            boost::bind(&pulsar::ProducerImpl::batchMessageTimeoutHandler, &producer_,
-                        boost::asio::placeholders::error));
+    timer_->async_wait(boost::bind(&pulsar::ProducerImpl::batchMessageTimeoutHandler, &producer_,
+                                   boost::asio::placeholders::error));
 }
 
 void BatchMessageContainer::sendMessage() {
@@ -96,30 +97,28 @@ void BatchMessageContainer::sendMessage() {
     msg.impl_ = impl_;
 
     // bind keeps a copy of the parameters
-    SendCallback callback = boost::bind(&BatchMessageContainer::batchMessageCallBack, _1, messagesContainerListPtr_);
+    SendCallback callback =
+        boost::bind(&BatchMessageContainer::batchMessageCallBack, _1, messagesContainerListPtr_);
 
     producer_.sendMessage(msg, callback);
     clear();
 }
 
 void BatchMessageContainer::compressPayLoad() {
-
     if (compressionType_ != CompressionNone) {
-        impl_->metadata.set_compression(
-                CompressionCodecProvider::convertType(compressionType_));
+        impl_->metadata.set_compression(CompressionCodecProvider::convertType(compressionType_));
         impl_->metadata.set_uncompressed_size(impl_->payload.readableBytes());
     }
     impl_->payload = CompressionCodecProvider::getCodec(compressionType_).encode(impl_->payload);
 }
 
-SharedBuffer BatchMessageContainer::getBatchedPayload() {
-    return impl_->payload;
-}
+SharedBuffer BatchMessageContainer::getBatchedPayload() { return impl_->payload; }
 
 void BatchMessageContainer::clear() {
     LOG_DEBUG(*this << " BatchMessageContainer::clear() called");
     timer_->cancel();
-    averageBatchSize_ = (messagesContainerListPtr_->size() + (averageBatchSize_ * numberOfBatchesSent_))/(numberOfBatchesSent_ + 1);
+    averageBatchSize_ = (messagesContainerListPtr_->size() + (averageBatchSize_ * numberOfBatchesSent_)) /
+                        (numberOfBatchesSent_ + 1);
     numberOfBatchesSent_++;
     messagesContainerListPtr_ = messageContainerListPool.create();
     // Try to optimize this
@@ -132,8 +131,10 @@ void BatchMessageContainer::batchMessageCallBack(Result r, MessageContainerListP
     if (!messagesContainerListPtr) {
         return;
     }
-    LOG_DEBUG("BatchMessageContainer::batchMessageCallBack called with [Result = " << r << "] [numOfMessages = " << messagesContainerListPtr->size() << "]");
-    for(MessageContainerList::iterator iter = messagesContainerListPtr->begin(); iter != messagesContainerListPtr->end(); iter++) {
+    LOG_DEBUG("BatchMessageContainer::batchMessageCallBack called with [Result = "
+              << r << "] [numOfMessages = " << messagesContainerListPtr->size() << "]");
+    for (MessageContainerList::iterator iter = messagesContainerListPtr->begin();
+         iter != messagesContainerListPtr->end(); iter++) {
         // callback(result, message)
         iter->sendCallback_(r, iter->message_);
     }
@@ -143,6 +144,6 @@ BatchMessageContainer::~BatchMessageContainer() {
     timer_->cancel();
     LOG_DEBUG(*this << " BatchMessageContainer Object destructed");
     LOG_INFO("[numberOfBatchesSent = " << numberOfBatchesSent_
-    << "] [averageBatchSize = " << averageBatchSize_ << "]");
+                                       << "] [averageBatchSize = " << averageBatchSize_ << "]");
 }
 }
diff --git a/pulsar-client-cpp/lib/BatchMessageContainer.h b/pulsar-client-cpp/lib/BatchMessageContainer.h
index bf7a6aace..d0c4dfd31 100644
--- a/pulsar-client-cpp/lib/BatchMessageContainer.h
+++ b/pulsar-client-cpp/lib/BatchMessageContainer.h
@@ -19,7 +19,8 @@
 /*
  * \class BatchMessageContainer
  *
- * \brief This class is a container for holding individual messages being published until they are batched and sent to broker.
+ * \brief This class is a container for holding individual messages being published until they are batched and
+ * sent to broker.
  *
  * \note This class is not thread safe.
  */
@@ -43,13 +44,10 @@
 namespace pulsar {
 
 class BatchMessageContainer {
- public:
-
+   public:
     struct MessageContainer {
         MessageContainer(Message message, SendCallback sendCallback)
-        : message_(message),
-          sendCallback_(sendCallback) {
-        }
+            : message_(message), sendCallback_(sendCallback) {}
         Message message_;
         SendCallback sendCallback_;
     };
@@ -68,10 +66,11 @@ class BatchMessageContainer {
 
     static void batchMessageCallBack(Result r, MessageContainerListPtr messages);
 
-    friend inline std::ostream& operator<<(std::ostream& os, const BatchMessageContainer& batchMessageContainer);
+    friend inline std::ostream& operator<<(std::ostream& os,
+                                           const BatchMessageContainer& batchMessageContainer);
     friend class ProducerImpl;
 
- private:
+   private:
     const CompressionType compressionType_;
 
     const unsigned int maxAllowedNumMessagesInBatch_;
@@ -86,7 +85,8 @@ class BatchMessageContainer {
 
     Message::MessageImplPtr impl_;
 
-    // This copy (to vector) is needed since OpSendMsg no long holds the individual message and w/o a container
+    // This copy (to vector) is needed since OpSendMsg no long holds the individual message and w/o a
+    // container
     // the impl_ Shared Pointer will delete the data.
     MessageContainerListPtr messagesContainerListPtr_;
 
@@ -94,7 +94,6 @@ class BatchMessageContainer {
 
     DeadlineTimerPtr timer_;
 
-
     unsigned long numberOfBatchesSent_;
 
     double averageBatchSize_;
@@ -113,30 +112,28 @@ class BatchMessageContainer {
 };
 
 bool BatchMessageContainer::hasSpaceInBatch(const Message& msg) const {
-    return (msg.impl_->payload.readableBytes() + this->batchSizeInBytes_
-            <= this->maxAllowedMessageBatchSizeInBytes_)
-            && (this->messagesContainerListPtr_->size() < this->maxAllowedNumMessagesInBatch_);
+    return (msg.impl_->payload.readableBytes() + this->batchSizeInBytes_ <=
+            this->maxAllowedMessageBatchSizeInBytes_) &&
+           (this->messagesContainerListPtr_->size() < this->maxAllowedNumMessagesInBatch_);
 }
 
-bool BatchMessageContainer::isEmpty() const {
-    return this->messagesContainerListPtr_->empty();
-}
+bool BatchMessageContainer::isEmpty() const { return this->messagesContainerListPtr_->empty(); }
 
 bool BatchMessageContainer::isFull() const {
-    return (this->batchSizeInBytes_ >= this->maxAllowedMessageBatchSizeInBytes_
-            || this->messagesContainerListPtr_->size() >= this->maxAllowedNumMessagesInBatch_);
+    return (this->batchSizeInBytes_ >= this->maxAllowedMessageBatchSizeInBytes_ ||
+            this->messagesContainerListPtr_->size() >= this->maxAllowedNumMessagesInBatch_);
 }
 
 std::ostream& operator<<(std::ostream& os, const BatchMessageContainer& b) {
-    os << "{ BatchContainer [size = " << b.messagesContainerListPtr_->size() << "] [batchSizeInBytes_ = "
-            << b.batchSizeInBytes_ << "] [maxAllowedMessageBatchSizeInBytes_ = "
-            << b.maxAllowedMessageBatchSizeInBytes_ << "] [maxAllowedNumMessagesInBatch_ = "
-            << b.maxAllowedNumMessagesInBatch_ << "] [topicName = " << b.topicName_
-            << "] [producerName_ = " << b.producerName_ << "] [batchSizeInBytes_ = "
-            << b.batchSizeInBytes_ << "] [numberOfBatchesSent = " << b.numberOfBatchesSent_
-            << "] [averageBatchSize = " << b.averageBatchSize_ << "]}";
+    os << "{ BatchContainer [size = " << b.messagesContainerListPtr_->size()
+       << "] [batchSizeInBytes_ = " << b.batchSizeInBytes_
+       << "] [maxAllowedMessageBatchSizeInBytes_ = " << b.maxAllowedMessageBatchSizeInBytes_
+       << "] [maxAllowedNumMessagesInBatch_ = " << b.maxAllowedNumMessagesInBatch_
+       << "] [topicName = " << b.topicName_ << "] [producerName_ = " << b.producerName_
+       << "] [batchSizeInBytes_ = " << b.batchSizeInBytes_
+       << "] [numberOfBatchesSent = " << b.numberOfBatchesSent_
+       << "] [averageBatchSize = " << b.averageBatchSize_ << "]}";
     return os;
 }
-
 }
 #endif /* LIB_BATCHMESSAGECONTAINER_H_ */
diff --git a/pulsar-client-cpp/lib/BatchMessageId.cc b/pulsar-client-cpp/lib/BatchMessageId.cc
index 76498188d..5a78725ba 100644
--- a/pulsar-client-cpp/lib/BatchMessageId.cc
+++ b/pulsar-client-cpp/lib/BatchMessageId.cc
@@ -26,9 +26,8 @@
 
 namespace pulsar {
 
-BatchMessageId::BatchMessageId(const MessageId& msgId) :
-        MessageId(msgId.ledgerId_, msgId.entryId_), batchIndex_(msgId.getBatchIndex()) {
-}
+BatchMessageId::BatchMessageId(const MessageId& msgId)
+    : MessageId(msgId.ledgerId_, msgId.entryId_), batchIndex_(msgId.getBatchIndex()) {}
 
 void BatchMessageId::serialize(std::string& result) const {
     proto::MessageIdData idData;
@@ -43,9 +42,7 @@ void BatchMessageId::serialize(std::string& result) const {
     idData.SerializeToString(&result);
 }
 
-int64_t BatchMessageId::getBatchIndex() const {
-    return batchIndex_;
-}
+int64_t BatchMessageId::getBatchIndex() const { return batchIndex_; }
 
 #pragma GCC visibility push(default)
 
@@ -63,21 +60,17 @@ bool BatchMessageId::operator<(const BatchMessageId& other) const {
     }
 }
 
-bool BatchMessageId::operator<=(const BatchMessageId& other) const {
-    return *this < other || *this == other;
-}
+bool BatchMessageId::operator<=(const BatchMessageId& other) const { return *this < other || *this == other; }
 
 bool BatchMessageId::operator==(const BatchMessageId& other) const {
-    return ledgerId_ == other.ledgerId_ && entryId_ == other.entryId_
-            && batchIndex_ == other.batchIndex_;
+    return ledgerId_ == other.ledgerId_ && entryId_ == other.entryId_ && batchIndex_ == other.batchIndex_;
 }
 
 std::ostream& operator<<(std::ostream& s, const BatchMessageId& messageId) {
-    s << '(' << messageId.ledgerId_ << ':' << messageId.entryId_ << ':' << messageId.batchIndex_
-      << ':' << messageId.partition_ << ')';
+    s << '(' << messageId.ledgerId_ << ':' << messageId.entryId_ << ':' << messageId.batchIndex_ << ':'
+      << messageId.partition_ << ')';
     return s;
 }
 
 #pragma GCC visibility pop
-
 }
diff --git a/pulsar-client-cpp/lib/BinaryProtoLookupService.cc b/pulsar-client-cpp/lib/BinaryProtoLookupService.cc
index 156c65b70..b5fe150b7 100644
--- a/pulsar-client-cpp/lib/BinaryProtoLookupService.cc
+++ b/pulsar-client-cpp/lib/BinaryProtoLookupService.cc
@@ -30,112 +30,125 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    /*
-     * @param lookupUrl service url to do lookup
-     * Constructor
-     */
-    BinaryProtoLookupService::BinaryProtoLookupService(ConnectionPool& cnxPool, const std::string& lookupUrl)
-    :
-    cnxPool_(cnxPool),
-    serviceUrl_(lookupUrl),
-    mutex_(),
-    requestIdGenerator_(0) {}
+/*
+ * @param lookupUrl service url to do lookup
+ * Constructor
+ */
+BinaryProtoLookupService::BinaryProtoLookupService(ConnectionPool& cnxPool, const std::string& lookupUrl)
+    : cnxPool_(cnxPool), serviceUrl_(lookupUrl), mutex_(), requestIdGenerator_(0) {}
 
-    /*
-     * @param destination_name topic name to get broker for
-     *
-     * Looks up the owner broker for the given destination name
-     */
-    Future<Result, LookupDataResultPtr> BinaryProtoLookupService::lookupAsync(const std::string& destinationName) {
-        DestinationNamePtr dn = DestinationName::get(destinationName);
-        if (!dn) {
-            LOG_ERROR("Unable to parse destination - " << destinationName);
-            LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
-            promise->setFailed(ResultInvalidTopicName);
-            return promise->getFuture();
-        }
-        std::string lookupName = dn->toString();
+/*
+ * @param destination_name topic name to get broker for
+ *
+ * Looks up the owner broker for the given destination name
+ */
+Future<Result, LookupDataResultPtr> BinaryProtoLookupService::lookupAsync(
+    const std::string& destinationName) {
+    DestinationNamePtr dn = DestinationName::get(destinationName);
+    if (!dn) {
+        LOG_ERROR("Unable to parse destination - " << destinationName);
         LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
-        Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
-        future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this, lookupName, false, _1, _2, promise));
+        promise->setFailed(ResultInvalidTopicName);
         return promise->getFuture();
     }
+    std::string lookupName = dn->toString();
+    LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
+    Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
+    future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this, lookupName, false,
+                                   _1, _2, promise));
+    return promise->getFuture();
+}
 
-    /*
-     * @param    destination_name topic to get number of partitions.
-     *
-     */
-    Future<Result, LookupDataResultPtr> BinaryProtoLookupService::getPartitionMetadataAsync(const DestinationNamePtr& dn) {
-        LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
-        if (!dn) {
-            promise->setFailed(ResultInvalidTopicName);
-            return promise->getFuture();
-        }
-        std::string lookupName = dn->toString();
-        Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
-        future.addListener(boost::bind(&BinaryProtoLookupService::sendPartitionMetadataLookupRequest, this, lookupName, _1, _2, promise));
+/*
+ * @param    destination_name topic to get number of partitions.
+ *
+ */
+Future<Result, LookupDataResultPtr> BinaryProtoLookupService::getPartitionMetadataAsync(
+    const DestinationNamePtr& dn) {
+    LookupDataResultPromisePtr promise = boost::make_shared<LookupDataResultPromise>();
+    if (!dn) {
+        promise->setFailed(ResultInvalidTopicName);
         return promise->getFuture();
     }
+    std::string lookupName = dn->toString();
+    Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(serviceUrl_);
+    future.addListener(boost::bind(&BinaryProtoLookupService::sendPartitionMetadataLookupRequest, this,
+                                   lookupName, _1, _2, promise));
+    return promise->getFuture();
+}
 
-
-    void BinaryProtoLookupService::sendTopicLookupRequest(const std::string& destinationName, bool authoritative, Result result, const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise) {
-        if (result != ResultOk) {
-            promise->setFailed(ResultConnectError);
-            return;
-        }
-        LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
-        ClientConnectionPtr conn = clientCnx.lock();
-        uint64_t requestId = newRequestId();
-        conn->newTopicLookup(destinationName, authoritative, requestId, lookupPromise);
-        lookupPromise->getFuture().addListener(boost::bind(&BinaryProtoLookupService::handleLookup, this, destinationName, _1, _2, clientCnx, promise));
+void BinaryProtoLookupService::sendTopicLookupRequest(const std::string& destinationName, bool authoritative,
+                                                      Result result, const ClientConnectionWeakPtr& clientCnx,
+                                                      LookupDataResultPromisePtr promise) {
+    if (result != ResultOk) {
+        promise->setFailed(ResultConnectError);
+        return;
     }
+    LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
+    ClientConnectionPtr conn = clientCnx.lock();
+    uint64_t requestId = newRequestId();
+    conn->newTopicLookup(destinationName, authoritative, requestId, lookupPromise);
+    lookupPromise->getFuture().addListener(boost::bind(&BinaryProtoLookupService::handleLookup, this,
+                                                       destinationName, _1, _2, clientCnx, promise));
+}
 
-    void BinaryProtoLookupService::handleLookup(const std::string& destinationName,
-            Result result, LookupDataResultPtr data, const ClientConnectionWeakPtr& clientCnx,
-            LookupDataResultPromisePtr promise) {
-        if (data) {
-            if(data ->isRedirect()) {
-                LOG_DEBUG("Lookup request is for " << destinationName << " redirected to " << data->getBrokerUrl());
-                Future<Result, ClientConnectionWeakPtr> future = cnxPool_.getConnectionAsync(data->getBrokerUrl());
-                future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this, destinationName, data->isAuthoritative(), _1, _2, promise));
-            } else {
-                LOG_DEBUG("Lookup response for " << destinationName << ", lookup-broker-url " << data->getBrokerUrl());
-                promise->setValue(data);
-            }
+void BinaryProtoLookupService::handleLookup(const std::string& destinationName, Result result,
+                                            LookupDataResultPtr data,
+                                            const ClientConnectionWeakPtr& clientCnx,
+                                            LookupDataResultPromisePtr promise) {
+    if (data) {
+        if (data->isRedirect()) {
+            LOG_DEBUG("Lookup request is for " << destinationName << " redirected to "
+                                               << data->getBrokerUrl());
+            Future<Result, ClientConnectionWeakPtr> future =
+                cnxPool_.getConnectionAsync(data->getBrokerUrl());
+            future.addListener(boost::bind(&BinaryProtoLookupService::sendTopicLookupRequest, this,
+                                           destinationName, data->isAuthoritative(), _1, _2, promise));
         } else {
-            LOG_DEBUG("Lookup failed for " << destinationName << ", result " << result);
-            promise->setFailed(result);
-        }
-    }
-
-    void BinaryProtoLookupService::sendPartitionMetadataLookupRequest(const std::string& destinationName, Result result, const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise) {
-        if (result != ResultOk) {
-            promise->setFailed(ResultConnectError);
-            Future<Result, LookupDataResultPtr> future = promise->getFuture();
-            return;
+            LOG_DEBUG("Lookup response for " << destinationName << ", lookup-broker-url "
+                                             << data->getBrokerUrl());
+            promise->setValue(data);
         }
-        LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
-        ClientConnectionPtr conn = clientCnx.lock();
-        uint64_t requestId = newRequestId();
-        conn->newPartitionedMetadataLookup(destinationName, requestId, lookupPromise);
-        lookupPromise->getFuture().addListener(boost::bind(&BinaryProtoLookupService::handlePartitionMetadataLookup, this, destinationName, _1, _2, clientCnx, promise));
+    } else {
+        LOG_DEBUG("Lookup failed for " << destinationName << ", result " << result);
+        promise->setFailed(result);
     }
+}
 
-    void BinaryProtoLookupService::handlePartitionMetadataLookup(const std::string& destinationName,
-            Result result, LookupDataResultPtr data, const ClientConnectionWeakPtr& clientCnx,
-            LookupDataResultPromisePtr promise) {
-        if (data) {
-            LOG_DEBUG("PartitionMetadataLookup response for " << destinationName << ", lookup-broker-url " << data->getBrokerUrl());
-            promise->setValue(data);
-        } else {
-            LOG_DEBUG("PartitionMetadataLookup failed for " << destinationName << ", result " << result);
-            promise->setFailed(result);
-        }
+void BinaryProtoLookupService::sendPartitionMetadataLookupRequest(const std::string& destinationName,
+                                                                  Result result,
+                                                                  const ClientConnectionWeakPtr& clientCnx,
+                                                                  LookupDataResultPromisePtr promise) {
+    if (result != ResultOk) {
+        promise->setFailed(ResultConnectError);
+        Future<Result, LookupDataResultPtr> future = promise->getFuture();
+        return;
     }
+    LookupDataResultPromisePtr lookupPromise = boost::make_shared<LookupDataResultPromise>();
+    ClientConnectionPtr conn = clientCnx.lock();
+    uint64_t requestId = newRequestId();
+    conn->newPartitionedMetadataLookup(destinationName, requestId, lookupPromise);
+    lookupPromise->getFuture().addListener(
+        boost::bind(&BinaryProtoLookupService::handlePartitionMetadataLookup, this, destinationName, _1, _2,
+                    clientCnx, promise));
+}
 
-    uint64_t BinaryProtoLookupService::newRequestId() {
-        Lock lock(mutex_);
-        return ++requestIdGenerator_;
+void BinaryProtoLookupService::handlePartitionMetadataLookup(const std::string& destinationName,
+                                                             Result result, LookupDataResultPtr data,
+                                                             const ClientConnectionWeakPtr& clientCnx,
+                                                             LookupDataResultPromisePtr promise) {
+    if (data) {
+        LOG_DEBUG("PartitionMetadataLookup response for " << destinationName << ", lookup-broker-url "
+                                                          << data->getBrokerUrl());
+        promise->setValue(data);
+    } else {
+        LOG_DEBUG("PartitionMetadataLookup failed for " << destinationName << ", result " << result);
+        promise->setFailed(result);
     }
+}
 
+uint64_t BinaryProtoLookupService::newRequestId() {
+    Lock lock(mutex_);
+    return ++requestIdGenerator_;
+}
 }
diff --git a/pulsar-client-cpp/lib/BinaryProtoLookupService.h b/pulsar-client-cpp/lib/BinaryProtoLookupService.h
index ebcb12143..e34f430f4 100644
--- a/pulsar-client-cpp/lib/BinaryProtoLookupService.h
+++ b/pulsar-client-cpp/lib/BinaryProtoLookupService.h
@@ -30,7 +30,7 @@ namespace pulsar {
 class LookupDataResult;
 
 class BinaryProtoLookupService : public LookupService {
- public:
+   public:
     /*
      * constructor
      */
@@ -40,8 +40,7 @@ class BinaryProtoLookupService : public LookupService {
 
     Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr& dn);
 
- private:
-
+   private:
     boost::mutex mutex_;
     uint64_t requestIdGenerator_;
 
@@ -49,26 +48,24 @@ class BinaryProtoLookupService : public LookupService {
     ConnectionPool& cnxPool_;
 
     void sendTopicLookupRequest(const std::string& destinationName, bool authoritative, Result result,
-                     const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
+                                const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
 
     void handleLookup(const std::string& destinationName, Result result, LookupDataResultPtr data,
                       const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
 
-
     void sendPartitionMetadataLookupRequest(const std::string& destinationName, Result result,
-                                   const ClientConnectionWeakPtr& clientCnx,
-                                   LookupDataResultPromisePtr promise);
-
-    void handlePartitionMetadataLookup(const std::string& destinationName, Result result, LookupDataResultPtr data,
-                          const ClientConnectionWeakPtr& clientCnx, LookupDataResultPromisePtr promise);
+                                            const ClientConnectionWeakPtr& clientCnx,
+                                            LookupDataResultPromisePtr promise);
 
+    void handlePartitionMetadataLookup(const std::string& destinationName, Result result,
+                                       LookupDataResultPtr data, const ClientConnectionWeakPtr& clientCnx,
+                                       LookupDataResultPromisePtr promise);
 
     uint64_t newRequestId();
-
 };
 typedef boost::shared_ptr<BinaryProtoLookupService> BinaryProtoLookupServicePtr;
 }
 
 #pragma GCC visibility pop
 
-#endif //_PULSAR_BINARY_LOOKUP_SERVICE_HEADER_
+#endif  //_PULSAR_BINARY_LOOKUP_SERVICE_HEADER_
diff --git a/pulsar-client-cpp/lib/BlockingQueue.h b/pulsar-client-cpp/lib/BlockingQueue.h
index d084dd2ef..44bfac6e3 100644
--- a/pulsar-client-cpp/lib/BlockingQueue.h
+++ b/pulsar-client-cpp/lib/BlockingQueue.h
@@ -28,52 +28,34 @@
  * This is done in order to avoid spurious wake up problem.
  * Details: https://www.justsoftwaresolutions.co.uk/threading/condition-variable-spurious-wakes.html
  */
-template<typename Container>
+template <typename Container>
 struct QueueNotEmpty {
     const Container& queue_;
-    QueueNotEmpty(const Container& queue)
-            : queue_(queue) {
-
-    }
-    bool operator()() const {
-        return !queue_.isEmptyNoMutex();
-    }
+    QueueNotEmpty(const Container& queue) : queue_(queue) {}
+    bool operator()() const { return !queue_.isEmptyNoMutex(); }
 };
 
-template<typename Container>
+template <typename Container>
 struct QueueNotFull {
     const Container& queue_;
-    QueueNotFull(const Container& queue)
-            : queue_(queue) {
-
-    }
-    bool operator()() const {
-        return !queue_.isFullNoMutex();
-    }
+    QueueNotFull(const Container& queue) : queue_(queue) {}
+    bool operator()() const { return !queue_.isFullNoMutex(); }
 };
 
-template<typename T>
+template <typename T>
 class BlockingQueue {
- public:
+   public:
     typedef typename boost::circular_buffer<T> Container;
     typedef typename Container::iterator iterator;
     typedef typename Container::const_iterator const_iterator;
 
     class ReservedSpot {
-     public:
-        ReservedSpot()
-                : queue_(),
-                  released_(true) {
-        }
+       public:
+        ReservedSpot() : queue_(), released_(true) {}
 
-        ReservedSpot(BlockingQueue<T>& queue)
-                : queue_(&queue),
-                  released_(false) {
-        }
+        ReservedSpot(BlockingQueue<T>& queue) : queue_(&queue), released_(false) {}
 
-        ~ReservedSpot() {
-            release();
-        }
+        ~ReservedSpot() { release(); }
 
         void release() {
             if (!released_) {
@@ -82,24 +64,19 @@ class BlockingQueue {
             }
         }
 
-     private:
+       private:
         BlockingQueue<T>* queue_;
         bool released_;
 
-        friend class BlockingQueue<T> ;
+        friend class BlockingQueue<T>;
     };
 
-    BlockingQueue(size_t maxSize)
-            : maxSize_(maxSize),
-              mutex_(),
-              queue_(maxSize),
-              reservedSpots_(0) {
-    }
+    BlockingQueue(size_t maxSize) : maxSize_(maxSize), mutex_(), queue_(maxSize), reservedSpots_(0) {}
 
     bool tryReserve(size_t noOfSpots) {
         assert(noOfSpots <= maxSize_);
         Lock lock(mutex_);
-        if(noOfSpots <= maxSize_ - (reservedSpots_ + queue_.size())) {
+        if (noOfSpots <= maxSize_ - (reservedSpots_ + queue_.size())) {
             reservedSpots_ += noOfSpots;
             return true;
         }
@@ -109,7 +86,7 @@ class BlockingQueue {
     void reserve(size_t noOfSpots) {
         assert(noOfSpots <= maxSize_);
         Lock lock(mutex_);
-        while(noOfSpots--) {
+        while (noOfSpots--) {
             queueFullCondition.wait(lock, QueueNotFull<BlockingQueue<T> >(*this));
             reservedSpots_++;
         }
@@ -224,8 +201,7 @@ class BlockingQueue {
 
     bool pop(T& value, const boost::posix_time::time_duration& timeout) {
         Lock lock(mutex_);
-        if (!queueEmptyCondition.timed_wait(lock, timeout,
-                                            QueueNotEmpty<BlockingQueue<T> >(*this))) {
+        if (!queueEmptyCondition.timed_wait(lock, timeout, QueueNotEmpty<BlockingQueue<T> >(*this))) {
             return false;
         }
 
@@ -265,9 +241,7 @@ class BlockingQueue {
         return queue_.size();
     }
 
-    size_t maxSize() const {
-        return maxSize_;
-    }
+    size_t maxSize() const { return maxSize_; }
 
     bool empty() const {
         Lock lock(mutex_);
@@ -279,23 +253,15 @@ class BlockingQueue {
         return isFullNoMutex();
     }
 
-    const_iterator begin() const {
-        return queue_.begin();
-    }
+    const_iterator begin() const { return queue_.begin(); }
 
-    const_iterator end() const {
-        return queue_.end();
-    }
+    const_iterator end() const { return queue_.end(); }
 
-    iterator begin() {
-        return queue_.begin();
-    }
+    iterator begin() { return queue_.begin(); }
 
-    iterator end() {
-        return queue_.end();
-    }
+    iterator end() { return queue_.end(); }
 
- private:
+   private:
     void releaseReservedSpot() {
         Lock lock(mutex_);
         bool wasFull = isFullNoMutex();
@@ -308,13 +274,9 @@ class BlockingQueue {
         }
     }
 
-    bool isEmptyNoMutex() const {
-        return queue_.empty();
-    }
+    bool isEmptyNoMutex() const { return queue_.empty(); }
 
-    bool isFullNoMutex() const {
-        return (queue_.size() + reservedSpots_) == maxSize_;
-    }
+    bool isFullNoMutex() const { return (queue_.size() + reservedSpots_) == maxSize_; }
 
     const size_t maxSize_;
     mutable boost::mutex mutex_;
@@ -325,8 +287,8 @@ class BlockingQueue {
 
     typedef boost::unique_lock<boost::mutex> Lock;
     friend class QueueReservedSpot;
-    friend struct QueueNotEmpty<BlockingQueue<T> > ;
-    friend struct QueueNotFull<BlockingQueue<T> > ;
+    friend struct QueueNotEmpty<BlockingQueue<T> >;
+    friend struct QueueNotFull<BlockingQueue<T> >;
 };
 
 #endif /* LIB_BLOCKINGQUEUE_H_ */
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStats.cc b/pulsar-client-cpp/lib/BrokerConsumerStats.cc
index f11a85715..6b08f151f 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStats.cc
+++ b/pulsar-client-cpp/lib/BrokerConsumerStats.cc
@@ -20,27 +20,22 @@
 #include <lib/BrokerConsumerStatsImplBase.h>
 
 namespace pulsar {
-BrokerConsumerStats::BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl)
-        : impl_(impl) {
-}
+BrokerConsumerStats::BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl) : impl_(impl) {}
 
-BrokerConsumerStats::BrokerConsumerStats() {
-}
+BrokerConsumerStats::BrokerConsumerStats() {}
 
-boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStats::getImpl() const {
-    return impl_;
-}
+boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStats::getImpl() const { return impl_; }
 
-bool BrokerConsumerStats::isValid() const {
-    return impl_->isValid();
-}
+bool BrokerConsumerStats::isValid() const { return impl_->isValid(); }
 
 #pragma GCC visibility push(default)
-std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats& obj) {
-    os << "\nBrokerConsumerStats [" << "validTill_ = " << obj.isValid() << ", msgRateOut_ = "
-       << obj.getMsgRateOut() << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
-       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver() << ", consumerName_ = "
-       << obj.getConsumerName() << ", availablePermits_ = " << obj.getAvailablePermits()
+std::ostream& operator<<(std::ostream& os, const BrokerConsumerStats& obj) {
+    os << "\nBrokerConsumerStats ["
+       << "validTill_ = " << obj.isValid() << ", msgRateOut_ = " << obj.getMsgRateOut()
+       << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
+       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
+       << ", consumerName_ = " << obj.getConsumerName()
+       << ", availablePermits_ = " << obj.getAvailablePermits()
        << ", unackedMessages_ = " << obj.getUnackedMessages()
        << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
        << ", address_ = " << obj.getAddress() << ", connectedSince_ = " << obj.getConnectedSince()
@@ -50,51 +45,29 @@ std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats& obj) {
 }
 #pragma GCC visibility pop
 
-double BrokerConsumerStats::getMsgRateOut() const {
-    return impl_->getMsgRateOut();
-}
+double BrokerConsumerStats::getMsgRateOut() const { return impl_->getMsgRateOut(); }
 
-double BrokerConsumerStats::getMsgThroughputOut() const {
-    return impl_->getMsgThroughputOut();
-}
+double BrokerConsumerStats::getMsgThroughputOut() const { return impl_->getMsgThroughputOut(); }
 
-double BrokerConsumerStats::getMsgRateRedeliver() const {
-    return impl_->getMsgRateRedeliver();
-}
+double BrokerConsumerStats::getMsgRateRedeliver() const { return impl_->getMsgRateRedeliver(); }
 
-const std::string BrokerConsumerStats::getConsumerName() const {
-    return impl_->getConsumerName();
-}
+const std::string BrokerConsumerStats::getConsumerName() const { return impl_->getConsumerName(); }
 
-uint64_t BrokerConsumerStats::getAvailablePermits() const {
-    return impl_->getAvailablePermits();
-}
+uint64_t BrokerConsumerStats::getAvailablePermits() const { return impl_->getAvailablePermits(); }
 
-uint64_t BrokerConsumerStats::getUnackedMessages() const {
-    return impl_->getUnackedMessages();
-}
+uint64_t BrokerConsumerStats::getUnackedMessages() const { return impl_->getUnackedMessages(); }
 
 bool BrokerConsumerStats::isBlockedConsumerOnUnackedMsgs() const {
     return impl_->isBlockedConsumerOnUnackedMsgs();
 }
 
-const std::string BrokerConsumerStats::getAddress() const {
-    return impl_->getAddress();
-}
+const std::string BrokerConsumerStats::getAddress() const { return impl_->getAddress(); }
 
-const std::string BrokerConsumerStats::getConnectedSince() const {
-    return impl_->getConnectedSince();
-}
+const std::string BrokerConsumerStats::getConnectedSince() const { return impl_->getConnectedSince(); }
 
-const ConsumerType BrokerConsumerStats::getType() const {
-    return impl_->getType();
-}
+const ConsumerType BrokerConsumerStats::getType() const { return impl_->getType(); }
 
-double BrokerConsumerStats::getMsgRateExpired() const {
-    return impl_->getMsgRateExpired();
-}
+double BrokerConsumerStats::getMsgRateExpired() const { return impl_->getMsgRateExpired(); }
 
-uint64_t BrokerConsumerStats::getMsgBacklog() const {
-    return impl_->getMsgBacklog();
-}
+uint64_t BrokerConsumerStats::getMsgBacklog() const { return impl_->getMsgBacklog(); }
 }
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc
index c9c4e426a..84c7ec52a 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc
+++ b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.cc
@@ -20,110 +20,83 @@
 #include <boost/date_time/local_time/local_time.hpp>
 
 namespace pulsar {
-    BrokerConsumerStatsImpl::BrokerConsumerStatsImpl() : validTill_(boost::posix_time::microsec_clock::universal_time()) {};
-
-    BrokerConsumerStatsImpl::BrokerConsumerStatsImpl(double msgRateOut, double msgThroughputOut,
-                                                     double msgRateRedeliver, std::string consumerName,
-                                                     uint64_t availablePermits,
-                                                     uint64_t unackedMessages, bool blockedConsumerOnUnackedMsgs,
-                                                     std::string address,
-                                                     std::string connectedSince, const std::string& type,
-                                                     double msgRateExpired, uint64_t msgBacklog) :
-            msgRateOut_(msgRateOut),
-            msgThroughputOut_(msgThroughputOut),
-            msgRateRedeliver_(msgRateRedeliver),
-            consumerName_(consumerName),
-            availablePermits_(availablePermits),
-            unackedMessages_(unackedMessages),
-            blockedConsumerOnUnackedMsgs_(blockedConsumerOnUnackedMsgs),
-            address_(address),
-            connectedSince_(connectedSince),
-            type_(convertStringToConsumerType(type)),
-            msgRateExpired_(msgRateExpired),
-            msgBacklog_(msgBacklog) {}
-
-    bool BrokerConsumerStatsImpl::isValid() const {
-        return boost::posix_time::microsec_clock::universal_time() <= validTill_;
-    }
+BrokerConsumerStatsImpl::BrokerConsumerStatsImpl()
+    : validTill_(boost::posix_time::microsec_clock::universal_time()){};
+
+BrokerConsumerStatsImpl::BrokerConsumerStatsImpl(double msgRateOut, double msgThroughputOut,
+                                                 double msgRateRedeliver, std::string consumerName,
+                                                 uint64_t availablePermits, uint64_t unackedMessages,
+                                                 bool blockedConsumerOnUnackedMsgs, std::string address,
+                                                 std::string connectedSince, const std::string& type,
+                                                 double msgRateExpired, uint64_t msgBacklog)
+    : msgRateOut_(msgRateOut),
+      msgThroughputOut_(msgThroughputOut),
+      msgRateRedeliver_(msgRateRedeliver),
+      consumerName_(consumerName),
+      availablePermits_(availablePermits),
+      unackedMessages_(unackedMessages),
+      blockedConsumerOnUnackedMsgs_(blockedConsumerOnUnackedMsgs),
+      address_(address),
+      connectedSince_(connectedSince),
+      type_(convertStringToConsumerType(type)),
+      msgRateExpired_(msgRateExpired),
+      msgBacklog_(msgBacklog) {}
+
+bool BrokerConsumerStatsImpl::isValid() const {
+    return boost::posix_time::microsec_clock::universal_time() <= validTill_;
+}
 
-    std::ostream& operator<<(std::ostream &os, const BrokerConsumerStatsImpl& obj) {
-        os << "\nBrokerConsumerStatsImpl ["
-           << "validTill_ = " << obj.isValid()
-           << ", msgRateOut_ = " << obj.getMsgRateOut()
-           << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
-           << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
-           << ", consumerName_ = " << obj.getConsumerName()
-           << ", availablePermits_ = " << obj.getAvailablePermits()
-           << ", unackedMessages_ = " << obj.getUnackedMessages()
-           << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
-           << ", address_ = " << obj.getAddress()
-           << ", connectedSince_ = " << obj.getConnectedSince()
-           << ", type_ = " << obj.getType()
-           << ", msgRateExpired_ = " << obj.getMsgRateExpired()
-           << ", msgBacklog_ = " << obj.getMsgBacklog()
-           << "]";
-        return os;
-    }
+std::ostream& operator<<(std::ostream& os, const BrokerConsumerStatsImpl& obj) {
+    os << "\nBrokerConsumerStatsImpl ["
+       << "validTill_ = " << obj.isValid() << ", msgRateOut_ = " << obj.getMsgRateOut()
+       << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
+       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
+       << ", consumerName_ = " << obj.getConsumerName()
+       << ", availablePermits_ = " << obj.getAvailablePermits()
+       << ", unackedMessages_ = " << obj.getUnackedMessages()
+       << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
+       << ", address_ = " << obj.getAddress() << ", connectedSince_ = " << obj.getConnectedSince()
+       << ", type_ = " << obj.getType() << ", msgRateExpired_ = " << obj.getMsgRateExpired()
+       << ", msgBacklog_ = " << obj.getMsgBacklog() << "]";
+    return os;
+}
 
-    double BrokerConsumerStatsImpl::getMsgRateOut() const {
-        return msgRateOut_;
-    }
+double BrokerConsumerStatsImpl::getMsgRateOut() const { return msgRateOut_; }
 
-    double BrokerConsumerStatsImpl::getMsgThroughputOut() const {
-        return msgThroughputOut_;
-    }
+double BrokerConsumerStatsImpl::getMsgThroughputOut() const { return msgThroughputOut_; }
 
-    double BrokerConsumerStatsImpl::getMsgRateRedeliver() const {
-        return msgRateRedeliver_;
-    }
+double BrokerConsumerStatsImpl::getMsgRateRedeliver() const { return msgRateRedeliver_; }
 
-    const std::string BrokerConsumerStatsImpl::getConsumerName() const {
-        return consumerName_;
-    }
+const std::string BrokerConsumerStatsImpl::getConsumerName() const { return consumerName_; }
 
-    uint64_t BrokerConsumerStatsImpl::getAvailablePermits() const {
-        return availablePermits_;
-    }
+uint64_t BrokerConsumerStatsImpl::getAvailablePermits() const { return availablePermits_; }
 
-    uint64_t BrokerConsumerStatsImpl::getUnackedMessages() const {
-        return unackedMessages_;
-    }
+uint64_t BrokerConsumerStatsImpl::getUnackedMessages() const { return unackedMessages_; }
 
-    bool BrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const {
-        return blockedConsumerOnUnackedMsgs_;
-    }
+bool BrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const { return blockedConsumerOnUnackedMsgs_; }
 
-    const std::string BrokerConsumerStatsImpl::getAddress() const {
-        return address_;
-    }
+const std::string BrokerConsumerStatsImpl::getAddress() const { return address_; }
 
-    const std::string BrokerConsumerStatsImpl::getConnectedSince() const {
-        return connectedSince_;
-    }
+const std::string BrokerConsumerStatsImpl::getConnectedSince() const { return connectedSince_; }
 
-    const ConsumerType BrokerConsumerStatsImpl::getType() const {
-        return type_;
-    }
+const ConsumerType BrokerConsumerStatsImpl::getType() const { return type_; }
 
-    double BrokerConsumerStatsImpl::getMsgRateExpired() const {
-        return msgRateExpired_;
-    }
+double BrokerConsumerStatsImpl::getMsgRateExpired() const { return msgRateExpired_; }
 
-    uint64_t BrokerConsumerStatsImpl::getMsgBacklog() const {
-        return msgBacklog_;
-    }
+uint64_t BrokerConsumerStatsImpl::getMsgBacklog() const { return msgBacklog_; }
 
-    void BrokerConsumerStatsImpl::setCacheTime(uint64_t cacehTimeInMs) {
-        validTill_ = boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(cacehTimeInMs);
-    }
+void BrokerConsumerStatsImpl::setCacheTime(uint64_t cacehTimeInMs) {
+    validTill_ =
+        boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(cacehTimeInMs);
+}
 
-    ConsumerType BrokerConsumerStatsImpl::convertStringToConsumerType(const std::string& str) {
-        if (str == "ConsumerFailover" || str == "Failover") {
-            return ConsumerFailover;
-        } else if (str == "ConsumerShared" || str == "Shared") {
-            return ConsumerShared;
-        } else {
-            return ConsumerExclusive;
-        }
+ConsumerType BrokerConsumerStatsImpl::convertStringToConsumerType(const std::string& str) {
+    if (str == "ConsumerFailover" || str == "Failover") {
+        return ConsumerFailover;
+    } else if (str == "ConsumerShared" || str == "Shared") {
+        return ConsumerShared;
+    } else {
+        return ConsumerExclusive;
     }
 }
+}
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h
index f68029486..e2b485636 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h
+++ b/pulsar-client-cpp/lib/BrokerConsumerStatsImpl.h
@@ -29,7 +29,7 @@
 #pragma GCC visibility push(default)
 namespace pulsar {
 class BrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
- private:
+   private:
     /** validTill_ - Stats will be valid till this time.*/
     boost::posix_time::ptime validTill_;
 
@@ -69,15 +69,14 @@ class BrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
     /** Number of messages in the subscription backlog */
     uint64_t msgBacklog_;
 
-public:
-
+   public:
     BrokerConsumerStatsImpl();
 
     BrokerConsumerStatsImpl(double msgRateOut, double msgThroughputOut, double msgRateRedeliver,
-                            std::string consumerName, uint64_t availablePermits,
-                            uint64_t unackedMessages, bool blockedConsumerOnUnackedMsgs,
-                            std::string address, std::string connectedSince, const std::string& type,
-                            double msgRateExpired, uint64_t msgBacklog);
+                            std::string consumerName, uint64_t availablePermits, uint64_t unackedMessages,
+                            bool blockedConsumerOnUnackedMsgs, std::string address,
+                            std::string connectedSince, const std::string& type, double msgRateExpired,
+                            uint64_t msgBacklog);
 
     /** Returns true if the Stats are still valid **/
     virtual bool isValid() const;
@@ -120,10 +119,10 @@ class BrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
 
     void setCacheTime(uint64_t cacehTimeInMs);
 
-    friend std::ostream& operator<<(std::ostream &os, const BrokerConsumerStatsImpl &obj);
+    friend std::ostream& operator<<(std::ostream& os, const BrokerConsumerStatsImpl& obj);
 
     static ConsumerType convertStringToConsumerType(const std::string& str);
 };
 }
 #pragma GCC visibility pop
-#endif //PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
diff --git a/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h b/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h
index e09d80fb2..743e61b29 100644
--- a/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h
+++ b/pulsar-client-cpp/lib/BrokerConsumerStatsImplBase.h
@@ -22,48 +22,48 @@
 #include <pulsar/BrokerConsumerStats.h>
 
 namespace pulsar {
-    class BrokerConsumerStatsImplBase {
-    public:
-        /** Returns true if the Stats are still valid **/
-        virtual bool isValid() const = 0;
+class BrokerConsumerStatsImplBase {
+   public:
+    /** Returns true if the Stats are still valid **/
+    virtual bool isValid() const = 0;
 
-        /** Returns the rate of messages delivered to the consumer. msg/s */
-        virtual double getMsgRateOut() const = 0;
+    /** Returns the rate of messages delivered to the consumer. msg/s */
+    virtual double getMsgRateOut() const = 0;
 
-        /** Returns the throughput delivered to the consumer. bytes/s */
-        virtual double getMsgThroughputOut() const = 0;
+    /** Returns the throughput delivered to the consumer. bytes/s */
+    virtual double getMsgThroughputOut() const = 0;
 
-        /** Returns the rate of messages redelivered by this consumer. msg/s */
-        virtual double getMsgRateRedeliver() const = 0;
+    /** Returns the rate of messages redelivered by this consumer. msg/s */
+    virtual double getMsgRateRedeliver() const = 0;
 
-        /** Returns the Name of the consumer */
-        virtual const std::string getConsumerName() const = 0;
+    /** Returns the Name of the consumer */
+    virtual const std::string getConsumerName() const = 0;
 
-        /** Returns the Number of available message permits for the consumer */
-        virtual uint64_t getAvailablePermits() const = 0;
+    /** Returns the Number of available message permits for the consumer */
+    virtual uint64_t getAvailablePermits() const = 0;
 
-        /** Returns the Number of unacknowledged messages for the consumer */
-        virtual uint64_t getUnackedMessages() const = 0;
+    /** Returns the Number of unacknowledged messages for the consumer */
+    virtual uint64_t getUnackedMessages() const = 0;
 
-        /** Returns true if the consumer is blocked due to unacked messages.  */
-        virtual bool isBlockedConsumerOnUnackedMsgs() const = 0;
+    /** Returns true if the consumer is blocked due to unacked messages.  */
+    virtual bool isBlockedConsumerOnUnackedMsgs() const = 0;
 
-        /** Returns the Address of this consumer */
-        virtual const std::string getAddress() const = 0;
+    /** Returns the Address of this consumer */
+    virtual const std::string getAddress() const = 0;
 
-        /** Returns the Timestamp of connection */
-        virtual const std::string getConnectedSince() const = 0;
+    /** Returns the Timestamp of connection */
+    virtual const std::string getConnectedSince() const = 0;
 
-        /** Returns Whether this subscription is Exclusive or Shared or Failover */
-        virtual const ConsumerType getType() const = 0;
+    /** Returns Whether this subscription is Exclusive or Shared or Failover */
+    virtual const ConsumerType getType() const = 0;
 
-        /** Returns the rate of messages expired on this subscription. msg/s */
-        virtual double getMsgRateExpired() const = 0;
+    /** Returns the rate of messages expired on this subscription. msg/s */
+    virtual double getMsgRateExpired() const = 0;
 
-        /** Returns the Number of messages in the subscription backlog */
-        virtual uint64_t getMsgBacklog() const = 0;
-    };
-    typedef boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStatsImplBasePtr;
+    /** Returns the Number of messages in the subscription backlog */
+    virtual uint64_t getMsgBacklog() const = 0;
+};
+typedef boost::shared_ptr<BrokerConsumerStatsImplBase> BrokerConsumerStatsImplBasePtr;
 }
 
-#endif //PULSAR_CPP_BROKERCONSUMERSTATSIMPLBASE_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATSIMPLBASE_H
diff --git a/pulsar-client-cpp/lib/Client.cc b/pulsar-client-cpp/lib/Client.cc
index 8adf40198..e3b718f21 100644
--- a/pulsar-client-cpp/lib/Client.cc
+++ b/pulsar-client-cpp/lib/Client.cc
@@ -32,21 +32,17 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-Client::Client(const boost::shared_ptr<ClientImpl> impl) : impl_(impl) {
-}
+Client::Client(const boost::shared_ptr<ClientImpl> impl) : impl_(impl) {}
 
 Client::Client(const std::string& serviceUrl)
-        : impl_(boost::make_shared<ClientImpl>(serviceUrl, ClientConfiguration(), true)) {
-}
+    : impl_(boost::make_shared<ClientImpl>(serviceUrl, ClientConfiguration(), true)) {}
 
 Client::Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration)
-        : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, true)) {
-}
+    : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, true)) {}
 
 Client::Client(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
                bool poolConnections)
-        : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, poolConnections)) {
-}
+    : impl_(boost::make_shared<ClientImpl>(serviceUrl, clientConfiguration, poolConnections)) {}
 
 Result Client::createProducer(const std::string& topic, Producer& producer) {
     return createProducer(topic, ProducerConfiguration(), producer);
@@ -70,8 +66,7 @@ void Client::createProducerAsync(const std::string& topic, ProducerConfiguration
     impl_->createProducerAsync(topic, conf, callback);
 }
 
-Result Client::subscribe(const std::string& topic, const std::string& consumerName,
-                         Consumer& consumer) {
+Result Client::subscribe(const std::string& topic, const std::string& consumerName, Consumer& consumer) {
     return subscribe(topic, consumerName, ConsumerConfiguration(), consumer);
 }
 
@@ -96,7 +91,7 @@ void Client::subscribeAsync(const std::string& topic, const std::string& consume
 }
 
 Result Client::createReader(const std::string& topic, const MessageId& startMessageId,
-        const ReaderConfiguration& conf, Reader& reader) {
+                            const ReaderConfiguration& conf, Reader& reader) {
     Promise<Result, Reader> promise;
     createReaderAsync(topic, startMessageId, conf, WaitForCallbackValue<Reader>(promise));
     Future<Result, Reader> future = promise.getFuture();
@@ -105,7 +100,7 @@ Result Client::createReader(const std::string& topic, const MessageId& startMess
 }
 
 void Client::createReaderAsync(const std::string& topic, const MessageId& startMessageId,
-        const ReaderConfiguration& conf, ReaderCallback callback) {
+                               const ReaderConfiguration& conf, ReaderCallback callback) {
     impl_->createReaderAsync(topic, startMessageId, conf, callback);
 }
 
@@ -118,12 +113,7 @@ Result Client::close() {
     return result;
 }
 
-void Client::closeAsync(CloseCallback callback) {
-    impl_->closeAsync(callback);
-}
-
-void Client::shutdown() {
-    impl_->shutdown();
-}
+void Client::closeAsync(CloseCallback callback) { impl_->closeAsync(callback); }
 
+void Client::shutdown() { impl_->shutdown(); }
 }
diff --git a/pulsar-client-cpp/lib/ClientConfiguration.cc b/pulsar-client-cpp/lib/ClientConfiguration.cc
index d7f30ba18..cbcbd12fc 100644
--- a/pulsar-client-cpp/lib/ClientConfiguration.cc
+++ b/pulsar-client-cpp/lib/ClientConfiguration.cc
@@ -20,16 +20,11 @@
 
 namespace pulsar {
 
-ClientConfiguration::ClientConfiguration()
-        : impl_(boost::make_shared<ClientConfigurationImpl>()) {
-}
+ClientConfiguration::ClientConfiguration() : impl_(boost::make_shared<ClientConfigurationImpl>()) {}
 
-ClientConfiguration::~ClientConfiguration() {
-}
+ClientConfiguration::~ClientConfiguration() {}
 
-ClientConfiguration::ClientConfiguration(const ClientConfiguration& x)
-    : impl_(x.impl_) {
-}
+ClientConfiguration::ClientConfiguration(const ClientConfiguration& x) : impl_(x.impl_) {}
 
 ClientConfiguration& ClientConfiguration::operator=(const ClientConfiguration& x) {
     impl_ = x.impl_;
@@ -41,87 +36,68 @@ ClientConfiguration& ClientConfiguration::setAuth(const AuthenticationPtr& authe
     return *this;
 }
 
-const Authentication& ClientConfiguration::getAuth() const {
-    return *impl_->authenticationPtr;
-}
+const Authentication& ClientConfiguration::getAuth() const { return *impl_->authenticationPtr; }
 
-const AuthenticationPtr& ClientConfiguration::getAuthPtr() const {
-    return impl_->authenticationPtr;
-}
+const AuthenticationPtr& ClientConfiguration::getAuthPtr() const { return impl_->authenticationPtr; }
 
 ClientConfiguration& ClientConfiguration::setOperationTimeoutSeconds(int timeout) {
     impl_->operationTimeoutSeconds = timeout;
     return *this;
 }
 
-int ClientConfiguration::getOperationTimeoutSeconds() const {
-    return impl_->operationTimeoutSeconds;
-}
+int ClientConfiguration::getOperationTimeoutSeconds() const { return impl_->operationTimeoutSeconds; }
 
 ClientConfiguration& ClientConfiguration::setIOThreads(int threads) {
     impl_->ioThreads = threads;
     return *this;
 }
 
-int ClientConfiguration::getIOThreads() const {
-    return impl_->ioThreads;
-}
+int ClientConfiguration::getIOThreads() const { return impl_->ioThreads; }
 
 ClientConfiguration& ClientConfiguration::setMessageListenerThreads(int threads) {
     impl_->messageListenerThreads = threads;
     return *this;
 }
 
-int ClientConfiguration::getMessageListenerThreads() const {
-    return impl_->messageListenerThreads;
-}
+int ClientConfiguration::getMessageListenerThreads() const { return impl_->messageListenerThreads; }
 
 ClientConfiguration& ClientConfiguration::setUseTls(bool useTls) {
     impl_->useTls = useTls;
     return *this;
 }
 
-bool ClientConfiguration::isUseTls() const {
-    return impl_->useTls;
-}
+bool ClientConfiguration::isUseTls() const { return impl_->useTls; }
 
-ClientConfiguration& ClientConfiguration::setTlsTrustCertsFilePath(const std::string &filePath) {
+ClientConfiguration& ClientConfiguration::setTlsTrustCertsFilePath(const std::string& filePath) {
     impl_->tlsTrustCertsFilePath = filePath;
     return *this;
 }
 
-std::string ClientConfiguration::getTlsTrustCertsFilePath() const {
-    return impl_->tlsTrustCertsFilePath;
-}
+std::string ClientConfiguration::getTlsTrustCertsFilePath() const { return impl_->tlsTrustCertsFilePath; }
 
 ClientConfiguration& ClientConfiguration::setTlsAllowInsecureConnection(bool allowInsecure) {
     impl_->tlsAllowInsecureConnection = allowInsecure;
     return *this;
 }
 
-bool ClientConfiguration::isTlsAllowInsecureConnection() const {
-    return impl_->tlsAllowInsecureConnection;
-}
+bool ClientConfiguration::isTlsAllowInsecureConnection() const { return impl_->tlsAllowInsecureConnection; }
 
 ClientConfiguration& ClientConfiguration::setConcurrentLookupRequest(int concurrentLookupRequest) {
     impl_->concurrentLookupRequest = concurrentLookupRequest;
     return *this;
 }
 
-int ClientConfiguration::getConcurrentLookupRequest() const {
-    return impl_->concurrentLookupRequest;
-}
+int ClientConfiguration::getConcurrentLookupRequest() const { return impl_->concurrentLookupRequest; }
 
 ClientConfiguration& ClientConfiguration::setLogConfFilePath(const std::string& logConfFilePath) {
     impl_->logConfFilePath = logConfFilePath;
     return *this;
 }
 
-const std::string& ClientConfiguration::getLogConfFilePath() const {
-    return impl_->logConfFilePath;
-}
+const std::string& ClientConfiguration::getLogConfFilePath() const { return impl_->logConfFilePath; }
 
-ClientConfiguration& ClientConfiguration::setStatsIntervalInSeconds(const unsigned int& statsIntervalInSeconds) {
+ClientConfiguration& ClientConfiguration::setStatsIntervalInSeconds(
+    const unsigned int& statsIntervalInSeconds) {
     impl_->statsIntervalInSeconds = statsIntervalInSeconds;
     return *this;
 }
@@ -129,5 +105,4 @@ ClientConfiguration& ClientConfiguration::setStatsIntervalInSeconds(const unsign
 const unsigned int& ClientConfiguration::getStatsIntervalInSeconds() const {
     return impl_->statsIntervalInSeconds;
 }
-
 }
diff --git a/pulsar-client-cpp/lib/ClientConfigurationImpl.h b/pulsar-client-cpp/lib/ClientConfigurationImpl.h
index 40b6a9b5e..2d3e87799 100644
--- a/pulsar-client-cpp/lib/ClientConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ClientConfigurationImpl.h
@@ -34,15 +34,16 @@ struct ClientConfigurationImpl {
     std::string tlsTrustCertsFilePath;
     bool tlsAllowInsecureConnection;
     unsigned int statsIntervalInSeconds;
-    ClientConfigurationImpl() : authenticationPtr(AuthFactory::Disabled()),
-             ioThreads(1),
-             operationTimeoutSeconds(30),
-             messageListenerThreads(1),
-             concurrentLookupRequest(5000),
-             logConfFilePath(),
-             useTls(false),
-             tlsAllowInsecureConnection(true),
-             statsIntervalInSeconds(600) { // 10 minutes
+    ClientConfigurationImpl()
+        : authenticationPtr(AuthFactory::Disabled()),
+          ioThreads(1),
+          operationTimeoutSeconds(30),
+          messageListenerThreads(1),
+          concurrentLookupRequest(5000),
+          logConfFilePath(),
+          useTls(false),
+          tlsAllowInsecureConnection(true),
+          statsIntervalInSeconds(600) {  // 10 minutes
     }
 };
 }
diff --git a/pulsar-client-cpp/lib/ClientConnection.cc b/pulsar-client-cpp/lib/ClientConnection.cc
index 6b24d750a..e24a1db36 100644
--- a/pulsar-client-cpp/lib/ClientConnection.cc
+++ b/pulsar-client-cpp/lib/ClientConnection.cc
@@ -81,10 +81,10 @@ static Result getResult(ServerError serverError) {
             return ResultServiceUnitNotReady;
 
         case ProducerBlockedQuotaExceededError:
-        	return ResultProducerBlockedQuotaExceededError;
+            return ResultProducerBlockedQuotaExceededError;
 
         case ProducerBlockedQuotaExceededException:
-        	return ResultProducerBlockedQuotaExceededException;
+            return ResultProducerBlockedQuotaExceededException;
 
         case TopicNotFound:
             return ResultTopicNotFound;
@@ -105,29 +105,30 @@ static Result getResult(ServerError serverError) {
 }
 
 ClientConnection::ClientConnection(const std::string& endpoint, ExecutorServicePtr executor,
-                                   const ClientConfiguration& clientConfiguration, const AuthenticationPtr& authentication)
-: state_(Pending),
-operationsTimeout_(seconds(clientConfiguration.getOperationTimeoutSeconds())),
-authentication_(authentication),
-serverProtocolVersion_(ProtocolVersion_MIN),
-executor_(executor),
-resolver_(executor->createTcpResolver()),
-socket_(executor->createSocket()),
-address_(endpoint),
-cnxString_("[<none> -> " + endpoint + "] "),
-error_(boost::system::error_code()),
-incomingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
-incomingCmd_(),
-pendingWriteBuffers_(),
-pendingWriteOperations_(0),
-outgoingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
-outgoingCmd_(),
-havePendingPingRequest_(false),
-keepAliveTimer_(),
-maxPendingLookupRequest_(clientConfiguration.getConcurrentLookupRequest()),
-consumerStatsRequestTimer_(executor_->createDeadlineTimer()),
-numOfPendingLookupRequest_(0),
-isTlsAllowInsecureConnection_(false) {
+                                   const ClientConfiguration& clientConfiguration,
+                                   const AuthenticationPtr& authentication)
+    : state_(Pending),
+      operationsTimeout_(seconds(clientConfiguration.getOperationTimeoutSeconds())),
+      authentication_(authentication),
+      serverProtocolVersion_(ProtocolVersion_MIN),
+      executor_(executor),
+      resolver_(executor->createTcpResolver()),
+      socket_(executor->createSocket()),
+      address_(endpoint),
+      cnxString_("[<none> -> " + endpoint + "] "),
+      error_(boost::system::error_code()),
+      incomingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
+      incomingCmd_(),
+      pendingWriteBuffers_(),
+      pendingWriteOperations_(0),
+      outgoingBuffer_(SharedBuffer::allocate(DefaultBufferSize)),
+      outgoingCmd_(),
+      havePendingPingRequest_(false),
+      keepAliveTimer_(),
+      maxPendingLookupRequest_(clientConfiguration.getConcurrentLookupRequest()),
+      consumerStatsRequestTimer_(executor_->createDeadlineTimer()),
+      numOfPendingLookupRequest_(0),
+      isTlsAllowInsecureConnection_(false) {
     if (clientConfiguration.isUseTls()) {
         using namespace boost::filesystem;
 
@@ -152,7 +153,7 @@ isTlsAllowInsecureConnection_(false) {
         }
 
         AuthenticationDataPtr authData;
-        if (authentication_->getAuthData(authData) == ResultOk && authData->hasDataForTls()){
+        if (authentication_->getAuthData(authData) == ResultOk && authData->hasDataForTls()) {
             std::string tlsCertificates = authData->getTlsCertificates();
             std::string tlsPrivateKey = authData->getTlsPrivateKey();
 
@@ -177,9 +178,7 @@ isTlsAllowInsecureConnection_(false) {
     }
 }
 
-ClientConnection::~ClientConnection() {
-    LOG_INFO(cnxString_ << "Destroyed connection");
-}
+ClientConnection::~ClientConnection() { LOG_INFO(cnxString_ << "Destroyed connection"); }
 
 void ClientConnection::handlePulsarConnected(const CommandConnected& cmdConnected) {
     if (!cmdConnected.has_server_version()) {
@@ -197,7 +196,7 @@ void ClientConnection::handlePulsarConnected(const CommandConnected& cmdConnecte
         keepAliveTimer_ = executor_->createDeadlineTimer();
         keepAliveTimer_->expires_from_now(boost::posix_time::seconds(KeepAliveIntervalInSeconds));
         keepAliveTimer_->async_wait(
-                boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
+            boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
     }
 
     if (serverProtocolVersion_ >= v8) {
@@ -212,7 +211,8 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
     for (int i = 0; i < consumerStatsRequests.size(); i++) {
         PendingConsumerStatsMap::iterator it = pendingConsumerStatsMap_.find(consumerStatsRequests[i]);
         if (it != pendingConsumerStatsMap_.end()) {
-            LOG_DEBUG(cnxString_ << " removing request_id " << it->first << " from the pendingConsumerStatsMap_");
+            LOG_DEBUG(cnxString_ << " removing request_id " << it->first
+                                 << " from the pendingConsumerStatsMap_");
             consumerStatsPromises.push_back(it->second);
             pendingConsumerStatsMap_.erase(it);
         } else {
@@ -226,9 +226,9 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
         consumerStatsRequests.push_back(it->first);
     }
     consumerStatsRequestTimer_->expires_from_now(operationsTimeout_);
-    consumerStatsRequestTimer_->async_wait(
-            boost::bind(&ClientConnection::handleConsumerStatsTimeout, shared_from_this(),
-                        boost::asio::placeholders::error, consumerStatsRequests));
+    consumerStatsRequestTimer_->async_wait(boost::bind(&ClientConnection::handleConsumerStatsTimeout,
+                                                       shared_from_this(), boost::asio::placeholders::error,
+                                                       consumerStatsRequests));
     lock.unlock();
     // Complex logic since promises need to be fulfilled outside the lock
     for (int i = 0; i < consumerStatsPromises.size(); i++) {
@@ -237,18 +237,21 @@ void ClientConnection::startConsumerStatsTimer(std::vector<uint64_t> consumerSta
     }
 }
 
-/// The number of unacknowledged probes to send before considering the connection dead and notifying the application layer
+/// The number of unacknowledged probes to send before considering the connection dead and notifying the
+/// application layer
 typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPCNT> tcp_keep_alive_count;
 
-/// The interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime
+/// The interval between subsequential keepalive probes, regardless of what the connection has exchanged in
+/// the meantime
 typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPINTVL> tcp_keep_alive_interval;
 
-/// The interval between the last data packet sent (simple ACKs are not considered data) and the first keepalive
+/// The interval between the last data packet sent (simple ACKs are not considered data) and the first
+/// keepalive
 /// probe; after the connection is marked to need keepalive, this counter is not used any further
 #ifdef __APPLE__
-  typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPALIVE> tcp_keep_alive_idle;
+typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPALIVE> tcp_keep_alive_idle;
 #else
-  typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPIDLE> tcp_keep_alive_idle;
+typedef boost::asio::detail::socket_option::integer<IPPROTO_TCP, TCP_KEEPIDLE> tcp_keep_alive_idle;
 #endif
 
 /*
@@ -291,7 +294,9 @@ void ClientConnection::handleTcpConnected(const boost::system::error_code& err,
                     return;
                 }
             }
-            tlsSocket_->async_handshake(boost::asio::ssl::stream<tcp::socket>::client, boost::bind(&ClientConnection::handleHandshake, shared_from_this(), boost::asio::placeholders::error));
+            tlsSocket_->async_handshake(boost::asio::ssl::stream<tcp::socket>::client,
+                                        boost::bind(&ClientConnection::handleHandshake, shared_from_this(),
+                                                    boost::asio::placeholders::error));
         } else {
             handleHandshake(boost::system::errc::make_error_code(boost::system::errc::success));
         }
@@ -299,37 +304,33 @@ void ClientConnection::handleTcpConnected(const boost::system::error_code& err,
         // The connection failed. Try the next endpoint in the list.
         socket_->close();
         tcp::endpoint endpoint = *endpointIterator;
-        socket_->async_connect(
-                endpoint,
-                boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
-                            boost::asio::placeholders::error, ++endpointIterator));
+        socket_->async_connect(endpoint,
+                               boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
+                                           boost::asio::placeholders::error, ++endpointIterator));
     } else {
         LOG_ERROR(cnxString_ << "Failed to establish connection: " << err.message());
         close();
         return;
-
     }
-
 }
 
 void ClientConnection::handleHandshake(const boost::system::error_code& err) {
-        SharedBuffer buffer = Commands::newConnect(authentication_);
-        // Send CONNECT command to broker
-        asyncWrite(
-                buffer.const_asio_buffer(),
-                boost::bind(&ClientConnection::handleSentPulsarConnect, shared_from_this(),
-                            boost::asio::placeholders::error, buffer));
+    SharedBuffer buffer = Commands::newConnect(authentication_);
+    // Send CONNECT command to broker
+    asyncWrite(buffer.const_asio_buffer(),
+               boost::bind(&ClientConnection::handleSentPulsarConnect, shared_from_this(),
+                           boost::asio::placeholders::error, buffer));
 }
 
 void ClientConnection::handleSentPulsarConnect(const boost::system::error_code& err,
-                                            const SharedBuffer& buffer) {
+                                               const SharedBuffer& buffer) {
     if (err) {
         LOG_ERROR(cnxString_ << "Failed to establish connection: " << err.message());
         close();
         return;
     }
 
-// Schedule the reading of CONNECTED command from broker
+    // Schedule the reading of CONNECTED command from broker
     readNextCommand();
 }
 
@@ -349,18 +350,17 @@ void ClientConnection::tcpConnectAsync() {
     }
 
     if (service_url.protocol() != "pulsar" && service_url.protocol() != "pulsar+ssl") {
-        LOG_ERROR(cnxString_ << "Invalid Url protocol '" <<  service_url.protocol() << "'. Valid values are 'pulsar' and 'pulsar+ssl'");
+        LOG_ERROR(cnxString_ << "Invalid Url protocol '" << service_url.protocol()
+                             << "'. Valid values are 'pulsar' and 'pulsar+ssl'");
         close();
         return;
     }
 
     LOG_DEBUG(cnxString_ << "Connecting to " << service_url.host() << ":" << service_url.port());
-    tcp::resolver::query query(service_url.host(),
-                               boost::lexical_cast<std::string>(service_url.port()));
+    tcp::resolver::query query(service_url.host(), boost::lexical_cast<std::string>(service_url.port()));
     resolver_->async_resolve(
-            query,
-            boost::bind(&ClientConnection::handleResolve, shared_from_this(),
-                        boost::asio::placeholders::error, boost::asio::placeholders::iterator));
+        query, boost::bind(&ClientConnection::handleResolve, shared_from_this(),
+                           boost::asio::placeholders::error, boost::asio::placeholders::iterator));
 }
 
 void ClientConnection::handleResolve(const boost::system::error_code& err,
@@ -373,11 +373,10 @@ void ClientConnection::handleResolve(const boost::system::error_code& err,
 
     if (endpointIterator != tcp::resolver::iterator()) {
         LOG_DEBUG(cnxString_ << "Resolved hostname " << endpointIterator->host_name()  //
-                << " to " << endpointIterator->endpoint());
-        socket_->async_connect(
-                *endpointIterator++,
-                boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
-                            boost::asio::placeholders::error, endpointIterator));
+                             << " to " << endpointIterator->endpoint());
+        socket_->async_connect(*endpointIterator++,
+                               boost::bind(&ClientConnection::handleTcpConnected, shared_from_this(),
+                                           boost::asio::placeholders::error, endpointIterator));
     } else {
         LOG_WARN(cnxString_ << "No IP address found");
         close();
@@ -387,11 +386,9 @@ void ClientConnection::handleResolve(const boost::system::error_code& err,
 
 void ClientConnection::readNextCommand() {
     const static uint32_t minReadSize = sizeof(uint32_t);
-    asyncReceive(
-            incomingBuffer_.asio_buffer(),
-            customAllocReadHandler(
-                    boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2,
-                                minReadSize)));
+    asyncReceive(incomingBuffer_.asio_buffer(),
+                 customAllocReadHandler(
+                     boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2, minReadSize)));
 }
 
 void ClientConnection::handleRead(const boost::system::error_code& err, size_t bytesTransferred,
@@ -405,11 +402,9 @@ void ClientConnection::handleRead(const boost::system::error_code& err, size_t b
         // Read the remaining part, use a slice of buffer to write on the next
         // region
         SharedBuffer buffer = incomingBuffer_.slice(bytesTransferred);
-        asyncReceive(
-                buffer.asio_buffer(),
-                customAllocReadHandler(
-                        boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2,
-                                    minReadSize - bytesTransferred)));
+        asyncReceive(buffer.asio_buffer(),
+                     customAllocReadHandler(boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
+                                                        _2, minReadSize - bytesTransferred)));
     } else {
         processIncomingBuffer();
     }
@@ -418,7 +413,6 @@ void ClientConnection::handleRead(const boost::system::error_code& err, size_t b
 void ClientConnection::processIncomingBuffer() {
     // Process all the available frames from the incoming buffer
     while (incomingBuffer_.readableBytes() >= sizeof(uint32_t)) {
-
         // Extract message frames from incoming buffer
         // At this point we have at least 4 bytes in the buffer
         uint32_t frameSize = incomingBuffer_.readUnsignedInt();
@@ -433,23 +427,18 @@ void ClientConnection::processIncomingBuffer() {
 
             if (bytesToReceive <= incomingBuffer_.writableBytes()) {
                 // The rest of the frame still fits in the current buffer
-                asyncReceive(
-                        incomingBuffer_.asio_buffer(),
-                        customAllocReadHandler(
-                                boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
-                                            _2, bytesToReceive)));
+                asyncReceive(incomingBuffer_.asio_buffer(),
+                             customAllocReadHandler(boost::bind(&ClientConnection::handleRead,
+                                                                shared_from_this(), _1, _2, bytesToReceive)));
                 return;
             } else {
                 // Need to allocate a buffer big enough for the frame
-                uint32_t newBufferSize = std::max<uint32_t>(DefaultBufferSize,
-                                                            frameSize + sizeof(uint32_t));
+                uint32_t newBufferSize = std::max<uint32_t>(DefaultBufferSize, frameSize + sizeof(uint32_t));
                 incomingBuffer_ = SharedBuffer::copyFrom(incomingBuffer_, newBufferSize);
 
-                asyncReceive(
-                        incomingBuffer_.asio_buffer(),
-                        customAllocReadHandler(
-                                boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
-                                            _2, bytesToReceive)));
+                asyncReceive(incomingBuffer_.asio_buffer(),
+                             customAllocReadHandler(boost::bind(&ClientConnection::handleRead,
+                                                                shared_from_this(), _1, _2, bytesToReceive)));
                 return;
             }
         }
@@ -468,14 +457,16 @@ void ClientConnection::processIncomingBuffer() {
             // Parse message metadata and extract payload
             MessageMetadata msgMetadata;
 
-            //read checksum
+            // read checksum
             bool isChecksumValid = verifyChecksum(incomingBuffer_, incomingCmd_);
 
             uint32_t metadataSize = incomingBuffer_.readUnsignedInt();
             if (!msgMetadata.ParseFromArray(incomingBuffer_.data(), metadataSize)) {
                 LOG_ERROR(cnxString_ << "[consumer id " << incomingCmd_.message().consumer_id()  //
-                        << ", message ledger id " << incomingCmd_.message().message_id().ledgerid() //
-                        << ", entry id " << incomingCmd_.message().message_id().entryid() << "] Error parsing message metadata");
+                                     << ", message ledger id "
+                                     << incomingCmd_.message().message_id().ledgerid()  //
+                                     << ", entry id " << incomingCmd_.message().message_id().entryid()
+                                     << "] Error parsing message metadata");
                 close();
                 return;
             }
@@ -501,11 +492,9 @@ void ClientConnection::processIncomingBuffer() {
         // At least we need to read 4 bytes to have the complete frame size
         uint32_t minReadSize = sizeof(uint32_t) - incomingBuffer_.readableBytes();
 
-        asyncReceive(
-                incomingBuffer_.asio_buffer(),
-                customAllocReadHandler(
-                        boost::bind(&ClientConnection::handleRead, shared_from_this(), _1, _2,
-                                    minReadSize)));
+        asyncReceive(incomingBuffer_.asio_buffer(),
+                     customAllocReadHandler(boost::bind(&ClientConnection::handleRead, shared_from_this(), _1,
+                                                        _2, minReadSize)));
         return;
     }
 
@@ -528,11 +517,12 @@ bool ClientConnection::verifyChecksum(SharedBuffer& incomingBuffer_, proto::Base
         isChecksumValid = (storedChecksum == computedChecksum);
 
         if (!isChecksumValid) {
-            LOG_ERROR("[consumer id " << incomingCmd_.message().consumer_id()  //
-                    << ", message ledger id " << incomingCmd_.message().message_id().ledgerid()//
-                    << ", entry id " << incomingCmd_.message().message_id().entryid()//
-                    << "stored-checksum" << storedChecksum << "computedChecksum" << computedChecksum//
-                    << "] Checksum verification failed");
+            LOG_ERROR("[consumer id "
+                      << incomingCmd_.message().consumer_id()                                           //
+                      << ", message ledger id " << incomingCmd_.message().message_id().ledgerid()       //
+                      << ", entry id " << incomingCmd_.message().message_id().entryid()                 //
+                      << "stored-checksum" << storedChecksum << "computedChecksum" << computedChecksum  //
+                      << "] Checksum verification failed");
         }
     } else {
         incomingBuffer_.setReaderIndex(readerIndex);
@@ -541,8 +531,7 @@ bool ClientConnection::verifyChecksum(SharedBuffer& incomingBuffer_, proto::Base
 }
 
 void ClientConnection::handleIncomingMessage(const proto::CommandMessage& msg, bool isChecksumValid,
-                                             proto::MessageMetadata& msgMetadata,
-                                             SharedBuffer& payload) {
+                                             proto::MessageMetadata& msgMetadata, SharedBuffer& payload) {
     LOG_DEBUG(cnxString_ << "Received a message from the server for consumer: " << msg.consumer_id());
 
     Lock lock(mutex_);
@@ -557,18 +546,17 @@ void ClientConnection::handleIncomingMessage(const proto::CommandMessage& msg, b
             consumer->messageReceived(shared_from_this(), msg, isChecksumValid, msgMetadata, payload);
         } else {
             consumers_.erase(msg.consumer_id());
-            LOG_DEBUG(
-                    cnxString_ << "Ignoring incoming message for already destroyed consumer " << msg.consumer_id());
+            LOG_DEBUG(cnxString_ << "Ignoring incoming message for already destroyed consumer "
+                                 << msg.consumer_id());
         }
     } else {
-        LOG_DEBUG(cnxString_ << "Got invalid consumer Id in "            //
-                << msg.consumer_id() << " -- msg: "<< msgMetadata.sequence_id());
+        LOG_DEBUG(cnxString_ << "Got invalid consumer Id in "  //
+                             << msg.consumer_id() << " -- msg: " << msgMetadata.sequence_id());
     }
 }
 
 void ClientConnection::handleIncomingCommand() {
-    LOG_DEBUG(
-            cnxString_ << "Handling incoming command: " << Commands::messageType(incomingCmd_.type()));
+    LOG_DEBUG(cnxString_ << "Handling incoming command: " << Commands::messageType(incomingCmd_.type()));
 
     switch (state_) {
         case Pending: {
@@ -600,8 +588,8 @@ void ClientConnection::handleIncomingCommand() {
                     int producerId = sendReceipt.producer_id();
                     uint64_t sequenceId = sendReceipt.sequence_id();
 
-                    LOG_DEBUG(
-                            cnxString_ << "Got receipt for producer: " << producerId << " -- msg: "<< sequenceId);
+                    LOG_DEBUG(cnxString_ << "Got receipt for producer: " << producerId
+                                         << " -- msg: " << sequenceId);
 
                     Lock lock(mutex_);
                     ProducersMap::iterator it = producers_.find(producerId);
@@ -611,13 +599,14 @@ void ClientConnection::handleIncomingCommand() {
 
                         if (producer) {
                             if (!producer->ackReceived(sequenceId)) {
-                                // If the producer fails to process the ack, we need to close the connection to give it a chance to recover from there
+                                // If the producer fails to process the ack, we need to close the connection
+                                // to give it a chance to recover from there
                                 close();
                             }
                         }
                     } else {
                         LOG_ERROR(cnxString_ << "Got invalid producer Id in SendReceipt: "  //
-                                << producerId << " -- msg: "<< sequenceId);
+                                             << producerId << " -- msg: " << sequenceId);
                     }
 
                     break;
@@ -637,7 +626,8 @@ void ClientConnection::handleIncomingCommand() {
 
                             if (producer) {
                                 if (!producer->removeCorruptMessage(sequenceId)) {
-                                    // If the producer fails to remove corrupt msg, we need to close the connection to give it a chance to recover from there
+                                    // If the producer fails to remove corrupt msg, we need to close the
+                                    // connection to give it a chance to recover from there
                                     close();
                                 }
                             }
@@ -650,8 +640,8 @@ void ClientConnection::handleIncomingCommand() {
 
                 case BaseCommand::SUCCESS: {
                     const CommandSuccess& success = incomingCmd_.success();
-                    LOG_DEBUG(
-                            cnxString_ << "Received success response from server. req_id: " << success.request_id());
+                    LOG_DEBUG(cnxString_ << "Received success response from server. req_id: "
+                                         << success.request_id());
 
                     Lock lock(mutex_);
                     PendingRequestsMap::iterator it = pendingRequests_.find(success.request_id());
@@ -668,53 +658,54 @@ void ClientConnection::handleIncomingCommand() {
 
                 case BaseCommand::PARTITIONED_METADATA_RESPONSE: {
                     const CommandPartitionedTopicMetadataResponse& partitionMetadataResponse =
-                            incomingCmd_.partitionmetadataresponse();
-                    LOG_DEBUG(
-                            cnxString_ << "Received partition-metadata response from server. req_id: " << partitionMetadataResponse.request_id());
+                        incomingCmd_.partitionmetadataresponse();
+                    LOG_DEBUG(cnxString_ << "Received partition-metadata response from server. req_id: "
+                                         << partitionMetadataResponse.request_id());
 
                     Lock lock(mutex_);
-                    PendingLookupRequestsMap::iterator it = pendingLookupRequests_.find(
-                            partitionMetadataResponse.request_id());
+                    PendingLookupRequestsMap::iterator it =
+                        pendingLookupRequests_.find(partitionMetadataResponse.request_id());
                     if (it != pendingLookupRequests_.end()) {
                         LookupDataResultPromisePtr lookupDataPromise = it->second;
                         pendingLookupRequests_.erase(it);
                         numOfPendingLookupRequest_--;
                         lock.unlock();
 
-                        if (!partitionMetadataResponse.has_response()
-                                || (partitionMetadataResponse.response()
-                                        == CommandPartitionedTopicMetadataResponse::Failed)) {
+                        if (!partitionMetadataResponse.has_response() ||
+                            (partitionMetadataResponse.response() ==
+                             CommandPartitionedTopicMetadataResponse::Failed)) {
                             if (partitionMetadataResponse.has_error()) {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed partition-metadata lookup req_id: " << partitionMetadataResponse.request_id() << " error: " << partitionMetadataResponse.error());
+                                LOG_ERROR(cnxString_ << "Failed partition-metadata lookup req_id: "
+                                                     << partitionMetadataResponse.request_id()
+                                                     << " error: " << partitionMetadataResponse.error());
                             } else {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed partition-metadata lookup req_id: " << partitionMetadataResponse.request_id() << " with empty response: ");
+                                LOG_ERROR(cnxString_ << "Failed partition-metadata lookup req_id: "
+                                                     << partitionMetadataResponse.request_id()
+                                                     << " with empty response: ");
                             }
                             lookupDataPromise->setFailed(ResultConnectError);
                         } else {
-                            LookupDataResultPtr lookupResultPtr = boost::make_shared<
-                                    LookupDataResult>();
+                            LookupDataResultPtr lookupResultPtr = boost::make_shared<LookupDataResult>();
                             lookupResultPtr->setPartitions(partitionMetadataResponse.partitions());
                             lookupDataPromise->setValue(lookupResultPtr);
                         }
 
                     } else {
-                        LOG_WARN(
-                                "Received unknown request id from server: " << partitionMetadataResponse.request_id());
+                        LOG_WARN("Received unknown request id from server: "
+                                 << partitionMetadataResponse.request_id());
                     }
                     break;
                 }
 
                 case BaseCommand::CONSUMER_STATS_RESPONSE: {
-                    const CommandConsumerStatsResponse& consumerStatsResponse = incomingCmd_.consumerstatsresponse();
-                    LOG_DEBUG(
-                            cnxString_
-                                    << "ConsumerStatsResponse command - Received consumer stats response from server. req_id: "
-                                    << consumerStatsResponse.request_id());
+                    const CommandConsumerStatsResponse& consumerStatsResponse =
+                        incomingCmd_.consumerstatsresponse();
+                    LOG_DEBUG(cnxString_ << "ConsumerStatsResponse command - Received consumer stats "
+                                            "response from server. req_id: "
+                                         << consumerStatsResponse.request_id());
                     Lock lock(mutex_);
-                    PendingConsumerStatsMap::iterator it = pendingConsumerStatsMap_.find(
-                            consumerStatsResponse.request_id());
+                    PendingConsumerStatsMap::iterator it =
+                        pendingConsumerStatsMap_.find(consumerStatsResponse.request_id());
                     if (it != pendingConsumerStatsMap_.end()) {
                         Promise<Result, BrokerConsumerStatsImpl> consumerStatsPromise = it->second;
                         pendingConsumerStatsMap_.erase(it);
@@ -727,66 +718,65 @@ void ClientConnection::handleIncomingCommand() {
                             }
                             consumerStatsPromise.setFailed(getResult(consumerStatsResponse.error_code()));
                         } else {
-                            LOG_DEBUG(
-                                    cnxString_
-                                            << "ConsumerStatsResponse command - Received consumer stats response from server. req_id: "
-                                            << consumerStatsResponse.request_id() << " Stats: ");
-                            BrokerConsumerStatsImpl brokerStats(consumerStatsResponse.msgrateout(),
-                                                            consumerStatsResponse.msgthroughputout(),
-                                                            consumerStatsResponse.msgrateredeliver(),
-                                                            consumerStatsResponse.consumername(),
-                                                            consumerStatsResponse.availablepermits(),
-                                                            consumerStatsResponse.unackedmessages(),
-                                                            consumerStatsResponse.blockedconsumeronunackedmsgs(),
-                                                            consumerStatsResponse.address(),
-                                                            consumerStatsResponse.connectedsince(),
-                                                            consumerStatsResponse.type(),
-                                                            consumerStatsResponse.msgrateexpired(),
-                                                            consumerStatsResponse.msgbacklog());
+                            LOG_DEBUG(cnxString_ << "ConsumerStatsResponse command - Received consumer stats "
+                                                    "response from server. req_id: "
+                                                 << consumerStatsResponse.request_id() << " Stats: ");
+                            BrokerConsumerStatsImpl brokerStats(
+                                consumerStatsResponse.msgrateout(), consumerStatsResponse.msgthroughputout(),
+                                consumerStatsResponse.msgrateredeliver(),
+                                consumerStatsResponse.consumername(),
+                                consumerStatsResponse.availablepermits(),
+                                consumerStatsResponse.unackedmessages(),
+                                consumerStatsResponse.blockedconsumeronunackedmsgs(),
+                                consumerStatsResponse.address(), consumerStatsResponse.connectedsince(),
+                                consumerStatsResponse.type(), consumerStatsResponse.msgrateexpired(),
+                                consumerStatsResponse.msgbacklog());
                             consumerStatsPromise.setValue(brokerStats);
                         }
                     } else {
-                        LOG_WARN(
-                                "ConsumerStatsResponse command - Received unknown request id from server: "
-                                        << consumerStatsResponse.request_id());
+                        LOG_WARN("ConsumerStatsResponse command - Received unknown request id from server: "
+                                 << consumerStatsResponse.request_id());
                     }
                     break;
-
                 }
 
                 case BaseCommand::LOOKUP_RESPONSE: {
-                    const CommandLookupTopicResponse& lookupTopicResponse = incomingCmd_.lookuptopicresponse();
-                    LOG_DEBUG(
-                            cnxString_ << "Received lookup response from server. req_id: " << lookupTopicResponse.request_id());
+                    const CommandLookupTopicResponse& lookupTopicResponse =
+                        incomingCmd_.lookuptopicresponse();
+                    LOG_DEBUG(cnxString_ << "Received lookup response from server. req_id: "
+                                         << lookupTopicResponse.request_id());
 
                     Lock lock(mutex_);
-                    PendingLookupRequestsMap::iterator it = pendingLookupRequests_.find(
-                            lookupTopicResponse.request_id());
+                    PendingLookupRequestsMap::iterator it =
+                        pendingLookupRequests_.find(lookupTopicResponse.request_id());
                     if (it != pendingLookupRequests_.end()) {
                         LookupDataResultPromisePtr lookupDataPromise = it->second;
                         pendingLookupRequests_.erase(it);
                         numOfPendingLookupRequest_--;
                         lock.unlock();
 
-                        if (!lookupTopicResponse.has_response()
-                                || (lookupTopicResponse.response()
-                                        == CommandLookupTopicResponse::Failed)) {
+                        if (!lookupTopicResponse.has_response() ||
+                            (lookupTopicResponse.response() == CommandLookupTopicResponse::Failed)) {
                             if (lookupTopicResponse.has_error()) {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed lookup req_id: " << lookupTopicResponse.request_id() << " error: " << lookupTopicResponse.error());
+                                LOG_ERROR(cnxString_
+                                          << "Failed lookup req_id: " << lookupTopicResponse.request_id()
+                                          << " error: " << lookupTopicResponse.error());
                             } else {
-                                LOG_ERROR(
-                                        cnxString_ << "Failed lookup req_id: " << lookupTopicResponse.request_id() << " with empty response: ");
+                                LOG_ERROR(cnxString_
+                                          << "Failed lookup req_id: " << lookupTopicResponse.request_id()
+                                          << " with empty response: ");
                             }
-                            lookupDataPromise -> setFailed(ResultConnectError);
+                            lookupDataPromise->setFailed(ResultConnectError);
                         } else {
-                            LOG_DEBUG(
-                                    cnxString_ << "Received lookup response from server. req_id: " << lookupTopicResponse.request_id()  //
-                                    << " -- broker-url: " << lookupTopicResponse.brokerserviceurl() << " -- broker-tls-url: "//
-                                    << lookupTopicResponse.brokerserviceurltls() << " authoritative: " << lookupTopicResponse.authoritative()//
-                                    << " redirect: " << lookupTopicResponse.response());
-                            LookupDataResultPtr lookupResultPtr =
-                                                            boost::make_shared<LookupDataResult>();
+                            LOG_DEBUG(cnxString_
+                                      << "Received lookup response from server. req_id: "
+                                      << lookupTopicResponse.request_id()  //
+                                      << " -- broker-url: " << lookupTopicResponse.brokerserviceurl()
+                                      << " -- broker-tls-url: "  //
+                                      << lookupTopicResponse.brokerserviceurltls()
+                                      << " authoritative: " << lookupTopicResponse.authoritative()  //
+                                      << " redirect: " << lookupTopicResponse.response());
+                            LookupDataResultPtr lookupResultPtr = boost::make_shared<LookupDataResult>();
 
                             if (tlsSocket_) {
                                 lookupResultPtr->setBrokerUrl(lookupTopicResponse.brokerserviceurltls());
@@ -794,39 +784,35 @@ void ClientConnection::handleIncomingCommand() {
                                 lookupResultPtr->setBrokerUrl(lookupTopicResponse.brokerserviceurl());
                             }
 
-                            lookupResultPtr->setBrokerUrlSsl(
-                                    lookupTopicResponse.brokerserviceurltls());
+                            lookupResultPtr->setBrokerUrlSsl(lookupTopicResponse.brokerserviceurltls());
                             lookupResultPtr->setAuthoritative(lookupTopicResponse.authoritative());
-                            lookupResultPtr->setRedirect(
-                                    lookupTopicResponse.response()
-                                            == CommandLookupTopicResponse::Redirect);
+                            lookupResultPtr->setRedirect(lookupTopicResponse.response() ==
+                                                         CommandLookupTopicResponse::Redirect);
                             lookupDataPromise->setValue(lookupResultPtr);
                         }
 
                     } else {
                         LOG_WARN(
-                                "Received unknown request id from server: " << lookupTopicResponse.request_id());
+                            "Received unknown request id from server: " << lookupTopicResponse.request_id());
                     }
                     break;
                 }
 
-
                 case BaseCommand::PRODUCER_SUCCESS: {
                     const CommandProducerSuccess& producerSuccess = incomingCmd_.producer_success();
-                    LOG_DEBUG(
-                            cnxString_ << "Received success producer response from server. req_id: " << producerSuccess.request_id()  //
-                            << " -- producer name: " << producerSuccess.producer_name());
+                    LOG_DEBUG(cnxString_ << "Received success producer response from server. req_id: "
+                                         << producerSuccess.request_id()  //
+                                         << " -- producer name: " << producerSuccess.producer_name());
 
                     Lock lock(mutex_);
-                    PendingRequestsMap::iterator it = pendingRequests_.find(
-                            producerSuccess.request_id());
+                    PendingRequestsMap::iterator it = pendingRequests_.find(producerSuccess.request_id());
                     if (it != pendingRequests_.end()) {
                         PendingRequestData requestData = it->second;
                         pendingRequests_.erase(it);
                         lock.unlock();
 
                         requestData.promise.setValue(
-                                { producerSuccess.producer_name(), producerSuccess.last_sequence_id() });
+                            {producerSuccess.producer_name(), producerSuccess.last_sequence_id()});
                         requestData.timer->cancel();
                     }
                     break;
@@ -835,8 +821,8 @@ void ClientConnection::handleIncomingCommand() {
                 case BaseCommand::ERROR: {
                     const CommandError& error = incomingCmd_.error();
                     Result result = getResult(error.error());
-                    LOG_WARN(
-                            cnxString_ << "Received error response from server: " << result << " -- req_id: "<< error.request_id());
+                    LOG_WARN(cnxString_ << "Received error response from server: " << result
+                                        << " -- req_id: " << error.request_id());
 
                     Lock lock(mutex_);
                     PendingRequestsMap::iterator it = pendingRequests_.find(error.request_id());
@@ -870,8 +856,8 @@ void ClientConnection::handleIncomingCommand() {
                             producer->disconnectProducer();
                         }
                     } else {
-                        LOG_ERROR(
-                                cnxString_ << "Got invalid producer Id in closeProducer command: "<< producerId);
+                        LOG_ERROR(cnxString_ << "Got invalid producer Id in closeProducer command: "
+                                             << producerId);
                     }
 
                     break;
@@ -894,8 +880,8 @@ void ClientConnection::handleIncomingCommand() {
                             consumer->disconnectConsumer();
                         }
                     } else {
-                        LOG_ERROR(
-                                cnxString_ << "Got invalid consumer Id in closeConsumer command: "<< consumerId);
+                        LOG_ERROR(cnxString_ << "Got invalid consumer Id in closeConsumer command: "
+                                             << consumerId);
                     }
 
                     break;
@@ -903,7 +889,7 @@ void ClientConnection::handleIncomingCommand() {
 
                 case BaseCommand::PING: {
                     // Respond to ping request
-                    LOG_DEBUG(cnxString_  << "Replying to ping command");
+                    LOG_DEBUG(cnxString_ << "Replying to ping command");
                     sendCommand(Commands::newPong());
                     break;
                 }
@@ -924,8 +910,8 @@ void ClientConnection::handleIncomingCommand() {
     }
 }
 
-Future<Result, BrokerConsumerStatsImpl>
-ClientConnection::newConsumerStats(uint64_t consumerId, uint64_t requestId) {
+Future<Result, BrokerConsumerStatsImpl> ClientConnection::newConsumerStats(uint64_t consumerId,
+                                                                           uint64_t requestId) {
     Lock lock(mutex_);
     Promise<Result, BrokerConsumerStatsImpl> promise;
     if (isClosed()) {
@@ -940,17 +926,14 @@ ClientConnection::newConsumerStats(uint64_t consumerId, uint64_t requestId) {
 }
 
 void ClientConnection::newTopicLookup(const std::string& destinationName, bool authoritative,
-                                      const uint64_t requestId,
-                                      LookupDataResultPromisePtr promise) {
-    newLookup(Commands::newLookup(destinationName, authoritative, requestId),
-              requestId, promise);
+                                      const uint64_t requestId, LookupDataResultPromisePtr promise) {
+    newLookup(Commands::newLookup(destinationName, authoritative, requestId), requestId, promise);
 }
 
 void ClientConnection::newPartitionedMetadataLookup(const std::string& destinationName,
                                                     const uint64_t requestId,
                                                     LookupDataResultPromisePtr promise) {
-    newLookup(Commands::newPartitionMetadataRequest(destinationName, requestId),
-              requestId, promise);
+    newLookup(Commands::newPartitionMetadataRequest(destinationName, requestId), requestId, promise);
 }
 
 void ClientConnection::newLookup(const SharedBuffer& cmd, const uint64_t requestId,
@@ -977,12 +960,9 @@ void ClientConnection::sendCommand(const SharedBuffer& cmd) {
     Lock lock(mutex_);
 
     if (pendingWriteOperations_++ == 0) {
-
         // Write immediately to socket
-        asyncWrite(
-                cmd.const_asio_buffer(),
-                customAllocWriteHandler(
-                        boost::bind(&ClientConnection::handleSend, shared_from_this(), _1, cmd)));
+        asyncWrite(cmd.const_asio_buffer(), customAllocWriteHandler(boost::bind(
+                                                &ClientConnection::handleSend, shared_from_this(), _1, cmd)));
     } else {
         // Queue to send later
         pendingWriteBuffers_.push_back(cmd);
@@ -993,16 +973,12 @@ void ClientConnection::sendMessage(const OpSendMsg& opSend) {
     Lock lock(mutex_);
 
     if (pendingWriteOperations_++ == 0) {
-
-        PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_,
-                                                    opSend.producerId_, opSend.sequenceId_,
-                                                    getChecksumType(), opSend.msg_);
+        PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_, opSend.producerId_,
+                                                    opSend.sequenceId_, getChecksumType(), opSend.msg_);
 
         // Write immediately to socket
-        asyncWrite(
-                buffer,
-                customAllocWriteHandler(
-                        boost::bind(&ClientConnection::handleSendPair, shared_from_this(), _1)));
+        asyncWrite(buffer, customAllocWriteHandler(
+                               boost::bind(&ClientConnection::handleSendPair, shared_from_this(), _1)));
     } else {
         // Queue to send later
         pendingWriteBuffers_.push_back(opSend);
@@ -1037,24 +1013,18 @@ void ClientConnection::sendPendingCommands() {
 
         if (any.type() == typeid(SharedBuffer)) {
             SharedBuffer buffer = boost::any_cast<SharedBuffer>(any);
-            asyncWrite(
-                    buffer.const_asio_buffer(),
-                    customAllocWriteHandler(
-                            boost::bind(&ClientConnection::handleSend, shared_from_this(), _1,
-                                        buffer)));
+            asyncWrite(buffer.const_asio_buffer(),
+                       customAllocWriteHandler(
+                           boost::bind(&ClientConnection::handleSend, shared_from_this(), _1, buffer)));
         } else {
             assert(any.type() == typeid(OpSendMsg));
 
             const OpSendMsg& op = boost::any_cast<const OpSendMsg&>(any);
-            PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_,
-                                                        op.producerId_, op.sequenceId_,
-                                                        getChecksumType(), op.msg_);
-
-            asyncWrite(
-                    buffer,
-                    customAllocWriteHandler(
-                            boost::bind(&ClientConnection::handleSendPair, shared_from_this(),
-                                        _1)));
+            PairSharedBuffer buffer = Commands::newSend(outgoingBuffer_, outgoingCmd_, op.producerId_,
+                                                        op.sequenceId_, getChecksumType(), op.msg_);
+
+            asyncWrite(buffer, customAllocWriteHandler(
+                                   boost::bind(&ClientConnection::handleSendPair, shared_from_this(), _1)));
         }
     } else {
         // No more pending writes
@@ -1076,8 +1046,7 @@ Future<Result, ResponseData> ClientConnection::sendRequestWithId(SharedBuffer cm
     requestData.timer = executor_->createDeadlineTimer();
     requestData.timer->expires_from_now(operationsTimeout_);
     requestData.timer->async_wait(
-            boost::bind(&ClientConnection::handleRequestTimeout, shared_from_this(), _1,
-                        requestData));
+        boost::bind(&ClientConnection::handleRequestTimeout, shared_from_this(), _1, requestData));
 
     pendingRequests_.insert(std::make_pair(requestId, requestData));
     lock.unlock();
@@ -1109,7 +1078,7 @@ void ClientConnection::handleKeepAliveTimeout() {
 
         keepAliveTimer_->expires_from_now(boost::posix_time::seconds(KeepAliveIntervalInSeconds));
         keepAliveTimer_->async_wait(
-                boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
+            boost::bind(&ClientConnection::handleKeepAliveTimeout, shared_from_this()));
     }
 }
 
@@ -1153,7 +1122,7 @@ void ClientConnection::close() {
     connectPromise_.setFailed(ResultConnectError);
 
     // Fail all pending operations on the connection
-    for (PendingRequestsMap::iterator it = pendingRequests_.begin(); it != pendingRequests_.end(); ++it ) {
+    for (PendingRequestsMap::iterator it = pendingRequests_.begin(); it != pendingRequests_.end(); ++it) {
         it->second.promise.setFailed(ResultConnectError);
     }
 
@@ -1167,11 +1136,11 @@ void ClientConnection::close() {
     pendingConsumerStatsMap_.swap(pendingConsumerStatsMap);
     lock.unlock();
 
-    for (PendingLookupRequestsMap::iterator it = pendingLookupRequests.begin(); it != pendingLookupRequests.end(); ++it) {
+    for (PendingLookupRequestsMap::iterator it = pendingLookupRequests.begin();
+         it != pendingLookupRequests.end(); ++it) {
         it->second->setFailed(ResultConnectError);
     }
 
-
     for (PendingConsumerStatsMap::iterator it = pendingConsumerStatsMap.begin();
          it != pendingConsumerStatsMap.end(); ++it) {
         LOG_ERROR(cnxString_ << " Closing Client Connection, please try again later");
@@ -1183,9 +1152,7 @@ void ClientConnection::close() {
     }
 }
 
-bool ClientConnection::isClosed() const {
-    return state_ == Disconnected;
-}
+bool ClientConnection::isClosed() const { return state_ == Disconnected; }
 
 Future<Result, ClientConnectionWeakPtr> ClientConnection::getConnectFuture() {
     return connectPromise_.getFuture();
@@ -1211,20 +1178,13 @@ void ClientConnection::removeConsumer(int consumerId) {
     consumers_.erase(consumerId);
 }
 
-const std::string& ClientConnection::brokerAddress() const {
-    return address_;
-}
+const std::string& ClientConnection::brokerAddress() const { return address_; }
 
-const std::string& ClientConnection::cnxString() const {
-    return cnxString_;
-}
+const std::string& ClientConnection::cnxString() const { return cnxString_; }
 
-int ClientConnection::getServerProtocolVersion() const {
-    return serverProtocolVersion_;
-}
+int ClientConnection::getServerProtocolVersion() const { return serverProtocolVersion_; }
 
 Commands::ChecksumType ClientConnection::getChecksumType() const {
-    return getServerProtocolVersion() >= proto::v6 ?
-            Commands::Crc32c : Commands::None;
+    return getServerProtocolVersion() >= proto::v6 ? Commands::Crc32c : Commands::None;
 }
 }
diff --git a/pulsar-client-cpp/lib/ClientConnection.h b/pulsar-client-cpp/lib/ClientConnection.h
index 171a6fb4f..3dd8fc68d 100644
--- a/pulsar-client-cpp/lib/ClientConnection.h
+++ b/pulsar-client-cpp/lib/ClientConnection.h
@@ -71,14 +71,15 @@ struct OpSendMsg;
 typedef std::pair<std::string, int64_t> ResponseData;
 
 class ClientConnection : public boost::enable_shared_from_this<ClientConnection> {
-    enum State {
+    enum State
+    {
         Pending,
         TcpConnected,
         Ready,
         Disconnected
     };
 
- public:
+   public:
     typedef boost::shared_ptr<boost::asio::ip::tcp::socket> SocketPtr;
     typedef boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > TlsSocketPtr;
     typedef boost::shared_ptr<ClientConnection> ConnectionPtr;
@@ -109,7 +110,7 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     Future<Result, ClientConnectionWeakPtr> getCloseFuture();
 
     void newTopicLookup(const std::string& destinationName, bool authoritative, const uint64_t requestId,
-                   LookupDataResultPromisePtr promise);
+                        LookupDataResultPromisePtr promise);
 
     void newPartitionedMetadataLookup(const std::string& destinationName, const uint64_t requestId,
                                       LookupDataResultPromisePtr promise);
@@ -137,8 +138,9 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
 
     Commands::ChecksumType getChecksumType() const;
 
-    Future<Result, BrokerConsumerStatsImpl> newConsumerStats(uint64_t consumerId, uint64_t requestId) ;
- private:
+    Future<Result, BrokerConsumerStatsImpl> newConsumerStats(uint64_t consumerId, uint64_t requestId);
+
+   private:
     struct PendingRequestData {
         Promise<Result, ResponseData> promise;
         DeadlineTimerPtr timer;
@@ -176,26 +178,24 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     void handleSend(const boost::system::error_code& err, const SharedBuffer& cmd);
     void handleSendPair(const boost::system::error_code& err);
     void sendPendingCommands();
-    void newLookup(const SharedBuffer& cmd, const uint64_t requestId,
-                   LookupDataResultPromisePtr promise);
-
+    void newLookup(const SharedBuffer& cmd, const uint64_t requestId, LookupDataResultPromisePtr promise);
 
     void handleRequestTimeout(const boost::system::error_code& ec, PendingRequestData pendingRequestData);
 
     void handleKeepAliveTimeout();
 
-    template<typename Handler>
+    template <typename Handler>
     inline AllocHandler<Handler> customAllocReadHandler(Handler h) {
         return AllocHandler<Handler>(readHandlerAllocator_, h);
     }
 
-    template<typename Handler>
+    template <typename Handler>
     inline AllocHandler<Handler> customAllocWriteHandler(Handler h) {
         return AllocHandler<Handler>(writeHandlerAllocator_, h);
     }
 
-    template<typename ConstBufferSequence, typename WriteHandler>
-    inline void asyncWrite(const ConstBufferSequence &buffers, WriteHandler handler) {
+    template <typename ConstBufferSequence, typename WriteHandler>
+    inline void asyncWrite(const ConstBufferSequence& buffers, WriteHandler handler) {
         if (tlsSocket_) {
             boost::asio::async_write(*tlsSocket_, buffers, handler);
         } else {
@@ -203,8 +203,8 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
         }
     }
 
-    template<typename MutableBufferSequence, typename ReadHandler>
-    inline void asyncReceive(const MutableBufferSequence &buffers, ReadHandler handler) {
+    template <typename MutableBufferSequence, typename ReadHandler>
+    inline void asyncReceive(const MutableBufferSequence& buffers, ReadHandler handler) {
         if (tlsSocket_) {
             tlsSocket_->async_read_some(buffers, handler);
         } else {
@@ -259,7 +259,6 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     typedef std::map<uint64_t, Promise<Result, BrokerConsumerStatsImpl> > PendingConsumerStatsMap;
     PendingConsumerStatsMap pendingConsumerStatsMap_;
 
-
     boost::mutex mutex_;
     typedef boost::unique_lock<boost::mutex> Lock;
 
@@ -278,7 +277,7 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
     DeadlineTimerPtr keepAliveTimer_;
     DeadlineTimerPtr consumerStatsRequestTimer_;
 
-    void handleConsumerStatsTimeout(const boost::system::error_code &ec,
+    void handleConsumerStatsTimeout(const boost::system::error_code& ec,
                                     std::vector<uint64_t> consumerStatsRequests);
 
     void startConsumerStatsTimer(std::vector<uint64_t> consumerStatsRequests);
@@ -288,7 +287,6 @@ class ClientConnection : public boost::enable_shared_from_this<ClientConnection>
 
     bool isTlsAllowInsecureConnection_;
 };
-
 }
 
-#endif//_PULSAR_CLIENT_CONNECTION_HEADER_
+#endif  //_PULSAR_CLIENT_CONNECTION_HEADER_
diff --git a/pulsar-client-cpp/lib/ClientImpl.cc b/pulsar-client-cpp/lib/ClientImpl.cc
index 99be8b684..a95cd4958 100644
--- a/pulsar-client-cpp/lib/ClientImpl.cc
+++ b/pulsar-client-cpp/lib/ClientImpl.cc
@@ -36,389 +36,360 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    static const char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
-
-    const std::string generateRandomName() {
-        unsigned char hash[SHA_DIGEST_LENGTH];  // == 20;
-        boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
-        long nanoSeconds = t.time_of_day().total_nanoseconds();
-        std::stringstream ss;
-        ss << nanoSeconds;
-        SHA1(reinterpret_cast<const unsigned char*>(ss.str().c_str()), ss.str().length(), hash);
-
-        const int nameLength = 6;
-        std::stringstream hexHash;
-        for (int i = 0; i < nameLength / 2; i++) {
-            hexHash << hexDigits[(hash[i] & 0xF0) >> 4];
-            hexHash << hexDigits[hash[i] & 0x0F];
-        }
-
-        return hexHash.str();
-    }
-    typedef boost::unique_lock<boost::mutex> Lock;
-
-    ClientImpl::ClientImpl(const std::string& serviceUrl,
-                           const ClientConfiguration& clientConfiguration, bool poolConnections)
-        : mutex_(),
-          state_(Open),
-          serviceUrl_(serviceUrl),
-          clientConfiguration_(clientConfiguration),
-          ioExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getIOThreads())),
-          listenerExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
-          partitionListenerExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
-          pool_(clientConfiguration, ioExecutorProvider_, clientConfiguration.getAuthPtr(), poolConnections),
-          producerIdGenerator_(0),
-          consumerIdGenerator_(0),
-          requestIdGenerator_(0) {
-        LogUtils::init(clientConfiguration.getLogConfFilePath());
-        if (serviceUrl_.compare(0, 4, "http") == 0) {
-            LOG_DEBUG("Using HTTP Lookup");
-            lookupServicePtr_ = boost::make_shared<HTTPLookupService>(boost::cref(serviceUrl_),
-                                                                      boost::cref(clientConfiguration_),
-                                                                      boost::cref(
-                                                                              clientConfiguration.getAuthPtr()));
-        } else {
-            LOG_DEBUG("Using Binary Lookup");
-            lookupServicePtr_ = boost::make_shared<BinaryProtoLookupService>(boost::ref(pool_), boost::ref(serviceUrl));
-        }
+static const char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7',
+                                 '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+const std::string generateRandomName() {
+    unsigned char hash[SHA_DIGEST_LENGTH];  // == 20;
+    boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
+    long nanoSeconds = t.time_of_day().total_nanoseconds();
+    std::stringstream ss;
+    ss << nanoSeconds;
+    SHA1(reinterpret_cast<const unsigned char*>(ss.str().c_str()), ss.str().length(), hash);
+
+    const int nameLength = 6;
+    std::stringstream hexHash;
+    for (int i = 0; i < nameLength / 2; i++) {
+        hexHash << hexDigits[(hash[i] & 0xF0) >> 4];
+        hexHash << hexDigits[hash[i] & 0x0F];
     }
 
-    ClientImpl::~ClientImpl() {
-        shutdown();
+    return hexHash.str();
+}
+typedef boost::unique_lock<boost::mutex> Lock;
+
+ClientImpl::ClientImpl(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
+                       bool poolConnections)
+    : mutex_(),
+      state_(Open),
+      serviceUrl_(serviceUrl),
+      clientConfiguration_(clientConfiguration),
+      ioExecutorProvider_(boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getIOThreads())),
+      listenerExecutorProvider_(
+          boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
+      partitionListenerExecutorProvider_(
+          boost::make_shared<ExecutorServiceProvider>(clientConfiguration.getMessageListenerThreads())),
+      pool_(clientConfiguration, ioExecutorProvider_, clientConfiguration.getAuthPtr(), poolConnections),
+      producerIdGenerator_(0),
+      consumerIdGenerator_(0),
+      requestIdGenerator_(0) {
+    LogUtils::init(clientConfiguration.getLogConfFilePath());
+    if (serviceUrl_.compare(0, 4, "http") == 0) {
+        LOG_DEBUG("Using HTTP Lookup");
+        lookupServicePtr_ =
+            boost::make_shared<HTTPLookupService>(boost::cref(serviceUrl_), boost::cref(clientConfiguration_),
+                                                  boost::cref(clientConfiguration.getAuthPtr()));
+    } else {
+        LOG_DEBUG("Using Binary Lookup");
+        lookupServicePtr_ =
+            boost::make_shared<BinaryProtoLookupService>(boost::ref(pool_), boost::ref(serviceUrl));
     }
+}
 
-    const ClientConfiguration& ClientImpl::conf() const {
-        return clientConfiguration_;
-    }
+ClientImpl::~ClientImpl() { shutdown(); }
 
-    ExecutorServiceProviderPtr ClientImpl::getIOExecutorProvider() {
-        return ioExecutorProvider_;
-    }
+const ClientConfiguration& ClientImpl::conf() const { return clientConfiguration_; }
 
-    ExecutorServiceProviderPtr ClientImpl::getListenerExecutorProvider() {
-        return listenerExecutorProvider_;
-    }
+ExecutorServiceProviderPtr ClientImpl::getIOExecutorProvider() { return ioExecutorProvider_; }
+
+ExecutorServiceProviderPtr ClientImpl::getListenerExecutorProvider() { return listenerExecutorProvider_; }
 
-    ExecutorServiceProviderPtr ClientImpl::getPartitionListenerExecutorProvider() {
-        return partitionListenerExecutorProvider_;
+ExecutorServiceProviderPtr ClientImpl::getPartitionListenerExecutorProvider() {
+    return partitionListenerExecutorProvider_;
+}
+void ClientImpl::createProducerAsync(const std::string& topic, ProducerConfiguration conf,
+                                     CreateProducerCallback callback) {
+    DestinationNamePtr dn;
+    {
+        Lock lock(mutex_);
+        if (state_ != Open) {
+            lock.unlock();
+            callback(ResultAlreadyClosed, Producer());
+            return;
+        } else if (!(dn = DestinationName::get(topic))) {
+            lock.unlock();
+            callback(ResultInvalidTopicName, Producer());
+            return;
+        }
     }
-    void ClientImpl::createProducerAsync(const std::string& topic,
-                                         ProducerConfiguration conf,
-                                         CreateProducerCallback callback) {
-        DestinationNamePtr dn;
-        {
-            Lock lock(mutex_);
-            if (state_ != Open) {
-                lock.unlock();
-                callback(ResultAlreadyClosed, Producer());
-                return;
-            } else if (!(dn = DestinationName::get(topic))) {
-                lock.unlock();
-                callback(ResultInvalidTopicName, Producer());
-                return;
-            }
+    lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(
+        boost::bind(&ClientImpl::handleCreateProducer, shared_from_this(), _1, _2, dn, conf, callback));
+}
+
+void ClientImpl::handleCreateProducer(const Result result, const LookupDataResultPtr partitionMetadata,
+                                      DestinationNamePtr dn, ProducerConfiguration conf,
+                                      CreateProducerCallback callback) {
+    if (!result) {
+        ProducerImplBasePtr producer;
+        if (partitionMetadata->getPartitions() > 1) {
+            producer = boost::make_shared<PartitionedProducerImpl>(shared_from_this(), dn,
+                                                                   partitionMetadata->getPartitions(), conf);
+        } else {
+            producer = boost::make_shared<ProducerImpl>(shared_from_this(), dn->toString(), conf);
         }
-        lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(&ClientImpl::handleCreateProducer,
-                                    shared_from_this(), _1, _2, dn, conf, callback));
+        producer->getProducerCreatedFuture().addListener(
+            boost::bind(&ClientImpl::handleProducerCreated, shared_from_this(), _1, _2, callback, producer));
+        Lock lock(mutex_);
+        producers_.push_back(producer);
+        lock.unlock();
+        producer->start();
+    } else {
+        LOG_ERROR("Error Checking/Getting Partition Metadata while creating producer on "
+                  << dn->toString() << " -- " << result);
+        callback(result, Producer());
     }
+}
 
-    void ClientImpl::handleCreateProducer(const Result result,
-            const LookupDataResultPtr partitionMetadata,
-            DestinationNamePtr dn,
-            ProducerConfiguration conf,
-            CreateProducerCallback callback) {
-        if (!result) {
-            ProducerImplBasePtr producer;
-            if (partitionMetadata->getPartitions() > 1) {
-                producer = boost::make_shared<PartitionedProducerImpl>(shared_from_this(),
-                                                                       dn, partitionMetadata->getPartitions(), conf);
-            } else {
-                producer = boost::make_shared<ProducerImpl>(shared_from_this(), dn->toString(), conf);
-            }
-            producer->getProducerCreatedFuture().addListener(boost::bind(&ClientImpl::handleProducerCreated,
-                                                                         shared_from_this(), _1, _2, callback,
-                                                                         producer));
-            Lock lock(mutex_);
-            producers_.push_back(producer);
+void ClientImpl::handleProducerCreated(Result result, ProducerImplBaseWeakPtr producerBaseWeakPtr,
+                                       CreateProducerCallback callback, ProducerImplBasePtr producer) {
+    callback(result, Producer(producer));
+}
+
+void ClientImpl::createReaderAsync(const std::string& topic, const MessageId& startMessageId,
+                                   const ReaderConfiguration& conf, ReaderCallback callback) {
+    DestinationNamePtr dn;
+    {
+        Lock lock(mutex_);
+        if (state_ != Open) {
             lock.unlock();
-            producer->start();
-        } else {
-            LOG_ERROR("Error Checking/Getting Partition Metadata while creating producer on " << dn->toString() << " -- " << result );
-            callback (result, Producer());
+            callback(ResultAlreadyClosed, Reader());
+            return;
+        } else if (!(dn = DestinationName::get(topic))) {
+            lock.unlock();
+            callback(ResultInvalidTopicName, Reader());
+            return;
         }
+    }
 
+    BatchMessageId msgId(startMessageId);
+    lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(
+        &ClientImpl::handleReaderMetadataLookup, shared_from_this(), _1, _2, dn, msgId, conf, callback));
+}
+
+void ClientImpl::handleReaderMetadataLookup(const Result result, const LookupDataResultPtr partitionMetadata,
+                                            DestinationNamePtr dn, BatchMessageId startMessageId,
+                                            ReaderConfiguration conf, ReaderCallback callback) {
+    if (result != ResultOk) {
+        LOG_ERROR("Error Checking/Getting Partition Metadata while creating reader: " << result);
+        callback(result, Reader());
+        return;
     }
 
-    void ClientImpl::handleProducerCreated(Result result, ProducerImplBaseWeakPtr producerBaseWeakPtr,
-                                           CreateProducerCallback callback, ProducerImplBasePtr producer) {
-        callback(result, Producer(producer));
+    if (partitionMetadata->getPartitions() > 1) {
+        LOG_ERROR("Topic reader cannot be created on a partitioned topic: " << dn->toString());
+        callback(ResultOperationNotSupported, Reader());
+        return;
     }
 
-    void ClientImpl::createReaderAsync(const std::string& topic,
-            const MessageId& startMessageId,
-            const ReaderConfiguration& conf,
-            ReaderCallback callback) {
-        DestinationNamePtr dn;
-        {
-            Lock lock(mutex_);
-            if (state_ != Open) {
-                lock.unlock();
-                callback(ResultAlreadyClosed, Reader());
-                return;
-            } else if (!(dn = DestinationName::get(topic))) {
-                lock.unlock();
-                callback(ResultInvalidTopicName, Reader());
-                return;
-            }
-        }
+    ReaderImplPtr reader = boost::make_shared<ReaderImpl>(shared_from_this(), dn->toString(), conf,
+                                                          getListenerExecutorProvider()->get(), callback);
+    reader->start(startMessageId);
 
-        BatchMessageId msgId(startMessageId);
-        lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(&ClientImpl::handleReaderMetadataLookup,
-                        shared_from_this(), _1, _2, dn, msgId, conf, callback));
-    }
+    Lock lock(mutex_);
+    consumers_.push_back(reader->getConsumer());
+}
 
-    void ClientImpl::handleReaderMetadataLookup(const Result result,
-            const LookupDataResultPtr partitionMetadata,
-            DestinationNamePtr dn,
-            BatchMessageId startMessageId,
-            ReaderConfiguration conf,
-            ReaderCallback callback) {
-        if (result != ResultOk) {
-            LOG_ERROR("Error Checking/Getting Partition Metadata while creating reader: " << result);
-            callback(result, Reader());
+void ClientImpl::subscribeAsync(const std::string& topic, const std::string& consumerName,
+                                const ConsumerConfiguration& conf, SubscribeCallback callback) {
+    DestinationNamePtr dn;
+    {
+        Lock lock(mutex_);
+        if (state_ != Open) {
+            lock.unlock();
+            callback(ResultAlreadyClosed, Consumer());
             return;
-        }
-
-        if (partitionMetadata->getPartitions() > 1) {
-            LOG_ERROR("Topic reader cannot be created on a partitioned topic: " << dn->toString());
-            callback(ResultOperationNotSupported, Reader());
+        } else if (!(dn = DestinationName::get(topic))) {
+            lock.unlock();
+            callback(ResultInvalidTopicName, Consumer());
             return;
         }
-
-        ReaderImplPtr reader = boost::make_shared<ReaderImpl>(shared_from_this(), dn->toString(),
-                 conf, getListenerExecutorProvider()->get(), callback);
-        reader->start(startMessageId);
-
-        Lock lock(mutex_);
-        consumers_.push_back(reader->getConsumer());
     }
 
-    void ClientImpl::subscribeAsync(const std::string& topic, const std::string& consumerName,
-                                    const ConsumerConfiguration& conf, SubscribeCallback callback) {
-        DestinationNamePtr dn;
-        {
-            Lock lock(mutex_);
-            if (state_ != Open) {
-                lock.unlock();
-                callback(ResultAlreadyClosed, Consumer());
-                return;
-            } else if (!(dn = DestinationName::get(topic))) {
-                lock.unlock();
-                callback(ResultInvalidTopicName, Consumer());
-                return;
-            }
+    lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(
+        &ClientImpl::handleSubscribe, shared_from_this(), _1, _2, dn, consumerName, conf, callback));
+}
+
+void ClientImpl::handleSubscribe(const Result result, const LookupDataResultPtr partitionMetadata,
+                                 DestinationNamePtr dn, const std::string& consumerName,
+                                 ConsumerConfiguration conf, SubscribeCallback callback) {
+    if (result == ResultOk) {
+        // generate random name if not supplied by the customer.
+        if (conf.getConsumerName().empty()) {
+            conf.setConsumerName(generateRandomName());
         }
-
-        lookupServicePtr_->getPartitionMetadataAsync(dn).addListener(boost::bind(&ClientImpl::handleSubscribe,
-                                    shared_from_this(), _1, _2, dn, consumerName, conf, callback));
-    }
-
-    void ClientImpl::handleSubscribe(const Result result,
-            const LookupDataResultPtr partitionMetadata,
-            DestinationNamePtr dn,
-            const std::string& consumerName,
-            ConsumerConfiguration conf,
-            SubscribeCallback callback) {
-        if (result == ResultOk) {
-            // generate random name if not supplied by the customer.
-            if(conf.getConsumerName().empty()) {
-                conf.setConsumerName(generateRandomName());
-            }
-            ConsumerImplBasePtr consumer;
-            if (partitionMetadata->getPartitions() > 1) {
-                if (conf.getReceiverQueueSize() == 0) {
-                    LOG_ERROR("Can't use partitioned topic if the queue size is 0.");
-                    callback (ResultInvalidConfiguration, Consumer());
-                    return;
-                }
-                consumer = boost::make_shared<PartitionedConsumerImpl>(shared_from_this(),
-                                                                       consumerName,
-                                                                       dn,
-                                                                       partitionMetadata->getPartitions(),
-                                                                       conf);
-            } else  {
-                consumer = boost::make_shared<ConsumerImpl>(shared_from_this(), dn->toString(),
-                                                            consumerName, conf);
+        ConsumerImplBasePtr consumer;
+        if (partitionMetadata->getPartitions() > 1) {
+            if (conf.getReceiverQueueSize() == 0) {
+                LOG_ERROR("Can't use partitioned topic if the queue size is 0.");
+                callback(ResultInvalidConfiguration, Consumer());
+                return;
             }
-            consumer->getConsumerCreatedFuture().addListener(boost::bind(&ClientImpl::handleConsumerCreated,
-                                                                         shared_from_this(), _1, _2, callback,
-                                                                         consumer));
-            Lock lock(mutex_);
-            consumers_.push_back(consumer);
-            lock.unlock();
-            consumer->start();
+            consumer = boost::make_shared<PartitionedConsumerImpl>(shared_from_this(), consumerName, dn,
+                                                                   partitionMetadata->getPartitions(), conf);
         } else {
-            LOG_ERROR("Error Checking/Getting Partition Metadata while Subscribing- " <<  result );
-            callback (result, Consumer());
+            consumer =
+                boost::make_shared<ConsumerImpl>(shared_from_this(), dn->toString(), consumerName, conf);
         }
-
+        consumer->getConsumerCreatedFuture().addListener(
+            boost::bind(&ClientImpl::handleConsumerCreated, shared_from_this(), _1, _2, callback, consumer));
+        Lock lock(mutex_);
+        consumers_.push_back(consumer);
+        lock.unlock();
+        consumer->start();
+    } else {
+        LOG_ERROR("Error Checking/Getting Partition Metadata while Subscribing- " << result);
+        callback(result, Consumer());
     }
-
-    void ClientImpl::handleConsumerCreated(Result result,
-                                           ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
-                                           SubscribeCallback callback,
-                                           ConsumerImplBasePtr consumer) {
-        callback(result, Consumer(consumer));
+}
+
+void ClientImpl::handleConsumerCreated(Result result, ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
+                                       SubscribeCallback callback, ConsumerImplBasePtr consumer) {
+    callback(result, Consumer(consumer));
+}
+
+Future<Result, ClientConnectionWeakPtr> ClientImpl::getConnection(const std::string& topic) {
+    Promise<Result, ClientConnectionWeakPtr> promise;
+    lookupServicePtr_->lookupAsync(topic).addListener(
+        boost::bind(&ClientImpl::handleLookup, this, _1, _2, promise));
+    return promise.getFuture();
+}
+
+void ClientImpl::handleLookup(Result result, LookupDataResultPtr data,
+                              Promise<Result, ClientConnectionWeakPtr> promise) {
+    if (data) {
+        LOG_DEBUG("Getting connection to broker: " << data->getBrokerUrl());
+        Future<Result, ClientConnectionWeakPtr> future = pool_.getConnectionAsync(data->getBrokerUrl());
+        future.addListener(boost::bind(&ClientImpl::handleNewConnection, this, _1, _2, promise));
+    } else {
+        promise.setFailed(result);
     }
-
-    Future<Result, ClientConnectionWeakPtr> ClientImpl::getConnection(const std::string& topic) {
-        Promise<Result, ClientConnectionWeakPtr> promise;
-        lookupServicePtr_->lookupAsync(topic).addListener(boost::bind(&ClientImpl::handleLookup, this, _1, _2, promise));
-        return promise.getFuture();
+}
+
+void ClientImpl::handleNewConnection(Result result, const ClientConnectionWeakPtr& conn,
+                                     Promise<Result, ClientConnectionWeakPtr> promise) {
+    if (result == ResultOk) {
+        promise.setValue(conn);
+    } else {
+        promise.setFailed(ResultConnectError);
     }
+}
 
-    void ClientImpl::handleLookup(Result result, LookupDataResultPtr data,
-                                      Promise<Result, ClientConnectionWeakPtr> promise) {
-            if (data) {
-                LOG_DEBUG("Getting connection to broker: " << data->getBrokerUrl());
-                Future<Result, ClientConnectionWeakPtr> future = pool_.getConnectionAsync(
-                                                                                          data->getBrokerUrl());
-                future.addListener(boost::bind(&ClientImpl::handleNewConnection, this, _1, _2, promise));
-            } else {
-                promise.setFailed(result);
-            }
+void ClientImpl::closeAsync(CloseCallback callback) {
+    Lock lock(mutex_);
+    ProducersList producers(producers_);
+    ConsumersList consumers(consumers_);
+
+    if (state_ != Open && callback) {
+        lock.unlock();
+        callback(ResultAlreadyClosed);
+        return;
+    }
+    // Set the state to Closing so that no producers could get added
+    state_ = Closing;
+    lock.unlock();
+
+    LOG_DEBUG("Closing Pulsar client");
+    SharedInt numberOfOpenHandlers = boost::make_shared<int>(producers.size() + consumers.size());
+
+    for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
+        ProducerImplBasePtr producer = it->lock();
+        if (producer && !producer->isClosed()) {
+            producer->closeAsync(boost::bind(&ClientImpl::handleClose, shared_from_this(), _1,
+                                             numberOfOpenHandlers, callback));
+        } else {
+            // Since the connection is already closed
+            (*numberOfOpenHandlers)--;
         }
+    }
 
-    void ClientImpl::handleNewConnection(Result result, const ClientConnectionWeakPtr& conn,
-                                         Promise<Result, ClientConnectionWeakPtr> promise) {
-        if (result == ResultOk) {
-            promise.setValue(conn);
+    for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
+        ConsumerImplBasePtr consumer = it->lock();
+        if (consumer && !consumer->isClosed()) {
+            consumer->closeAsync(boost::bind(&ClientImpl::handleClose, shared_from_this(), _1,
+                                             numberOfOpenHandlers, callback));
         } else {
-            promise.setFailed(ResultConnectError);
+            // Since the connection is already closed
+            (*numberOfOpenHandlers)--;
         }
     }
 
-    void ClientImpl::closeAsync(CloseCallback callback) {
+    if (*numberOfOpenHandlers == 0 && callback) {
+        callback(ResultOk);
+    }
+}
+
+void ClientImpl::handleClose(Result result, SharedInt numberOfOpenHandlers, ResultCallback callback) {
+    static bool errorClosing = false;
+    static Result failResult = ResultOk;
+    if (result != ResultOk) {
+        errorClosing = true;
+        failResult = result;
+    }
+    if (*numberOfOpenHandlers > 0) {
+        --(*numberOfOpenHandlers);
+    }
+    if (*numberOfOpenHandlers == 0) {
         Lock lock(mutex_);
-        ProducersList producers(producers_);
-        ConsumersList consumers(consumers_);
-
-        if (state_ != Open && callback) {
-            lock.unlock();
-            callback(ResultAlreadyClosed);
-            return;
-        }
-        // Set the state to Closing so that no producers could get added
-        state_ = Closing;
+        state_ = Closed;
         lock.unlock();
-
-        LOG_DEBUG("Closing Pulsar client");
-        SharedInt numberOfOpenHandlers = boost::make_shared<int>(producers.size() + consumers.size());
-
-        for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
-            ProducerImplBasePtr producer = it->lock();
-            if (producer && !producer->isClosed()) {
-                producer->closeAsync(
-                                     boost::bind(&ClientImpl::handleClose, shared_from_this(), _1, numberOfOpenHandlers,
-                                                 callback));
-            } else {
-                // Since the connection is already closed
-                (*numberOfOpenHandlers)--;
-            }
-        }
-
-        for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
-            ConsumerImplBasePtr consumer = it->lock();
-            if (consumer && !consumer->isClosed()) {
-                consumer->closeAsync(
-                                     boost::bind(&ClientImpl::handleClose, shared_from_this(), _1, numberOfOpenHandlers,
-                                                 callback));
-            } else {
-                // Since the connection is already closed
-                (*numberOfOpenHandlers)--;
+        if (errorClosing) {
+            LOG_DEBUG("Problem in closing client, could not close one or more consumers or producers");
+            if (callback) {
+                callback(failResult);
             }
         }
 
-        if (*numberOfOpenHandlers == 0 && callback) {
+        LOG_DEBUG("Shutting down producers and consumers for client");
+        shutdown();
+        if (callback) {
             callback(ResultOk);
         }
     }
+}
 
-    void ClientImpl::handleClose(Result result, SharedInt numberOfOpenHandlers, ResultCallback callback) {
-        static bool errorClosing = false;
-        static Result failResult = ResultOk;
-        if (result != ResultOk) {
-            errorClosing = true;
-            failResult = result;
-        }
-        if(*numberOfOpenHandlers > 0) {
-            --(*numberOfOpenHandlers);
-        }
-        if (*numberOfOpenHandlers == 0) {
+void ClientImpl::shutdown() {
+    Lock lock(mutex_);
+    ProducersList producers;
+    ConsumersList consumers;
 
-            Lock lock(mutex_);
-            state_ = Closed;
-            lock.unlock();
-            if (errorClosing) {
-                LOG_DEBUG("Problem in closing client, could not close one or more consumers or producers");
-                if (callback) {
-                    callback(failResult);
-                }
-            }
+    producers.swap(producers_);
+    consumers.swap(consumers_);
+    lock.unlock();
 
-            LOG_DEBUG("Shutting down producers and consumers for client");
-            shutdown();
-            if (callback) {
-                callback(ResultOk);
-            }
+    for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
+        ProducerImplBasePtr producer = it->lock();
+        if (producer) {
+            producer->shutdown();
         }
     }
 
-    void ClientImpl::shutdown() {
-        Lock lock(mutex_);
-        ProducersList producers;
-        ConsumersList consumers;
-
-        producers.swap(producers_);
-        consumers.swap(consumers_);
-        lock.unlock();
-
-        for (ProducersList::iterator it = producers.begin(); it != producers.end(); ++it) {
-            ProducerImplBasePtr producer = it->lock();
-            if (producer) {
-                producer->shutdown();
-            }
+    for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
+        ConsumerImplBasePtr consumer = it->lock();
+        if (consumer) {
+            consumer->shutdown();
         }
-
-        for (ConsumersList::iterator it = consumers.begin(); it != consumers.end(); ++it) {
-            ConsumerImplBasePtr consumer = it->lock();
-            if (consumer) {
-                consumer->shutdown();
-            }
-        }
-
-        ioExecutorProvider_->close();
-        listenerExecutorProvider_->close();
-        partitionListenerExecutorProvider_->close();
     }
 
-    uint64_t ClientImpl::newProducerId() {
-        Lock lock(mutex_);
-        return producerIdGenerator_++;
-    }
+    ioExecutorProvider_->close();
+    listenerExecutorProvider_->close();
+    partitionListenerExecutorProvider_->close();
+}
 
-    uint64_t ClientImpl::newConsumerId() {
-        Lock lock(mutex_);
-        return consumerIdGenerator_++;
-    }
+uint64_t ClientImpl::newProducerId() {
+    Lock lock(mutex_);
+    return producerIdGenerator_++;
+}
 
-    uint64_t ClientImpl::newRequestId() {
-        Lock lock(mutex_);
-        return requestIdGenerator_++;
-    }
+uint64_t ClientImpl::newConsumerId() {
+    Lock lock(mutex_);
+    return consumerIdGenerator_++;
+}
 
-    const ClientConfiguration& ClientImpl::getClientConfig() const {
-        return clientConfiguration_;
-    }
+uint64_t ClientImpl::newRequestId() {
+    Lock lock(mutex_);
+    return requestIdGenerator_++;
+}
+
+const ClientConfiguration& ClientImpl::getClientConfig() const { return clientConfiguration_; }
 
 } /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/ClientImpl.h b/pulsar-client-cpp/lib/ClientImpl.h
index c146f2119..679e2dee7 100644
--- a/pulsar-client-cpp/lib/ClientImpl.h
+++ b/pulsar-client-cpp/lib/ClientImpl.h
@@ -46,7 +46,7 @@ typedef boost::weak_ptr<ReaderImpl> ReaderImplWeakPtr;
 const std::string generateRandomName();
 
 class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
- public:
+   public:
     ClientImpl(const std::string& serviceUrl, const ClientConfiguration& clientConfiguration,
                bool poolConnections);
     ~ClientImpl();
@@ -57,10 +57,8 @@ class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
     void subscribeAsync(const std::string& topic, const std::string& consumerName,
                         const ConsumerConfiguration& conf, SubscribeCallback callback);
 
-    void createReaderAsync(const std::string& topic,
-                           const MessageId& startMessageId,
-                           const ReaderConfiguration& conf,
-                           ReaderCallback callback);
+    void createReaderAsync(const std::string& topic, const MessageId& startMessageId,
+                           const ReaderConfiguration& conf, ReaderCallback callback);
 
     Future<Result, ClientConnectionWeakPtr> getConnection(const std::string& topic);
     void handleLookup(Result result, LookupDataResultPtr data,
@@ -83,23 +81,16 @@ class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
     ExecutorServiceProviderPtr getPartitionListenerExecutorProvider();
     friend class PulsarFriend;
 
- private:
-
-    void handleCreateProducer(const Result result,
-                              const LookupDataResultPtr partitionMetadata,
-                              DestinationNamePtr dn,
-                              ProducerConfiguration conf,
+   private:
+    void handleCreateProducer(const Result result, const LookupDataResultPtr partitionMetadata,
+                              DestinationNamePtr dn, ProducerConfiguration conf,
                               CreateProducerCallback callback);
 
-    void handleSubscribe(const Result result,
-                             const LookupDataResultPtr partitionMetadata,
-                             DestinationNamePtr dn,
-                             const std::string& consumerName,
-                             ConsumerConfiguration conf,
-                             SubscribeCallback callback);
+    void handleSubscribe(const Result result, const LookupDataResultPtr partitionMetadata,
+                         DestinationNamePtr dn, const std::string& consumerName, ConsumerConfiguration conf,
+                         SubscribeCallback callback);
 
-    void handleReaderMetadataLookup(const Result result,
-                                    const LookupDataResultPtr partitionMetadata,
+    void handleReaderMetadataLookup(const Result result, const LookupDataResultPtr partitionMetadata,
                                     DestinationNamePtr dn, BatchMessageId startMessageId,
                                     ReaderConfiguration conf, ReaderCallback callback);
 
@@ -112,7 +103,8 @@ class ClientImpl : public boost::enable_shared_from_this<ClientImpl> {
 
     void handleClose(Result result, SharedInt remaining, ResultCallback callback);
 
-    enum State {
+    enum State
+    {
         Open,
         Closing,
         Closed
diff --git a/pulsar-client-cpp/lib/Commands.cc b/pulsar-client-cpp/lib/Commands.cc
index a7b7ce330..6c4a35cdf 100644
--- a/pulsar-client-cpp/lib/Commands.cc
+++ b/pulsar-client-cpp/lib/Commands.cc
@@ -60,8 +60,7 @@ SharedBuffer Commands::newPartitionMetadataRequest(const std::string& topic, uin
     return buffer;
 }
 
-SharedBuffer Commands::newLookup(const std::string& topic, const bool authoritative,
-                                 uint64_t requestId) {
+SharedBuffer Commands::newLookup(const std::string& topic, const bool authoritative, uint64_t requestId) {
     static BaseCommand cmd;
     static boost::mutex mutex;
     mutex.lock();
@@ -90,8 +89,8 @@ SharedBuffer Commands::newConsumerStats(uint64_t consumerId, uint64_t requestId)
     return buffer;
 }
 
-PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
-                                   uint64_t producerId, uint64_t sequenceId, ChecksumType checksumType, const Message& msg) {
+PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd, uint64_t producerId,
+                                   uint64_t sequenceId, ChecksumType checksumType, const Message& msg) {
     const proto::MessageMetadata& metadata = msg.impl_->metadata;
     SharedBuffer& payload = msg.impl_->payload;
 
@@ -110,10 +109,10 @@ PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
     int msgMetadataSize = metadata.ByteSize();
     int payloadSize = payload.readableBytes();
 
-    int magicAndChecksumLength =
-            (Crc32c == (checksumType)) ? (2 + 4 /* magic + checksumLength*/) : 0;
+    int magicAndChecksumLength = (Crc32c == (checksumType)) ? (2 + 4 /* magic + checksumLength*/) : 0;
     bool includeChecksum = magicAndChecksumLength > 0;
-    int headerContentSize = 4 + cmdSize + magicAndChecksumLength + 4 + msgMetadataSize;  // cmdLength + cmdSize + magicLength +
+    int headerContentSize =
+        4 + cmdSize + magicAndChecksumLength + 4 + msgMetadataSize;  // cmdLength + cmdSize + magicLength +
     // checksumSize + msgMetadataLength + msgMetadataSize
     int totalSize = headerContentSize + payloadSize;
     int headersSize = 4 + headerContentSize;  // totalSize + headerLength
@@ -132,7 +131,7 @@ PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
     if (includeChecksum) {
         headers.writeUnsignedShort(magicCrc32c);
         checksumReaderIndex = headers.writerIndex();
-        headers.skipBytes(checksumSize);  //skip 4 bytes of checksum
+        headers.skipBytes(checksumSize);  // skip 4 bytes of checksum
     }
 
     // Write metadata
@@ -148,10 +147,9 @@ PairSharedBuffer Commands::newSend(SharedBuffer& headers, BaseCommand& cmd,
     if (includeChecksum) {
         int writeIndex = headers.writerIndex();
         int metadataStartIndex = checksumReaderIndex + checksumSize;
-        uint32_t metadataChecksum = computeChecksum(
-                0, headers.data() + metadataStartIndex, (writeIndex - metadataStartIndex));
-        uint32_t computedChecksum = computeChecksum(metadataChecksum, payload.data(),
-                                               payload.writerIndex());
+        uint32_t metadataChecksum =
+            computeChecksum(0, headers.data() + metadataStartIndex, (writeIndex - metadataStartIndex));
+        uint32_t computedChecksum = computeChecksum(metadataChecksum, payload.data(), payload.writerIndex());
         // set computed checksum
         headers.setWriterIndex(checksumReaderIndex);
         headers.writeUnsignedInt(computedChecksum);
@@ -176,11 +174,9 @@ SharedBuffer Commands::newConnect(const AuthenticationPtr& authentication) {
     return writeMessageWithSize(cmd);
 }
 
-SharedBuffer Commands::newSubscribe(const std::string& topic, const std::string&subscription,
-                                    uint64_t consumerId, uint64_t requestId,
-                                    CommandSubscribe_SubType subType,
-                                    const std::string& consumerName,
-                                    SubscriptionMode subscriptionMode,
+SharedBuffer Commands::newSubscribe(const std::string& topic, const std::string& subscription,
+                                    uint64_t consumerId, uint64_t requestId, CommandSubscribe_SubType subType,
+                                    const std::string& consumerName, SubscriptionMode subscriptionMode,
                                     Optional<BatchMessageId> startMessageId) {
     BaseCommand cmd;
     cmd.set_type(BaseCommand::SUBSCRIBE);
@@ -231,8 +227,7 @@ SharedBuffer Commands::newProducer(const std::string& topic, uint64_t producerId
     return writeMessageWithSize(cmd);
 }
 
-SharedBuffer Commands::newAck(uint64_t consumerId, const MessageIdData& messageId,
-                              CommandAck_AckType ackType,
+SharedBuffer Commands::newAck(uint64_t consumerId, const MessageIdData& messageId, CommandAck_AckType ackType,
                               int validationError) {
     BaseCommand cmd;
     cmd.set_type(BaseCommand::ACK);
@@ -240,7 +235,7 @@ SharedBuffer Commands::newAck(uint64_t consumerId, const MessageIdData& messageI
     ack->set_consumer_id(consumerId);
     ack->set_ack_type(ackType);
     if (CommandAck_AckType_IsValid(validationError)) {
-        ack->set_validation_error((CommandAck_ValidationError) validationError);
+        ack->set_validation_error((CommandAck_ValidationError)validationError);
     }
     *(ack->mutable_message_id()) = messageId;
     return writeMessageWithSize(cmd);
@@ -375,8 +370,7 @@ std::string Commands::messageType(BaseCommand_Type type) {
     };
 }
 
-void Commands::initBatchMessageMetadata(const Message &msg, pulsar::proto::MessageMetadata &batchMetadata)
-{
+void Commands::initBatchMessageMetadata(const Message& msg, pulsar::proto::MessageMetadata& batchMetadata) {
     if (msg.impl_->metadata.has_publish_time()) {
         batchMetadata.set_publish_time(msg.impl_->metadata.publish_time());
     }
@@ -390,16 +384,16 @@ void Commands::initBatchMessageMetadata(const Message &msg, pulsar::proto::Messa
     }
 }
 
-void Commands::serializeSingleMessageInBatchWithPayload(const Message &msg,
-                                                        SharedBuffer& batchPayLoad, const unsigned long& maxMessageSizeInBytes) {
+void Commands::serializeSingleMessageInBatchWithPayload(const Message& msg, SharedBuffer& batchPayLoad,
+                                                        const unsigned long& maxMessageSizeInBytes) {
     SingleMessageMetadata metadata;
     if (msg.impl_->hasPartitionKey()) {
         metadata.set_partition_key(msg.impl_->getPartitionKey());
     }
 
     for (MessageBuilder::StringMap::const_iterator it = msg.impl_->properties().begin();
-            it != msg.impl_->properties().end(); it++) {
-        proto::KeyValue *keyValue = proto::KeyValue().New();
+         it != msg.impl_->properties().end(); it++) {
+        proto::KeyValue* keyValue = proto::KeyValue().New();
         keyValue->set_key(it->first);
         keyValue->set_value(it->second);
         metadata.mutable_properties()->AddAllocated(keyValue);
@@ -415,8 +409,11 @@ void Commands::serializeSingleMessageInBatchWithPayload(const Message &msg,
 
     unsigned long requiredSpace = sizeof(uint32_t) + msgMetadataSize + payloadSize;
     if (batchPayLoad.writableBytes() <= sizeof(uint32_t) + msgMetadataSize + payloadSize) {
-        LOG_DEBUG("remaining size of batchPayLoad buffer [" << batchPayLoad.writableBytes() << "] can't accomodate new payload [" << requiredSpace << "] - expanding the batchPayload buffer");
-        SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() +  std::max(requiredSpace, maxMessageSizeInBytes));
+        LOG_DEBUG("remaining size of batchPayLoad buffer ["
+                  << batchPayLoad.writableBytes() << "] can't accomodate new payload [" << requiredSpace
+                  << "] - expanding the batchPayload buffer");
+        SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() +
+                                                     std::max(requiredSpace, maxMessageSizeInBytes));
         // Adding batch created so far
         buffer.write(batchPayLoad.data(), batchPayLoad.readableBytes());
         batchPayLoad = buffer;
@@ -445,8 +442,7 @@ Message Commands::deSerializeSingleMessageInBatch(Message& batchedMessage) {
     SharedBuffer payload = uncompressedPayload.slice(0, payloadSize);
     uncompressedPayload.consume(payloadSize);
 
-    Message singleMessage(batchedMessage.impl_->messageId, batchedMessage.impl_->metadata, payload,
-                          metadata);
+    Message singleMessage(batchedMessage.impl_->messageId, batchedMessage.impl_->metadata, payload, metadata);
     singleMessage.impl_->cnx_ = batchedMessage.impl_->cnx_;
 
     return singleMessage;
diff --git a/pulsar-client-cpp/lib/Commands.h b/pulsar-client-cpp/lib/Commands.h
index 1edbb73a2..1fd9e48c7 100644
--- a/pulsar-client-cpp/lib/Commands.h
+++ b/pulsar-client-cpp/lib/Commands.h
@@ -38,19 +38,22 @@ typedef boost::shared_ptr<proto::MessageMetadata> MessageMetadataPtr;
  * Buffer are already including the 4 byte size at the beginning
  */
 class Commands {
- public:
-
-    enum ChecksumType {
+   public:
+    enum ChecksumType
+    {
         Crc32c,
         None
     };
-    enum WireFormatConstant {
+    enum WireFormatConstant
+    {
         MaxMessageSize = (5 * 1024 * 1024 - (10 * 1024)),
         MaxFrameSize = (5 * 1024 * 1024)
     };
 
-    enum SubscriptionMode {
-        // Make the subscription to be backed by a durable cursor that will retain messages and persist the current
+    enum SubscriptionMode
+    {
+        // Make the subscription to be backed by a durable cursor that will retain messages and persist the
+        // current
         // position
         SubscriptionModeDurable,
 
@@ -65,16 +68,14 @@ class Commands {
 
     static SharedBuffer newPartitionMetadataRequest(const std::string& topic, uint64_t requestId);
 
-    static SharedBuffer newLookup(const std::string& topic, const bool authoritative,
-                                  uint64_t requestId);
+    static SharedBuffer newLookup(const std::string& topic, const bool authoritative, uint64_t requestId);
 
-    static PairSharedBuffer newSend(SharedBuffer& headers, proto::BaseCommand& cmd,
-                                    uint64_t producerId, uint64_t sequenceId, ChecksumType checksumType, const Message& msg);
+    static PairSharedBuffer newSend(SharedBuffer& headers, proto::BaseCommand& cmd, uint64_t producerId,
+                                    uint64_t sequenceId, ChecksumType checksumType, const Message& msg);
 
-    static SharedBuffer newSubscribe(const std::string& topic, const std::string&subscription,
+    static SharedBuffer newSubscribe(const std::string& topic, const std::string& subscription,
                                      uint64_t consumerId, uint64_t requestId,
-                                     proto::CommandSubscribe_SubType subType,
-                                     const std::string& consumerName,
+                                     proto::CommandSubscribe_SubType subType, const std::string& consumerName,
                                      SubscriptionMode subscriptionMode,
                                      Optional<BatchMessageId> startMessageId);
 
@@ -99,19 +100,19 @@ class Commands {
 
     static std::string messageType(proto::BaseCommand::Type type);
 
-    static void initBatchMessageMetadata(const Message &msg, pulsar::proto::MessageMetadata &batchMetadata);
+    static void initBatchMessageMetadata(const Message& msg, pulsar::proto::MessageMetadata& batchMetadata);
 
-    static void serializeSingleMessageInBatchWithPayload(const Message &msg, SharedBuffer& batchPayLoad, const unsigned long& maxMessageSizeInBytes);
+    static void serializeSingleMessageInBatchWithPayload(const Message& msg, SharedBuffer& batchPayLoad,
+                                                         const unsigned long& maxMessageSizeInBytes);
 
     static Message deSerializeSingleMessageInBatch(Message& batchedMessage);
 
     static SharedBuffer newConsumerStats(uint64_t consumerId, uint64_t requestId);
 
- private:
+   private:
     Commands();
 
     static SharedBuffer writeMessageWithSize(const proto::BaseCommand& cmd);
-
 };
 
 } /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/CompressionCodec.cc b/pulsar-client-cpp/lib/CompressionCodec.cc
index 38635fb6c..d6847016d 100644
--- a/pulsar-client-cpp/lib/CompressionCodec.cc
+++ b/pulsar-client-cpp/lib/CompressionCodec.cc
@@ -62,14 +62,11 @@ proto::CompressionType CompressionCodecProvider::convertType(CompressionType typ
     }
 }
 
-SharedBuffer CompressionCodecNone::encode(const SharedBuffer& raw) {
-    return raw;
-}
+SharedBuffer CompressionCodecNone::encode(const SharedBuffer& raw) { return raw; }
 
 bool CompressionCodecNone::decode(const SharedBuffer& encoded, uint32_t uncompressedSize,
                                   SharedBuffer& decoded) {
     decoded = encoded;
     return true;
 }
-
 }
diff --git a/pulsar-client-cpp/lib/CompressionCodec.h b/pulsar-client-cpp/lib/CompressionCodec.h
index 1716c2475..c515b90fe 100644
--- a/pulsar-client-cpp/lib/CompressionCodec.h
+++ b/pulsar-client-cpp/lib/CompressionCodec.h
@@ -37,21 +37,21 @@ class CompressionCodecLZ4;
 class CompressionCodecZLib;
 
 class CompressionCodecProvider {
- public:
+   public:
     static CompressionType convertType(proto::CompressionType type);
     static proto::CompressionType convertType(CompressionType type);
 
     static CompressionCodec& getCodec(CompressionType compressionType);
- private:
+
+   private:
     static CompressionCodecNone compressionCodecNone_;
     static CompressionCodecLZ4 compressionCodecLZ4_;
     static CompressionCodecZLib compressionCodecZLib_;
 };
 
 class CompressionCodec {
- public:
-    virtual ~CompressionCodec() {
-    }
+   public:
+    virtual ~CompressionCodec() {}
 
     /**
      * Compress a buffer
@@ -75,17 +75,15 @@ class CompressionCodec {
      *             were the result will be passed
      * @return true if the buffer was decompressed, false otherwise
      */
-    virtual bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize,
-                        SharedBuffer& decoded) = 0;
+    virtual bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded) = 0;
 };
 
 class CompressionCodecNone : public CompressionCodec {
- public:
+   public:
     SharedBuffer encode(const SharedBuffer& raw);
 
     bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded);
 };
-
 }
 
 #endif /* LIB_COMPRESSIONCODEC_H_ */
diff --git a/pulsar-client-cpp/lib/CompressionCodecLZ4.cc b/pulsar-client-cpp/lib/CompressionCodecLZ4.cc
index 470c2279e..ec8d41d73 100644
--- a/pulsar-client-cpp/lib/CompressionCodecLZ4.cc
+++ b/pulsar-client-cpp/lib/CompressionCodecLZ4.cc
@@ -28,8 +28,8 @@ SharedBuffer CompressionCodecLZ4::encode(const SharedBuffer& raw) {
     int maxCompressedSize = LZ4_compressBound(raw.readableBytes());
     SharedBuffer compressed = SharedBuffer::allocate(maxCompressedSize);
 
-    int compressedSize = LZ4_compress_default(raw.data(), compressed.mutableData(),
-                                              raw.readableBytes(), maxCompressedSize);
+    int compressedSize =
+        LZ4_compress_default(raw.data(), compressed.mutableData(), raw.readableBytes(), maxCompressedSize);
     assert(compressedSize > 0);
     compressed.bytesWritten(compressedSize);
 
@@ -50,5 +50,4 @@ bool CompressionCodecLZ4::decode(const SharedBuffer& encoded, uint32_t uncompres
         return false;
     }
 }
-
 }
diff --git a/pulsar-client-cpp/lib/CompressionCodecLZ4.h b/pulsar-client-cpp/lib/CompressionCodecLZ4.h
index a7fe76c5f..35eac5be3 100644
--- a/pulsar-client-cpp/lib/CompressionCodecLZ4.h
+++ b/pulsar-client-cpp/lib/CompressionCodecLZ4.h
@@ -24,11 +24,10 @@
 namespace pulsar {
 
 class CompressionCodecLZ4 : public CompressionCodec {
- public:
+   public:
     SharedBuffer encode(const SharedBuffer& raw);
 
     bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded);
 };
-
 }
 #endif /* LIB_COMPRESSIONCODECLZ4_H_ */
diff --git a/pulsar-client-cpp/lib/CompressionCodecZLib.cc b/pulsar-client-cpp/lib/CompressionCodecZLib.cc
index bc3dc48c4..d80366da3 100644
--- a/pulsar-client-cpp/lib/CompressionCodecZLib.cc
+++ b/pulsar-client-cpp/lib/CompressionCodecZLib.cc
@@ -34,8 +34,8 @@ SharedBuffer CompressionCodecZLib::encode(const SharedBuffer& raw) {
     SharedBuffer compressed = SharedBuffer::allocate(maxCompressedSize);
 
     unsigned long bytesWritten = maxCompressedSize;
-    int res = compress((Bytef*) compressed.mutableData(), &bytesWritten, (const Bytef*) raw.data(),
-             raw.readableBytes());
+    int res = compress((Bytef*)compressed.mutableData(), &bytesWritten, (const Bytef*)raw.data(),
+                       raw.readableBytes());
     if (res != Z_OK) {
         LOG_ERROR("Failed to compress buffer. res=" << res);
         abort();
@@ -50,7 +50,8 @@ bool CompressionCodecZLib::decode(const SharedBuffer& encoded, uint32_t uncompre
     SharedBuffer decompressed = SharedBuffer::allocate(uncompressedSize);
 
     unsigned long bytesUncompressed = uncompressedSize;
-    int res = uncompress((Bytef*) decompressed.mutableData(), &bytesUncompressed, (Bytef*) encoded.data(), encoded.readableBytes());
+    int res = uncompress((Bytef*)decompressed.mutableData(), &bytesUncompressed, (Bytef*)encoded.data(),
+                         encoded.readableBytes());
 
     decompressed.bytesWritten(bytesUncompressed);
     if (res == Z_OK) {
@@ -60,5 +61,4 @@ bool CompressionCodecZLib::decode(const SharedBuffer& encoded, uint32_t uncompre
         return false;
     }
 }
-
 }
diff --git a/pulsar-client-cpp/lib/CompressionCodecZLib.h b/pulsar-client-cpp/lib/CompressionCodecZLib.h
index 94952019e..73b19aa2d 100644
--- a/pulsar-client-cpp/lib/CompressionCodecZLib.h
+++ b/pulsar-client-cpp/lib/CompressionCodecZLib.h
@@ -26,12 +26,11 @@
 namespace pulsar {
 
 class CompressionCodecZLib : public CompressionCodec {
- public:
+   public:
     SharedBuffer encode(const SharedBuffer& raw);
 
     bool decode(const SharedBuffer& encoded, uint32_t uncompressedSize, SharedBuffer& decoded);
 };
-
 }
 
 #endif /* LIB_COMPRESSIONCODECZLIB_H_ */
diff --git a/pulsar-client-cpp/lib/ConnectionPool.cc b/pulsar-client-cpp/lib/ConnectionPool.cc
index 076b1773b..b353f6e92 100644
--- a/pulsar-client-cpp/lib/ConnectionPool.cc
+++ b/pulsar-client-cpp/lib/ConnectionPool.cc
@@ -24,19 +24,16 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-ConnectionPool::ConnectionPool(const ClientConfiguration& conf,
-                               ExecutorServiceProviderPtr executorProvider,
+ConnectionPool::ConnectionPool(const ClientConfiguration& conf, ExecutorServiceProviderPtr executorProvider,
                                const AuthenticationPtr& authentication, bool poolConnections)
-        : clientConfiguration_(conf),
-          executorProvider_(executorProvider),
-          authentication_(authentication),
-          pool_(),
-          poolConnections_(poolConnections),
-          mutex_() {
-}
+    : clientConfiguration_(conf),
+      executorProvider_(executorProvider),
+      authentication_(authentication),
+      pool_(),
+      poolConnections_(poolConnections),
+      mutex_() {}
 
-Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(
-        const std::string& endpoint) {
+Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(const std::string& endpoint) {
     boost::unique_lock<boost::mutex> lock(mutex_);
 
     if (poolConnections_) {
@@ -47,19 +44,20 @@ Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(
             if (cnx && !cnx->isClosed()) {
                 // Found a valid or pending connection in the pool
                 LOG_DEBUG("Got connection from pool for " << endpoint << " use_count: "  //
-                        << (cnx.use_count() - 1) << " @ " << cnx.get());
+                                                          << (cnx.use_count() - 1) << " @ " << cnx.get());
                 return cnx->getConnectFuture();
             } else {
                 // Deleting stale connection
-                LOG_INFO("Deleting stale connection from pool for " << endpoint << " use_count: "
-                        << (cnx.use_count() - 1) << " @ " << cnx.get());
+                LOG_INFO("Deleting stale connection from pool for "
+                         << endpoint << " use_count: " << (cnx.use_count() - 1) << " @ " << cnx.get());
                 pool_.erase(endpoint);
             }
         }
     }
 
     // No valid or pending connection found in the pool, creating a new one
-    ClientConnectionPtr cnx(new ClientConnection(endpoint, executorProvider_->get(), clientConfiguration_, authentication_));
+    ClientConnectionPtr cnx(
+        new ClientConnection(endpoint, executorProvider_->get(), clientConfiguration_, authentication_));
 
     LOG_INFO("Created connection for " << endpoint);
 
@@ -71,5 +69,4 @@ Future<Result, ClientConnectionWeakPtr> ConnectionPool::getConnectionAsync(
     cnx->tcpConnectAsync();
     return future;
 }
-
 }
diff --git a/pulsar-client-cpp/lib/ConnectionPool.h b/pulsar-client-cpp/lib/ConnectionPool.h
index af6747418..d588d66b1 100644
--- a/pulsar-client-cpp/lib/ConnectionPool.h
+++ b/pulsar-client-cpp/lib/ConnectionPool.h
@@ -17,7 +17,7 @@
  * under the License.
  */
 #ifndef _PULSAR_CONNECTION_POOL_HEADER_
-#define  _PULSAR_CONNECTION_POOL_HEADER_
+#define _PULSAR_CONNECTION_POOL_HEADER_
 
 #include <pulsar/Result.h>
 
@@ -32,13 +32,13 @@ namespace pulsar {
 class ExecutorService;
 
 class ConnectionPool {
- public:
+   public:
     ConnectionPool(const ClientConfiguration& conf, ExecutorServiceProviderPtr executorProvider,
                    const AuthenticationPtr& authentication, bool poolConnections = true);
 
     Future<Result, ClientConnectionWeakPtr> getConnectionAsync(const std::string& endpoint);
 
- private:
+   private:
     ClientConfiguration clientConfiguration_;
     ExecutorServiceProviderPtr executorProvider_;
     AuthenticationPtr authentication_;
@@ -49,7 +49,6 @@ class ConnectionPool {
 
     friend class ConnectionPoolTest;
 };
-
 }
 #pragma GCC visibility pop
-#endif //_PULSAR_CONNECTION_POOL_HEADER_
+#endif  //_PULSAR_CONNECTION_POOL_HEADER_
diff --git a/pulsar-client-cpp/lib/Consumer.cc b/pulsar-client-cpp/lib/Consumer.cc
index 010cd1a86..edc4ae351 100644
--- a/pulsar-client-cpp/lib/Consumer.cc
+++ b/pulsar-client-cpp/lib/Consumer.cc
@@ -27,17 +27,11 @@ namespace pulsar {
 
 static const std::string EMPTY_STRING;
 
-Consumer::Consumer()
-        : impl_() {
-}
+Consumer::Consumer() : impl_() {}
 
-Consumer::Consumer(ConsumerImplBasePtr impl)
-        : impl_(impl) {
-}
+Consumer::Consumer(ConsumerImplBasePtr impl) : impl_(impl) {}
 
-const std::string& Consumer::getTopic() const {
-    return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING;
-}
+const std::string& Consumer::getTopic() const { return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING; }
 
 const std::string& Consumer::getSubscriptionName() const {
     return impl_ != NULL ? impl_->getSubscriptionName() : EMPTY_STRING;
@@ -79,9 +73,7 @@ Result Consumer::receive(Message& msg, int timeoutMs) {
     return impl_->receive(msg, timeoutMs);
 }
 
-Result Consumer::acknowledge(const Message& message) {
-    return acknowledge(message.getMessageId());
-}
+Result Consumer::acknowledge(const Message& message) { return acknowledge(message.getMessageId()); }
 
 Result Consumer::acknowledge(const MessageId& messageId) {
     if (!impl_) {
diff --git a/pulsar-client-cpp/lib/ConsumerConfiguration.cc b/pulsar-client-cpp/lib/ConsumerConfiguration.cc
index 35d75b70e..b27b1221a 100644
--- a/pulsar-client-cpp/lib/ConsumerConfiguration.cc
+++ b/pulsar-client-cpp/lib/ConsumerConfiguration.cc
@@ -20,16 +20,11 @@
 
 namespace pulsar {
 
-ConsumerConfiguration::ConsumerConfiguration()
-        : impl_(boost::make_shared<ConsumerConfigurationImpl>()) {
-}
+ConsumerConfiguration::ConsumerConfiguration() : impl_(boost::make_shared<ConsumerConfigurationImpl>()) {}
 
-ConsumerConfiguration::~ConsumerConfiguration() {
-}
+ConsumerConfiguration::~ConsumerConfiguration() {}
 
-ConsumerConfiguration::ConsumerConfiguration(const ConsumerConfiguration& x)
-    : impl_(x.impl_) {
-}
+ConsumerConfiguration::ConsumerConfiguration(const ConsumerConfiguration& x) : impl_(x.impl_) {}
 
 ConsumerConfiguration& ConsumerConfiguration::operator=(const ConsumerConfiguration& x) {
     impl_ = x.impl_;
@@ -49,9 +44,7 @@ ConsumerConfiguration& ConsumerConfiguration::setConsumerType(ConsumerType consu
     return *this;
 }
 
-ConsumerType ConsumerConfiguration::getConsumerType() const {
-    return impl_->consumerType;
-}
+ConsumerType ConsumerConfiguration::getConsumerType() const { return impl_->consumerType; }
 
 ConsumerConfiguration& ConsumerConfiguration::setMessageListener(MessageListener messageListener) {
     impl_->messageListener = messageListener;
@@ -59,33 +52,21 @@ ConsumerConfiguration& ConsumerConfiguration::setMessageListener(MessageListener
     return *this;
 }
 
-MessageListener ConsumerConfiguration::getMessageListener() const {
-    return impl_->messageListener;
-}
+MessageListener ConsumerConfiguration::getMessageListener() const { return impl_->messageListener; }
 
-bool ConsumerConfiguration::hasMessageListener() const {
-    return impl_->hasMessageListener;
-}
+bool ConsumerConfiguration::hasMessageListener() const { return impl_->hasMessageListener; }
 
-void ConsumerConfiguration::setReceiverQueueSize(int size) {
-    impl_->receiverQueueSize = size;
-}
+void ConsumerConfiguration::setReceiverQueueSize(int size) { impl_->receiverQueueSize = size; }
 
-int ConsumerConfiguration::getReceiverQueueSize() const {
-    return impl_->receiverQueueSize;
-}
+int ConsumerConfiguration::getReceiverQueueSize() const { return impl_->receiverQueueSize; }
 
-const std::string& ConsumerConfiguration::getConsumerName() const {
-    return impl_->consumerName;
-}
+const std::string& ConsumerConfiguration::getConsumerName() const { return impl_->consumerName; }
 
 void ConsumerConfiguration::setConsumerName(const std::string& consumerName) {
     impl_->consumerName = consumerName;
 }
 
-long ConsumerConfiguration::getUnAckedMessagesTimeoutMs() const {
-    return impl_->unAckedMessagesTimeoutMs;
-}
+long ConsumerConfiguration::getUnAckedMessagesTimeoutMs() const { return impl_->unAckedMessagesTimeoutMs; }
 
 void ConsumerConfiguration::setUnAckedMessagesTimeoutMs(const uint64_t milliSeconds) {
     if (milliSeconds < 10000) {
diff --git a/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h b/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h
index 9f03e0260..63a56fd37 100644
--- a/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ConsumerConfigurationImpl.h
@@ -32,13 +32,12 @@ struct ConsumerConfigurationImpl {
     std::string consumerName;
     long brokerConsumerStatsCacheTimeInMs;
     ConsumerConfigurationImpl()
-            : unAckedMessagesTimeoutMs(0),
-              consumerType(ConsumerExclusive),
-              messageListener(),
-              hasMessageListener(false),
-              brokerConsumerStatsCacheTimeInMs(30 * 1000), // 30 seconds
-              receiverQueueSize(1000) {
-    }
+        : unAckedMessagesTimeoutMs(0),
+          consumerType(ConsumerExclusive),
+          messageListener(),
+          hasMessageListener(false),
+          brokerConsumerStatsCacheTimeInMs(30 * 1000),  // 30 seconds
+          receiverQueueSize(1000) {}
 };
 }
 #endif /* LIB_CONSUMERCONFIGURATIONIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/ConsumerImpl.cc b/pulsar-client-cpp/lib/ConsumerImpl.cc
index d46f97411..ce2074788 100644
--- a/pulsar-client-cpp/lib/ConsumerImpl.cc
+++ b/pulsar-client-cpp/lib/ConsumerImpl.cc
@@ -38,31 +38,32 @@ ConsumerImpl::ConsumerImpl(const ClientImplPtr client, const std::string& topic,
                            const ConsumerTopicType consumerTopicType /* = NonPartitioned by default */,
                            Commands::SubscriptionMode subscriptionMode,
                            Optional<BatchMessageId> startMessageId)
-        : HandlerBase(client, topic, Backoff(milliseconds(100), seconds(60), milliseconds(0))),
-          waitingForZeroQueueSizeMessage(false),
-          config_(conf),
-          subscription_(subscription),
-          originalSubscriptionName_(subscription),
-          messageListener_(config_.getMessageListener()),
-          consumerTopicType_(consumerTopicType),
-          subscriptionMode_(subscriptionMode),
-          startMessageId_(startMessageId),
-          // This is the initial capacity of the queue
-          incomingMessages_(std::max(config_.getReceiverQueueSize(), 1)),
-          availablePermits_(conf.getReceiverQueueSize()),
-          consumerId_(client->newConsumerId()),
-          consumerName_(config_.getConsumerName()),
-          partitionIndex_(-1),
-          consumerCreatedPromise_(),
-          messageListenerRunning_(true),
-          batchAcknowledgementTracker_(topic_, subscription, (long)consumerId_),
-          brokerConsumerStats_(),
-          consumerStatsBasePtr_() {
+    : HandlerBase(client, topic, Backoff(milliseconds(100), seconds(60), milliseconds(0))),
+      waitingForZeroQueueSizeMessage(false),
+      config_(conf),
+      subscription_(subscription),
+      originalSubscriptionName_(subscription),
+      messageListener_(config_.getMessageListener()),
+      consumerTopicType_(consumerTopicType),
+      subscriptionMode_(subscriptionMode),
+      startMessageId_(startMessageId),
+      // This is the initial capacity of the queue
+      incomingMessages_(std::max(config_.getReceiverQueueSize(), 1)),
+      availablePermits_(conf.getReceiverQueueSize()),
+      consumerId_(client->newConsumerId()),
+      consumerName_(config_.getConsumerName()),
+      partitionIndex_(-1),
+      consumerCreatedPromise_(),
+      messageListenerRunning_(true),
+      batchAcknowledgementTracker_(topic_, subscription, (long)consumerId_),
+      brokerConsumerStats_(),
+      consumerStatsBasePtr_() {
     std::stringstream consumerStrStream;
     consumerStrStream << "[" << topic_ << ", " << subscription_ << ", " << consumerId_ << "] ";
     consumerStr_ = consumerStrStream.str();
     if (conf.getUnAckedMessagesTimeoutMs() != 0) {
-        unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
+        unAckedMessageTrackerPtr_.reset(
+            new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
     } else {
         unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerDisabled());
     }
@@ -75,8 +76,8 @@ ConsumerImpl::ConsumerImpl(const ClientImplPtr client, const std::string& topic,
     unsigned int statsIntervalInSeconds = client->getClientConfig().getStatsIntervalInSeconds();
     if (statsIntervalInSeconds) {
         consumerStatsBasePtr_ = boost::make_shared<ConsumerStatsImpl>(
-                consumerStr_, client->getIOExecutorProvider()->get()->createDeadlineTimer(),
-                statsIntervalInSeconds);
+            consumerStr_, client->getIOExecutorProvider()->get()->createDeadlineTimer(),
+            statsIntervalInSeconds);
     } else {
         consumerStatsBasePtr_ = boost::make_shared<ConsumerStatsDisabled>();
     }
@@ -91,33 +92,21 @@ ConsumerImpl::~ConsumerImpl() {
     }
 }
 
-void ConsumerImpl::setPartitionIndex(int partitionIndex) {
-     partitionIndex_ = partitionIndex;
-}
+void ConsumerImpl::setPartitionIndex(int partitionIndex) { partitionIndex_ = partitionIndex; }
 
-int ConsumerImpl::getPartitionIndex() {
-    return partitionIndex_;
-}
+int ConsumerImpl::getPartitionIndex() { return partitionIndex_; }
 
-uint64_t ConsumerImpl::getConsumerId() {
-    return consumerId_;
-}
+uint64_t ConsumerImpl::getConsumerId() { return consumerId_; }
 
 Future<Result, ConsumerImplBaseWeakPtr> ConsumerImpl::getConsumerCreatedFuture() {
     return consumerCreatedPromise_.getFuture();
 }
 
-const std::string& ConsumerImpl::getSubscriptionName() const {
-    return originalSubscriptionName_;
-}
+const std::string& ConsumerImpl::getSubscriptionName() const { return originalSubscriptionName_; }
 
-const std::string& ConsumerImpl::getTopic() const {
-    return topic_;
-}
+const std::string& ConsumerImpl::getTopic() const { return topic_; }
 
-void ConsumerImpl::start() {
-    grabCnx();
-}
+void ConsumerImpl::start() { grabCnx(); }
 
 void ConsumerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
     Lock lock(mutex_);
@@ -141,11 +130,10 @@ void ConsumerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
 
     ClientImplPtr client = client_.lock();
     uint64_t requestId = client->newRequestId();
-    SharedBuffer cmd = Commands::newSubscribe(topic_, subscription_, consumerId_, requestId,
-                                              getSubType(), consumerName_, subscriptionMode_,
-                                              startMessageId_);
-    cnx->sendRequestWithId(cmd, requestId).addListener(
-            boost::bind(&ConsumerImpl::handleCreateConsumer, shared_from_this(), cnx, _1));
+    SharedBuffer cmd = Commands::newSubscribe(topic_, subscription_, consumerId_, requestId, getSubType(),
+                                              consumerName_, subscriptionMode_, startMessageId_);
+    cnx->sendRequestWithId(cmd, requestId)
+        .addListener(boost::bind(&ConsumerImpl::handleCreateConsumer, shared_from_this(), cnx, _1));
 }
 
 void ConsumerImpl::connectionFailed(Result result) {
@@ -184,10 +172,8 @@ void ConsumerImpl::handleCreateConsumer(const ClientConnectionPtr& cnx, Result r
             availablePermits_ = 0;
         }
 
-
         LOG_DEBUG(getName() << "Send initial flow permits: " << config_.getReceiverQueueSize());
-        if ((consumerTopicType_ == NonPartitioned || !firstTime)
-                && config_.getReceiverQueueSize() != 0) {
+        if ((consumerTopicType_ == NonPartitioned || !firstTime) && config_.getReceiverQueueSize() != 0) {
             receiveMessages(cnx, config_.getReceiverQueueSize());
         }
         consumerCreatedPromise_.setValue(shared_from_this());
@@ -197,20 +183,17 @@ void ConsumerImpl::handleCreateConsumer(const ClientConnectionPtr& cnx, Result r
             // in case it was indeed created, otherwise it might prevent new subscribe operation,
             // since we are not closing the connection
             int requestId = client_.lock()->newRequestId();
-            cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId),
-                                   requestId);
+            cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId), requestId);
         }
 
         if (consumerCreatedPromise_.isComplete()) {
             // Consumer had already been initially created, we need to retry connecting in any case
-            LOG_WARN(
-                    getName() << "Failed to reconnect consumer: " << strResult(result));
+            LOG_WARN(getName() << "Failed to reconnect consumer: " << strResult(result));
             scheduleReconnection(shared_from_this());
         } else {
             // Consumer was not yet created, retry to connect to broker if it's possible
             if (isRetriableError(result) && (creationTimestamp_ + operationTimeut_ < now())) {
-                LOG_WARN(
-                        getName() << "Temporary error in creating consumer : " << strResult(result));
+                LOG_WARN(getName() << "Temporary error in creating consumer : " << strResult(result));
                 scheduleReconnection(shared_from_this());
             } else {
                 LOG_ERROR(getName() << "Failed to create consumer: " << strResult(result));
@@ -228,8 +211,8 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback callback) {
     if (state_ != Ready) {
         lock.unlock();
         callback(ResultAlreadyClosed);
-        LOG_ERROR(
-                getName() << "Can not unsubscribe a closed subscription, please call subscribe again and then call unsubscribe");
+        LOG_ERROR(getName() << "Can not unsubscribe a closed subscription, please call subscribe again and "
+                               "then call unsubscribe");
         return;
     }
 
@@ -240,8 +223,8 @@ void ConsumerImpl::unsubscribeAsync(ResultCallback callback) {
         lock.unlock();
         int requestId = client->newRequestId();
         SharedBuffer cmd = Commands::newUnsubscribe(consumerId_, requestId);
-        cnx->sendRequestWithId(cmd, requestId).addListener(
-                boost::bind(&ConsumerImpl::handleUnsubscribe, shared_from_this(), _1, callback));
+        cnx->sendRequestWithId(cmd, requestId)
+            .addListener(boost::bind(&ConsumerImpl::handleUnsubscribe, shared_from_this(), _1, callback));
     } else {
         Result result = ResultNotConnected;
         lock.unlock();
@@ -281,8 +264,9 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
     m.impl_->messageId.partition_ = partitionIndex_;
     m.impl_->cnx_ = cnx.get();
 
-    LOG_DEBUG(getName() << " metadata.num_messages_in_batch() = "<< metadata.num_messages_in_batch());
-    LOG_DEBUG(getName() << " metadata.has_num_messages_in_batch() = "<< metadata.has_num_messages_in_batch());
+    LOG_DEBUG(getName() << " metadata.num_messages_in_batch() = " << metadata.num_messages_in_batch());
+    LOG_DEBUG(getName() << " metadata.has_num_messages_in_batch() = "
+                        << metadata.has_num_messages_in_batch());
 
     unsigned int numOfMessageReceived = 1;
     if (metadata.has_num_messages_in_batch()) {
@@ -294,7 +278,7 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
             incomingMessages_.push(m);
         } else {
             Lock lock(mutex_);
-            if(waitingForZeroQueueSizeMessage) {
+            if (waitingForZeroQueueSizeMessage) {
                 lock.unlock();
                 incomingMessages_.push(m);
             }
@@ -308,19 +292,19 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
         }
         lock.unlock();
         // Trigger message listener callback in a separate thread
-        while(numOfMessageReceived--) {
-            listenerExecutor_->postWork(
-                boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
+        while (numOfMessageReceived--) {
+            listenerExecutor_->postWork(boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
         }
     }
 }
 
 // Zero Queue size is not supported with Batch Messages
-uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx, Message& batchedMessage) {
+uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx,
+                                                          Message& batchedMessage) {
     unsigned int batchSize = batchedMessage.impl_->metadata.num_messages_in_batch();
     batchAcknowledgementTracker_.receivedMessage(batchedMessage);
     LOG_DEBUG("Received Batch messages of size - " << batchSize
-             << " -- msgId: " << batchedMessage.getMessageId());
+                                                   << " -- msgId: " << batchedMessage.getMessageId());
 
     int skippedMessages = 0;
 
@@ -334,11 +318,11 @@ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnection
 
             // If we are receiving a batch message, we need to discard messages that were prior
             // to the startMessageId
-            if (msgId.ledgerId_ == startMessageId_.value().ledgerId_
-                    && msgId.entryId_ == startMessageId_.value().entryId_
-                    && msgId.batchIndex_ <= startMessageId_.value().batchIndex_) {
-                LOG_DEBUG(
-                        getName() << "Ignoring message from before the startMessageId" << msg.getMessageId());
+            if (msgId.ledgerId_ == startMessageId_.value().ledgerId_ &&
+                msgId.entryId_ == startMessageId_.value().entryId_ &&
+                msgId.batchIndex_ <= startMessageId_.value().batchIndex_) {
+                LOG_DEBUG(getName() << "Ignoring message from before the startMessageId"
+                                    << msg.getMessageId());
                 ++skippedMessages;
                 continue;
             }
@@ -355,10 +339,8 @@ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnection
     return batchSize - skippedMessages;
 }
 
-bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx,
-                                             const proto::CommandMessage& msg,
-                                             const proto::MessageMetadata& metadata,
-                                             SharedBuffer& payload) {
+bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx, const proto::CommandMessage& msg,
+                                             const proto::MessageMetadata& metadata, SharedBuffer& payload) {
     if (!metadata.has_compression()) {
         return true;
     }
@@ -370,15 +352,14 @@ bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx,
     if (payloadSize > Commands::MaxMessageSize) {
         // Uncompressed size is itself corrupted since it cannot be bigger than the MaxMessageSize
         LOG_ERROR(getName() << "Got corrupted payload message size " << payloadSize  //
-                << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
-        discardCorruptedMessage(cnx, msg.message_id(),
-                                proto::CommandAck::UncompressedSizeCorruption);
+                            << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
+        discardCorruptedMessage(cnx, msg.message_id(), proto::CommandAck::UncompressedSizeCorruption);
         return false;
     }
 
     if (!CompressionCodecProvider::getCodec(compressionType).decode(payload, uncompressedSize, payload)) {
         LOG_ERROR(getName() << "Failed to decompress message with " << uncompressedSize  //
-                << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
+                            << " at  " << msg.message_id().ledgerid() << ":" << msg.message_id().entryid());
         discardCorruptedMessage(cnx, msg.message_id(), proto::CommandAck::DecompressionError);
         return false;
     }
@@ -389,10 +370,11 @@ bool ConsumerImpl::uncompressMessageIfNeeded(const ClientConnectionPtr& cnx,
 void ConsumerImpl::discardCorruptedMessage(const ClientConnectionPtr& cnx,
                                            const proto::MessageIdData& messageId,
                                            proto::CommandAck::ValidationError validationError) {
-    LOG_ERROR(
-            getName() << "Discarding corrupted message at " << messageId.ledgerid() << ":" << messageId.entryid());
+    LOG_ERROR(getName() << "Discarding corrupted message at " << messageId.ledgerid() << ":"
+                        << messageId.entryid());
 
-    SharedBuffer cmd  = Commands::newAck(consumerId_, messageId, proto::CommandAck::Individual, validationError);
+    SharedBuffer cmd =
+        Commands::newAck(consumerId_, messageId, proto::CommandAck::Individual, validationError);
 
     cnx->sendCommand(cmd);
     increaseAvailablePermits(cnx);
@@ -431,7 +413,7 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
     // Just being cautious
     if (incomingMessages_.size() != 0) {
         LOG_ERROR(
-                getName() << "The incoming message queue should never be greater than 0 when Queue size is 0");
+            getName() << "The incoming message queue should never be greater than 0 when Queue size is 0");
         incomingMessages_.clear();
     }
     Lock localLock(mutex_);
@@ -446,7 +428,8 @@ Result ConsumerImpl::fetchSingleMessageFromBroker(Message& msg) {
     while (true) {
         incomingMessages_.pop(msg);
         {
-            // Lock needed to prevent race between connectionOpened and the check "msg.impl_->cnx_ == currentCnx.get())"
+            // Lock needed to prevent race between connectionOpened and the check "msg.impl_->cnx_ ==
+            // currentCnx.get())"
             Lock localLock(mutex_);
             // if message received due to an old flow - discard it and wait for the message from the
             // latest flow command
@@ -523,8 +506,7 @@ Result ConsumerImpl::receiveHelper(Message& msg, int timeout) {
 
 void ConsumerImpl::messageProcessed(Message& msg) {
     Lock lock(mutex_);
-    lastDequedMessage_ = Optional<BatchMessageId>::of(
-            static_cast<const BatchMessageId&>(msg.getMessageId()));
+    lastDequedMessage_ = Optional<BatchMessageId>::of(static_cast<const BatchMessageId&>(msg.getMessageId()));
 
     ClientConnectionPtr currentCnx = getCnx().lock();
     if (currentCnx && msg.impl_->cnx_ != currentCnx.get()) {
@@ -536,38 +518,41 @@ void ConsumerImpl::messageProcessed(Message& msg) {
 }
 
 /**
- * Clear the internal receiver queue and returns the message id of what was the 1st message in the queue that was
+ * Clear the internal receiver queue and returns the message id of what was the 1st message in the queue that
+ * was
  * not seen by the application
  */
 Optional<BatchMessageId> ConsumerImpl::clearReceiveQueue() {
     Message nextMessageInQueue;
     if (incomingMessages_.peekAndClear(nextMessageInQueue)) {
         // There was at least one message pending in the queue
-        // We can safely cast to 'BatchMessageId' since all the messages queued will have that type of message id,
+        // We can safely cast to 'BatchMessageId' since all the messages queued will have that type of message
+        // id,
         // irrespective of whether they were part of a batch or not.
         const BatchMessageId& nextMessageId =
-                static_cast<const BatchMessageId&>(nextMessageInQueue.getMessageId());
+            static_cast<const BatchMessageId&>(nextMessageInQueue.getMessageId());
         BatchMessageId previousMessageId;
         if (nextMessageId.batchIndex_ >= 0) {
             previousMessageId = BatchMessageId(nextMessageId.ledgerId_, nextMessageId.entryId_,
                                                nextMessageId.batchIndex_ - 1);
         } else {
-            previousMessageId = BatchMessageId(nextMessageId.ledgerId_, nextMessageId.entryId_ - 1,
-                                               -1);
+            previousMessageId = BatchMessageId(nextMessageId.ledgerId_, nextMessageId.entryId_ - 1, -1);
         }
         return Optional<BatchMessageId>::of(previousMessageId);
     } else if (lastDequedMessage_.is_present()) {
-        // If the queue was empty we need to restart from the message just after the last one that has been dequeued
+        // If the queue was empty we need to restart from the message just after the last one that has been
+        // dequeued
         // in the past
         return lastDequedMessage_;
     } else {
-        // No message was received or dequeued by this consumer. Next message would still be the startMessageId
+        // No message was received or dequeued by this consumer. Next message would still be the
+        // startMessageId
         return startMessageId_;
     }
 }
 
 void ConsumerImpl::increaseAvailablePermits(const ClientConnectionPtr& currentCnx, int numberOfPermits) {
-    int additionalPermits =  0;
+    int additionalPermits = 0;
 
     availablePermits_ += numberOfPermits;
     if (availablePermits_ >= config_.getReceiverQueueSize() / 2) {
@@ -598,7 +583,6 @@ inline proto::CommandSubscribe_SubType ConsumerImpl::getSubType() {
     }
 }
 
-
 void ConsumerImpl::statsCallback(Result res, ResultCallback callback, proto::CommandAck_AckType ackType) {
     consumerStatsBasePtr_->messageAcknowledged(res, ackType);
     if (callback) {
@@ -607,9 +591,11 @@ void ConsumerImpl::statsCallback(Result res, ResultCallback callback, proto::Com
 }
 
 void ConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback) {
-    ResultCallback cb = boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Individual);
+    ResultCallback cb =
+        boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Individual);
     const BatchMessageId& batchMsgId = (const BatchMessageId&)msgId;
-    if(batchMsgId.batchIndex_ != -1 && !batchAcknowledgementTracker_.isBatchReady(batchMsgId, proto::CommandAck_AckType_Individual)) {
+    if (batchMsgId.batchIndex_ != -1 &&
+        !batchAcknowledgementTracker_.isBatchReady(batchMsgId, proto::CommandAck_AckType_Individual)) {
         cb(ResultOk);
         return;
     }
@@ -617,11 +603,13 @@ void ConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callb
 }
 
 void ConsumerImpl::acknowledgeCumulativeAsync(const MessageId& mId, ResultCallback callback) {
-    ResultCallback cb = boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Cumulative);
-    const BatchMessageId& msgId = (const BatchMessageId&) mId;
-    if(msgId.batchIndex_ != -1 && !batchAcknowledgementTracker_.isBatchReady(msgId, proto::CommandAck_AckType_Cumulative)) {
+    ResultCallback cb =
+        boost::bind(&ConsumerImpl::statsCallback, this, _1, callback, proto::CommandAck_AckType_Cumulative);
+    const BatchMessageId& msgId = (const BatchMessageId&)mId;
+    if (msgId.batchIndex_ != -1 &&
+        !batchAcknowledgementTracker_.isBatchReady(msgId, proto::CommandAck_AckType_Cumulative)) {
         BatchMessageId messageId = batchAcknowledgementTracker_.getGreatestCumulativeAckReady(msgId);
-        if(messageId == BatchMessageId()) {
+        if (messageId == BatchMessageId()) {
             // nothing to ack
             cb(ResultOk);
         } else {
@@ -634,7 +622,6 @@ void ConsumerImpl::acknowledgeCumulativeAsync(const MessageId& mId, ResultCallba
 
 void ConsumerImpl::doAcknowledge(const BatchMessageId& messageId, proto::CommandAck_AckType ackType,
                                  ResultCallback callback) {
-
     proto::MessageIdData messageIdData;
     messageIdData.set_ledgerid(messageId.ledgerId_);
     messageIdData.set_entryid(messageId.entryId_);
@@ -649,12 +636,12 @@ void ConsumerImpl::doAcknowledge(const BatchMessageId& messageId, proto::Command
         }
         batchAcknowledgementTracker_.deleteAckedMessage((BatchMessageId&)messageId, ackType);
         callback(ResultOk);
-        LOG_DEBUG(
-                getName() << "ack request sent for message - [" << messageIdData.ledgerid() << "," << messageIdData.entryid() << "]");
+        LOG_DEBUG(getName() << "ack request sent for message - [" << messageIdData.ledgerid() << ","
+                            << messageIdData.entryid() << "]");
 
     } else {
         LOG_DEBUG(getName() << "Connection is not ready, Acknowledge failed for message - ["  //
-                << messageIdData.ledgerid() << "," << messageIdData.entryid() << "]");
+                            << messageIdData.ledgerid() << "," << messageIdData.entryid() << "]");
         callback(ResultNotConnected);
     }
 }
@@ -687,7 +674,6 @@ void ConsumerImpl::closeAsync(ResultCallback callback) {
         return;
     }
 
-
     ClientImplPtr client = client_.lock();
     if (!client) {
         lock.unlock();
@@ -701,13 +687,11 @@ void ConsumerImpl::closeAsync(ResultCallback callback) {
     // Lock is no longer required
     lock.unlock();
     int requestId = client->newRequestId();
-    Future<Result, ResponseData> future = cnx->sendRequestWithId(
-            Commands::newCloseConsumer(consumerId_, requestId), requestId);
+    Future<Result, ResponseData> future =
+        cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId), requestId);
     if (!callback.empty()) {
-        future.addListener(
-                boost::bind(&ConsumerImpl::handleClose, shared_from_this(), _1, callback));
+        future.addListener(boost::bind(&ConsumerImpl::handleClose, shared_from_this(), _1, callback));
     }
-
 }
 
 void ConsumerImpl::handleClose(Result result, ResultCallback callback) {
@@ -729,10 +713,7 @@ void ConsumerImpl::handleClose(Result result, ResultCallback callback) {
     callback(result);
 }
 
-
-const std::string& ConsumerImpl::getName() const {
-    return consumerStr_;
-}
+const std::string& ConsumerImpl::getName() const { return consumerStr_; }
 
 void ConsumerImpl::shutdown() {
     Lock lock(mutex_);
@@ -777,8 +758,7 @@ Result ConsumerImpl::resumeMessageListener() {
 
     for (size_t i = 0; i < count; i++) {
         // Trigger message listener callback in a separate thread
-        listenerExecutor_->postWork(
-                boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
+        listenerExecutor_->postWork(boost::bind(&ConsumerImpl::internalListener, shared_from_this()));
     }
     return ResultOk;
 }
@@ -786,10 +766,9 @@ Result ConsumerImpl::resumeMessageListener() {
 void ConsumerImpl::redeliverUnacknowledgedMessages() {
     ClientConnectionPtr cnx = getCnx().lock();
     if (cnx) {
-        if(cnx->getServerProtocolVersion() >= proto::v2) {
+        if (cnx->getServerProtocolVersion() >= proto::v2) {
             cnx->sendCommand(Commands::newRedeliverUnacknowledgedMessages(consumerId_));
-            LOG_DEBUG(
-                "Sending RedeliverUnacknowledgedMessages command for Consumer - " << getConsumerId());
+            LOG_DEBUG("Sending RedeliverUnacknowledgedMessages command for Consumer - " << getConsumerId());
         } else {
             LOG_DEBUG("Reconnecting the client to redeliver the messages for Consumer - " << getName());
             cnx->close();
@@ -799,9 +778,7 @@ void ConsumerImpl::redeliverUnacknowledgedMessages() {
     }
 }
 
-int ConsumerImpl::getNumOfPrefetchedMessages() const {
-    return incomingMessages_.size();
-}
+int ConsumerImpl::getNumOfPrefetchedMessages() const { return incomingMessages_.size(); }
 
 void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) {
     Lock lock(mutex_);
@@ -816,7 +793,8 @@ void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callb
         LOG_DEBUG(getName() << "Serving data from cache");
         BrokerConsumerStatsImpl brokerConsumerStats = brokerConsumerStats_;
         lock.unlock();
-        callback(ResultOk, BrokerConsumerStats(boost::make_shared<BrokerConsumerStatsImpl>(brokerConsumerStats_)));
+        callback(ResultOk,
+                 BrokerConsumerStats(boost::make_shared<BrokerConsumerStatsImpl>(brokerConsumerStats_)));
         return;
     }
     lock.unlock();
@@ -826,14 +804,16 @@ void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callb
         if (cnx->getServerProtocolVersion() >= proto::v8) {
             ClientImplPtr client = client_.lock();
             uint64_t requestId = client->newRequestId();
-            LOG_DEBUG(getName() <<
-                    " Sending ConsumerStats Command for Consumer - " << getConsumerId() << ", requestId - "<<requestId);
+            LOG_DEBUG(getName() << " Sending ConsumerStats Command for Consumer - " << getConsumerId()
+                                << ", requestId - " << requestId);
 
-            cnx->newConsumerStats(consumerId_, requestId).addListener(
-                    boost::bind(&ConsumerImpl::brokerConsumerStatsListener, shared_from_this(), _1, _2, callback));
+            cnx->newConsumerStats(consumerId_, requestId)
+                .addListener(boost::bind(&ConsumerImpl::brokerConsumerStatsListener, shared_from_this(), _1,
+                                         _2, callback));
             return;
         } else {
-            LOG_ERROR(getName() << " Operation not supported since server protobuf version " << cnx->getServerProtocolVersion() << " is older than proto::v7");
+            LOG_ERROR(getName() << " Operation not supported since server protobuf version "
+                                << cnx->getServerProtocolVersion() << " is older than proto::v7");
             callback(ResultUnsupportedVersionError, BrokerConsumerStats());
             return;
         }
@@ -842,9 +822,8 @@ void ConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callb
     callback(ResultNotConnected, BrokerConsumerStats());
 }
 
-void ConsumerImpl::brokerConsumerStatsListener(Result res, BrokerConsumerStatsImpl brokerConsumerStats
-        , BrokerConsumerStatsCallback callback) {
-
+void ConsumerImpl::brokerConsumerStatsListener(Result res, BrokerConsumerStatsImpl brokerConsumerStats,
+                                               BrokerConsumerStatsCallback callback) {
     if (res == ResultOk) {
         Lock lock(mutex_);
         brokerConsumerStats.setCacheTime(config_.getBrokerConsumerStatsCacheTimeInMs());
diff --git a/pulsar-client-cpp/lib/ConsumerImpl.h b/pulsar-client-cpp/lib/ConsumerImpl.h
index dd94134f2..c68abf48f 100644
--- a/pulsar-client-cpp/lib/ConsumerImpl.h
+++ b/pulsar-client-cpp/lib/ConsumerImpl.h
@@ -52,16 +52,18 @@ class BatchAcknowledgementTracker;
 typedef boost::shared_ptr<ConsumerImpl> ConsumerImplPtr;
 typedef boost::weak_ptr<ConsumerImpl> ConsumerImplWeakPtr;
 
-enum ConsumerTopicType {
+enum ConsumerTopicType
+{
     NonPartitioned,
     Partitioned
 };
 
- class ConsumerImpl : public ConsumerImplBase, public HandlerBase, public boost::enable_shared_from_this<ConsumerImpl> {
-
- public:
-    ConsumerImpl(const ClientImplPtr client, const std::string& topic,
-                 const std::string& subscription, const ConsumerConfiguration&,
+class ConsumerImpl : public ConsumerImplBase,
+                     public HandlerBase,
+                     public boost::enable_shared_from_this<ConsumerImpl> {
+   public:
+    ConsumerImpl(const ClientImplPtr client, const std::string& topic, const std::string& subscription,
+                 const ConsumerConfiguration&,
                  const ExecutorServicePtr listenerExecutor = ExecutorServicePtr(),
                  const ConsumerTopicType consumerTopicType = NonPartitioned,
                  Commands::SubscriptionMode = Commands::SubscriptionModeDurable,
@@ -72,8 +74,7 @@ enum ConsumerTopicType {
     void receiveMessages(const ClientConnectionPtr& cnx, unsigned int count);
     uint64_t getConsumerId();
     void messageReceived(const ClientConnectionPtr& cnx, const proto::CommandMessage& msg,
-                         bool& isChecksumValid, proto::MessageMetadata& msgMetadata,
-                         SharedBuffer& payload);
+                         bool& isChecksumValid, proto::MessageMetadata& msgMetadata, SharedBuffer& payload);
     int incrementAndGetPermits(uint64_t cnxSequenceId);
     void messageProcessed(Message& msg);
     inline proto::CommandSubscribe_SubType getSubType();
@@ -99,30 +100,28 @@ enum ConsumerTopicType {
     virtual Result resumeMessageListener();
     virtual void redeliverUnacknowledgedMessages();
     virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
- protected:
+
+   protected:
     void connectionOpened(const ClientConnectionPtr& cnx);
     void connectionFailed(Result result);
     void handleCreateConsumer(const ClientConnectionPtr& cnx, Result result);
 
     void internalListener();
     void handleClose(Result result, ResultCallback callback);
-    virtual HandlerBaseWeakPtr get_weak_from_this() {
-        return shared_from_this();
-    }
+    virtual HandlerBaseWeakPtr get_weak_from_this() { return shared_from_this(); }
     virtual const std::string& getName() const;
-    virtual int getNumOfPrefetchedMessages() const ;
+    virtual int getNumOfPrefetchedMessages() const;
     ConsumerStatsBasePtr consumerStatsBasePtr_;
-private:
+
+   private:
     bool waitingForZeroQueueSizeMessage;
     bool uncompressMessageIfNeeded(const ClientConnectionPtr& cnx, const proto::CommandMessage& msg,
                                    const proto::MessageMetadata& metadata, SharedBuffer& payload);
-    void discardCorruptedMessage(const ClientConnectionPtr& cnx,
-                                 const proto::MessageIdData& messageId,
+    void discardCorruptedMessage(const ClientConnectionPtr& cnx, const proto::MessageIdData& messageId,
                                  proto::CommandAck::ValidationError validationError);
     void increaseAvailablePermits(const ClientConnectionPtr& currentCnx, int numberOfPermits = 1);
     void drainIncomingMessageQueue(size_t count);
-    uint32_t receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx,
-                                                Message &batchedMessage);
+    uint32_t receiveIndividualMessagesFromBatch(const ClientConnectionPtr& cnx, Message& batchedMessage);
     void brokerConsumerStatsListener(Result, BrokerConsumerStatsImpl, BrokerConsumerStatsCallback);
 
     // TODO - Convert these functions to lambda when we move to C++11
diff --git a/pulsar-client-cpp/lib/ConsumerImplBase.h b/pulsar-client-cpp/lib/ConsumerImplBase.h
index 7ca4602f1..a71b68221 100644
--- a/pulsar-client-cpp/lib/ConsumerImplBase.h
+++ b/pulsar-client-cpp/lib/ConsumerImplBase.h
@@ -28,12 +28,11 @@ typedef boost::weak_ptr<ConsumerImplBase> ConsumerImplBaseWeakPtr;
 typedef boost::shared_ptr<ConsumerImplBase> ConsumerImplBasePtr;
 
 class ConsumerImplBase {
-public:
-    virtual ~ConsumerImplBase(){
-    }
+   public:
+    virtual ~ConsumerImplBase() {}
     virtual Future<Result, ConsumerImplBaseWeakPtr> getConsumerCreatedFuture() = 0;
     virtual const std::string& getSubscriptionName() const = 0;
-    virtual const std::string& getTopic() const  = 0;
+    virtual const std::string& getTopic() const = 0;
     virtual Result receive(Message& msg) = 0;
     virtual Result receive(Message& msg, int timeout) = 0;
     virtual void unsubscribeAsync(ResultCallback callback) = 0;
@@ -52,4 +51,4 @@ class ConsumerImplBase {
     virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) = 0;
 };
 }
-#endif //PULSAR_CONSUMER_IMPL_BASE_HEADER
+#endif  // PULSAR_CONSUMER_IMPL_BASE_HEADER
diff --git a/pulsar-client-cpp/lib/DeprecatedException.cc b/pulsar-client-cpp/lib/DeprecatedException.cc
index 8b788bf27..ba5154636 100644
--- a/pulsar-client-cpp/lib/DeprecatedException.cc
+++ b/pulsar-client-cpp/lib/DeprecatedException.cc
@@ -19,10 +19,8 @@
 #include <pulsar/DeprecatedException.h>
 
 namespace pulsar {
-    const std::string DeprecatedException::message_prefix = "Deprecated: ";
+const std::string DeprecatedException::message_prefix = "Deprecated: ";
 
-    DeprecatedException::DeprecatedException(const std::string& __arg)
-            : std::runtime_error(message_prefix + __arg) {
-
-    }
+DeprecatedException::DeprecatedException(const std::string& __arg)
+    : std::runtime_error(message_prefix + __arg) {}
 }
\ No newline at end of file
diff --git a/pulsar-client-cpp/lib/DestinationName.cc b/pulsar-client-cpp/lib/DestinationName.cc
index 77dd7276f..5c8eb3e41 100644
--- a/pulsar-client-cpp/lib/DestinationName.cc
+++ b/pulsar-client-cpp/lib/DestinationName.cc
@@ -34,156 +34,140 @@
 DECLARE_LOG_OBJECT()
 namespace pulsar {
 
-    typedef boost::unique_lock<boost::mutex> Lock;
-    // static members
-    CURL* DestinationName::curl = NULL;
-    boost::mutex DestinationName::curlHandleMutex;
-
-    CURL* DestinationName::getCurlHandle() {
-        if (curl == NULL) {
-            // this handle can not be shared across threads, so had to get here everytime
-            curl = curl_easy_init();
-        }
-        return curl;
-    }
-    //********************************************************************
-    DestinationName::DestinationName() {
-    }
-
-    bool DestinationName::init(const std::string& destinationName) {
-        destination_ = destinationName;
-        if(destinationName.find("://") == std::string::npos){
-            LOG_ERROR("Destination Name Invalid, domain not present - " << destinationName);
-            return false;
-        }
-        parse(destination_, domain_, property_, cluster_, namespacePortion_, localName_);
-        if(localName_.empty()) {
-            LOG_ERROR("Destination Name is not valid, topic name is empty - " << destination_);
-            return false;
-        }
-        namespaceName_ = NamespaceName::get(property_, cluster_, namespacePortion_);
-        return true;
-    }
-    void DestinationName::parse(const std::string& destinationName,
-                                std::string& domain,
-                                std::string& property,
-                                std::string& cluster,
-                                std::string& namespacePortion,
-                                std::string& localName) {
-        std::string destinationNameCopy = destinationName;
-        boost::replace_first(destinationNameCopy, "://", "/");
-        std::vector<std::string> pathTokens;
-        boost::algorithm::split(pathTokens, destinationNameCopy, boost::algorithm::is_any_of("/"));
-        if (pathTokens.size() < 5) {
-            LOG_ERROR("Destination Name Invalid, does not have enough parts - " << destinationName);
-            return;
-        }
-        domain = pathTokens[0];
-        property = pathTokens[1];
-        cluster = pathTokens[2];
-        namespacePortion = pathTokens[3];
-        size_t slashIndex = -1;
-        //find four '/', whatever is left is topic local name
-        for(int i=0; i < 4; i++) {
-            slashIndex = destinationNameCopy.find('/', slashIndex + 1);
-        }
-        // get index to next char to '/'
-        slashIndex++;
-        localName = destinationNameCopy.substr( slashIndex, (destinationNameCopy.size() - slashIndex));
-    }
-    std::string DestinationName::getEncodedName(const std::string& nameBeforeEncoding) {
-        Lock lock(curlHandleMutex);
-        std::string nameAfterEncoding;
-        if(getCurlHandle()) {
-            char *encodedName = curl_easy_escape(getCurlHandle(), nameBeforeEncoding.c_str(), nameBeforeEncoding.size());
-            if(encodedName) {
-                nameAfterEncoding.assign(encodedName);
-                curl_free(encodedName);
-            } else {
-                LOG_ERROR("Unable to encode the name using curl_easy_escape, name - " << nameBeforeEncoding);
-            }
+typedef boost::unique_lock<boost::mutex> Lock;
+// static members
+CURL* DestinationName::curl = NULL;
+boost::mutex DestinationName::curlHandleMutex;
+
+CURL* DestinationName::getCurlHandle() {
+    if (curl == NULL) {
+        // this handle can not be shared across threads, so had to get here everytime
+        curl = curl_easy_init();
+    }
+    return curl;
+}
+//********************************************************************
+DestinationName::DestinationName() {}
+
+bool DestinationName::init(const std::string& destinationName) {
+    destination_ = destinationName;
+    if (destinationName.find("://") == std::string::npos) {
+        LOG_ERROR("Destination Name Invalid, domain not present - " << destinationName);
+        return false;
+    }
+    parse(destination_, domain_, property_, cluster_, namespacePortion_, localName_);
+    if (localName_.empty()) {
+        LOG_ERROR("Destination Name is not valid, topic name is empty - " << destination_);
+        return false;
+    }
+    namespaceName_ = NamespaceName::get(property_, cluster_, namespacePortion_);
+    return true;
+}
+void DestinationName::parse(const std::string& destinationName, std::string& domain, std::string& property,
+                            std::string& cluster, std::string& namespacePortion, std::string& localName) {
+    std::string destinationNameCopy = destinationName;
+    boost::replace_first(destinationNameCopy, "://", "/");
+    std::vector<std::string> pathTokens;
+    boost::algorithm::split(pathTokens, destinationNameCopy, boost::algorithm::is_any_of("/"));
+    if (pathTokens.size() < 5) {
+        LOG_ERROR("Destination Name Invalid, does not have enough parts - " << destinationName);
+        return;
+    }
+    domain = pathTokens[0];
+    property = pathTokens[1];
+    cluster = pathTokens[2];
+    namespacePortion = pathTokens[3];
+    size_t slashIndex = -1;
+    // find four '/', whatever is left is topic local name
+    for (int i = 0; i < 4; i++) {
+        slashIndex = destinationNameCopy.find('/', slashIndex + 1);
+    }
+    // get index to next char to '/'
+    slashIndex++;
+    localName = destinationNameCopy.substr(slashIndex, (destinationNameCopy.size() - slashIndex));
+}
+std::string DestinationName::getEncodedName(const std::string& nameBeforeEncoding) {
+    Lock lock(curlHandleMutex);
+    std::string nameAfterEncoding;
+    if (getCurlHandle()) {
+        char* encodedName =
+            curl_easy_escape(getCurlHandle(), nameBeforeEncoding.c_str(), nameBeforeEncoding.size());
+        if (encodedName) {
+            nameAfterEncoding.assign(encodedName);
+            curl_free(encodedName);
         } else {
-            LOG_ERROR("Unable to get CURL handle to encode the name - " << nameBeforeEncoding);
+            LOG_ERROR("Unable to encode the name using curl_easy_escape, name - " << nameBeforeEncoding);
         }
-        return nameAfterEncoding;
-    }
-
-    std::string DestinationName::getDomain() {
-        return domain_;
-    }
-
-    std::string DestinationName::getProperty() {
-        return property_;
-    }
-
-    std::string DestinationName::getCluster() {
-        return cluster_;
-    }
-
-    std::string DestinationName::getNamespacePortion() {
-        return namespacePortion_;
-    }
-
-    std::string DestinationName::getLocalName() {
-        return localName_;
-    }
-
-    std::string DestinationName::getEncodedLocalName() {
-        return getEncodedName(localName_);
-    }
-
-    bool DestinationName::operator ==(const DestinationName& other) {
-        return (this->destination_.compare(other.destination_) == 0);
-    }
-
-    bool DestinationName::validateDestination() {
-        // check domain matches to "persistent", in future check "memory" when server is ready
-        if (domain_.compare("persistent") != 0) {
-            return false;
-        }
-        if (!property_.empty() && !cluster_.empty() && !namespacePortion_.empty() && !localName_.empty()) {
-            return NamedEntity::checkName(property_) && NamedEntity::checkName(cluster_)
-                && NamedEntity::checkName(namespacePortion_);
-        } else {
-            return false;
-        }
-    }
-
-    boost::shared_ptr<DestinationName> DestinationName::get(const std::string& destination) {
-        boost::shared_ptr<DestinationName> ptr(new DestinationName());
-        if (!ptr->init(destination)) {
-            LOG_ERROR("Destination Name Initialization failed");
-            return boost::shared_ptr<DestinationName>();
-        }
-        if (ptr->validateDestination()) {
-            return ptr;
-        } else {
-            LOG_ERROR("Destination Name Validation Failed");
-            return boost::shared_ptr<DestinationName>();
-        }
-    }
-
-    //TODO - for now return empty string if there's any error in format, later think about better error handling
-    std::string DestinationName::getLookupName() {
-        std::stringstream ss;
-        std::string seperator("/");
-        ss << domain_ << seperator << property_ << seperator << cluster_ << seperator
-           << namespacePortion_ << seperator << getEncodedLocalName();
-        return ss.str();
-    }
-
-    std::string DestinationName::toString() {
-        std::stringstream ss;
-        std::string seperator("/");
-        ss << domain_ << "://" << property_ << seperator << cluster_ << seperator
-           << namespacePortion_ << seperator << localName_;
-        return ss.str();
-    }
-
-    const std::string DestinationName::getTopicPartitionName(unsigned int partition) {
-        std::stringstream topicPartitionName;
-        // make this topic name as well
-        topicPartitionName << toString()<< PartitionedProducerImpl::PARTITION_NAME_SUFFIX << partition ;
-        return topicPartitionName.str();
-    }
-} //namespace pulsar
+    } else {
+        LOG_ERROR("Unable to get CURL handle to encode the name - " << nameBeforeEncoding);
+    }
+    return nameAfterEncoding;
+}
+
+std::string DestinationName::getDomain() { return domain_; }
+
+std::string DestinationName::getProperty() { return property_; }
+
+std::string DestinationName::getCluster() { return cluster_; }
+
+std::string DestinationName::getNamespacePortion() { return namespacePortion_; }
+
+std::string DestinationName::getLocalName() { return localName_; }
+
+std::string DestinationName::getEncodedLocalName() { return getEncodedName(localName_); }
+
+bool DestinationName::operator==(const DestinationName& other) {
+    return (this->destination_.compare(other.destination_) == 0);
+}
+
+bool DestinationName::validateDestination() {
+    // check domain matches to "persistent", in future check "memory" when server is ready
+    if (domain_.compare("persistent") != 0) {
+        return false;
+    }
+    if (!property_.empty() && !cluster_.empty() && !namespacePortion_.empty() && !localName_.empty()) {
+        return NamedEntity::checkName(property_) && NamedEntity::checkName(cluster_) &&
+               NamedEntity::checkName(namespacePortion_);
+    } else {
+        return false;
+    }
+}
+
+boost::shared_ptr<DestinationName> DestinationName::get(const std::string& destination) {
+    boost::shared_ptr<DestinationName> ptr(new DestinationName());
+    if (!ptr->init(destination)) {
+        LOG_ERROR("Destination Name Initialization failed");
+        return boost::shared_ptr<DestinationName>();
+    }
+    if (ptr->validateDestination()) {
+        return ptr;
+    } else {
+        LOG_ERROR("Destination Name Validation Failed");
+        return boost::shared_ptr<DestinationName>();
+    }
+}
+
+// TODO - for now return empty string if there's any error in format, later think about better error handling
+std::string DestinationName::getLookupName() {
+    std::stringstream ss;
+    std::string seperator("/");
+    ss << domain_ << seperator << property_ << seperator << cluster_ << seperator << namespacePortion_
+       << seperator << getEncodedLocalName();
+    return ss.str();
+}
+
+std::string DestinationName::toString() {
+    std::stringstream ss;
+    std::string seperator("/");
+    ss << domain_ << "://" << property_ << seperator << cluster_ << seperator << namespacePortion_
+       << seperator << localName_;
+    return ss.str();
+}
+
+const std::string DestinationName::getTopicPartitionName(unsigned int partition) {
+    std::stringstream topicPartitionName;
+    // make this topic name as well
+    topicPartitionName << toString() << PartitionedProducerImpl::PARTITION_NAME_SUFFIX << partition;
+    return topicPartitionName.str();
+}
+}  // namespace pulsar
diff --git a/pulsar-client-cpp/lib/DestinationName.h b/pulsar-client-cpp/lib/DestinationName.h
index afc65112e..4f5db9f85 100644
--- a/pulsar-client-cpp/lib/DestinationName.h
+++ b/pulsar-client-cpp/lib/DestinationName.h
@@ -30,47 +30,44 @@
 #pragma GCC visibility push(default)
 
 namespace pulsar {
-    class DestinationName : public ServiceUnitId {
-    private:
-        std::string destination_;
-        std::string domain_;
-        std::string property_;
-        std::string cluster_;
-        std::string namespacePortion_;
-        std::string localName_;
-        boost::shared_ptr<NamespaceName> namespaceName_;
+class DestinationName : public ServiceUnitId {
+   private:
+    std::string destination_;
+    std::string domain_;
+    std::string property_;
+    std::string cluster_;
+    std::string namespacePortion_;
+    std::string localName_;
+    boost::shared_ptr<NamespaceName> namespaceName_;
 
-    public:
-        std::string getLookupName();
-        std::string getDomain();
-        std::string getProperty();
-        std::string getCluster();
-        std::string getNamespacePortion();
-        std::string getLocalName();
-        std::string getEncodedLocalName();
-        std::string toString();
-        static boost::shared_ptr<DestinationName> get(const std::string& destination);
-        bool operator ==(const DestinationName& other);
-        static std::string getEncodedName(const std::string& nameBeforeEncoding);
-        const std::string getTopicPartitionName(unsigned int partition);
-    private:
-        static CURL* getCurlHandle();
-        static CURL* curl;
-        static boost::mutex curlHandleMutex;
-        static void parse(const std::string& destinationName,
-                          std::string& domain,
-                          std::string& property,
-                          std::string& cluster,
-                          std::string& namespacePortion,
-                          std::string& localName);
-        DestinationName();
-        bool validateDestination();
-        bool init(const std::string& destinationName);
-    };
-    typedef  boost::shared_ptr<DestinationName> DestinationNamePtr;
+   public:
+    std::string getLookupName();
+    std::string getDomain();
+    std::string getProperty();
+    std::string getCluster();
+    std::string getNamespacePortion();
+    std::string getLocalName();
+    std::string getEncodedLocalName();
+    std::string toString();
+    static boost::shared_ptr<DestinationName> get(const std::string& destination);
+    bool operator==(const DestinationName& other);
+    static std::string getEncodedName(const std::string& nameBeforeEncoding);
+    const std::string getTopicPartitionName(unsigned int partition);
+
+   private:
+    static CURL* getCurlHandle();
+    static CURL* curl;
+    static boost::mutex curlHandleMutex;
+    static void parse(const std::string& destinationName, std::string& domain, std::string& property,
+                      std::string& cluster, std::string& namespacePortion, std::string& localName);
+    DestinationName();
+    bool validateDestination();
+    bool init(const std::string& destinationName);
+};
+typedef boost::shared_ptr<DestinationName> DestinationNamePtr;
 }
 // end of namespace pulsar
 
 #pragma GCC visibility pop
 
-#endif //_PULSAR_DESTINATION_NAME_HEADER_
+#endif  //_PULSAR_DESTINATION_NAME_HEADER_
diff --git a/pulsar-client-cpp/lib/ExecutorService.cc b/pulsar-client-cpp/lib/ExecutorService.cc
index 5ad9e5fd1..4a663e6ce 100644
--- a/pulsar-client-cpp/lib/ExecutorService.cc
+++ b/pulsar-client-cpp/lib/ExecutorService.cc
@@ -27,14 +27,11 @@
 namespace pulsar {
 
 ExecutorService::ExecutorService()
-        : io_service_(),
-          work_(new BackgroundWork(io_service_)),
-          worker_(boost::bind(&boost::asio::io_service::run, &io_service_)) {
-}
+    : io_service_(),
+      work_(new BackgroundWork(io_service_)),
+      worker_(boost::bind(&boost::asio::io_service::run, &io_service_)) {}
 
-ExecutorService::~ExecutorService() {
-    close();
-}
+ExecutorService::~ExecutorService() { close(); }
 
 /*
  *  factory method of boost::asio::ip::tcp::socket associated with io_service_ instance
@@ -45,7 +42,8 @@ SocketPtr ExecutorService::createSocket() {
 }
 
 TlsSocketPtr ExecutorService::createTlsSocket(SocketPtr &socket, boost::asio::ssl::context &ctx) {
-    return boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> >(new boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> (*socket, ctx));
+    return boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket &> >(
+        new boost::asio::ssl::stream<boost::asio::ip::tcp::socket &>(*socket, ctx));
 }
 
 /*
@@ -66,17 +64,12 @@ void ExecutorService::close() {
     worker_.join();
 }
 
-void ExecutorService::postWork(boost::function<void(void)> task) {
-    io_service_.post(task);
-}
+void ExecutorService::postWork(boost::function<void(void)> task) { io_service_.post(task); }
 
 /////////////////////
 
 ExecutorServiceProvider::ExecutorServiceProvider(int nthreads)
-        : executors_(nthreads),
-          executorIdx_(0),
-          mutex_() {
-}
+    : executors_(nthreads), executorIdx_(0), mutex_() {}
 
 ExecutorServicePtr ExecutorServiceProvider::get() {
     Lock lock(mutex_);
@@ -97,5 +90,4 @@ void ExecutorServiceProvider::close() {
         it->reset();
     }
 }
-
 }
diff --git a/pulsar-client-cpp/lib/ExecutorService.h b/pulsar-client-cpp/lib/ExecutorService.h
index 2bce04665..44f3fdb5e 100644
--- a/pulsar-client-cpp/lib/ExecutorService.h
+++ b/pulsar-client-cpp/lib/ExecutorService.h
@@ -30,12 +30,13 @@
 
 namespace pulsar {
 typedef boost::shared_ptr<boost::asio::ip::tcp::socket> SocketPtr;
-typedef boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket&> > TlsSocketPtr;
+typedef boost::shared_ptr<boost::asio::ssl::stream<boost::asio::ip::tcp::socket &> > TlsSocketPtr;
 typedef boost::shared_ptr<boost::asio::ip::tcp::resolver> TcpResolverPtr;
 typedef boost::shared_ptr<boost::asio::deadline_timer> DeadlineTimerPtr;
 class ExecutorService : private boost::noncopyable {
- friend class ClientConnection;
- public:
+    friend class ClientConnection;
+
+   public:
     ExecutorService();
     ~ExecutorService();
 
@@ -45,8 +46,8 @@ class ExecutorService : private boost::noncopyable {
     DeadlineTimerPtr createDeadlineTimer();
     void postWork(boost::function<void(void)> task);
     void close();
- private:
 
+   private:
     /*
      *  only called once and within lock so no need to worry about thread-safety
      */
@@ -75,14 +76,14 @@ class ExecutorService : private boost::noncopyable {
 typedef boost::shared_ptr<ExecutorService> ExecutorServicePtr;
 
 class ExecutorServiceProvider {
- public:
+   public:
     explicit ExecutorServiceProvider(int nthreads);
 
     ExecutorServicePtr get();
 
     void close();
 
- private:
+   private:
     typedef std::vector<ExecutorServicePtr> ExecutorList;
     ExecutorList executors_;
     int executorIdx_;
@@ -91,9 +92,8 @@ class ExecutorServiceProvider {
 };
 
 typedef boost::shared_ptr<ExecutorServiceProvider> ExecutorServiceProviderPtr;
-
 }
 
 #pragma GCC visibility pop
 
-#endif //_PULSAR_EXECUTOR_SERVICE_HEADER_
+#endif  //_PULSAR_EXECUTOR_SERVICE_HEADER_
diff --git a/pulsar-client-cpp/lib/Future.h b/pulsar-client-cpp/lib/Future.h
index 7992275e3..aab83a4f0 100644
--- a/pulsar-client-cpp/lib/Future.h
+++ b/pulsar-client-cpp/lib/Future.h
@@ -33,7 +33,7 @@ typedef boost::unique_lock<boost::mutex> Lock;
 
 namespace pulsar {
 
-template<typename Result, typename Type>
+template <typename Result, typename Type>
 struct InternalState {
     boost::mutex mutex;
     boost::condition_variable condition;
@@ -44,9 +44,9 @@ struct InternalState {
     std::list<typename boost::function<void(Result, const Type&)> > listeners;
 };
 
-template<typename Result, typename Type>
+template <typename Result, typename Type>
 class Future {
- public:
+   public:
     typedef boost::function<void(Result, const Type&)> ListenerCallback;
 
     Future& addListener(ListenerCallback callback) {
@@ -78,24 +78,20 @@ class Future {
         return state->result;
     }
 
- private:
+   private:
     typedef boost::shared_ptr<InternalState<Result, Type> > InternalStatePtr;
-    Future(InternalStatePtr state)
-            : state_(state) {
-    }
+    Future(InternalStatePtr state) : state_(state) {}
 
     boost::shared_ptr<InternalState<Result, Type> > state_;
 
-    template<typename U, typename V>
+    template <typename U, typename V>
     friend class Promise;
 };
 
-template<typename Result, typename Type>
+template <typename Result, typename Type>
 class Promise {
- public:
-    Promise()
-            : state_(boost::make_shared<InternalState<Result, Type> >()) {
-    }
+   public:
+    Promise() : state_(boost::make_shared<InternalState<Result, Type> >()) {}
 
     bool setValue(const Type& value) {
         InternalState<Result, Type>* state = state_.get();
@@ -148,17 +144,14 @@ class Promise {
         return state->complete;
     }
 
-    Future<Result, Type> getFuture() const {
-        return Future<Result, Type>(state_);
-    }
+    Future<Result, Type> getFuture() const { return Future<Result, Type>(state_); }
 
- private:
+   private:
     typedef boost::function<void(Result, const Type&)> ListenerCallback;
     boost::shared_ptr<InternalState<Result, Type> > state_;
 };
 
-class Void {
-};
+class Void {};
 
 } /* namespace pulsar */
 
diff --git a/pulsar-client-cpp/lib/HTTPLookupService.cc b/pulsar-client-cpp/lib/HTTPLookupService.cc
index c8536bd34..2ce86fbb0 100644
--- a/pulsar-client-cpp/lib/HTTPLookupService.cc
+++ b/pulsar-client-cpp/lib/HTTPLookupService.cc
@@ -21,196 +21,203 @@
 DECLARE_LOG_OBJECT()
 
 namespace pulsar {
-    const static std::string V2_PATH = "/lookup/v2/destination/";
-    const static std::string PARTITION_PATH = "/admin/persistent/";
-    const static int MAX_HTTP_REDIRECTS = 20;
-    const static std::string PARTITION_METHOD_NAME = "partitions";
-    const static int NUMBER_OF_LOOKUP_THREADS = 1;
+const static std::string V2_PATH = "/lookup/v2/destination/";
+const static std::string PARTITION_PATH = "/admin/persistent/";
+const static int MAX_HTTP_REDIRECTS = 20;
+const static std::string PARTITION_METHOD_NAME = "partitions";
+const static int NUMBER_OF_LOOKUP_THREADS = 1;
 
-    HTTPLookupService::CurlInitializer HTTPLookupService::curlInitializer;
+HTTPLookupService::CurlInitializer HTTPLookupService::curlInitializer;
 
-    HTTPLookupService::HTTPLookupService(const std::string &lookupUrl,
-            const ClientConfiguration &clientConfiguration,
-            const AuthenticationPtr &authData)
+HTTPLookupService::HTTPLookupService(const std::string &lookupUrl,
+                                     const ClientConfiguration &clientConfiguration,
+                                     const AuthenticationPtr &authData)
     : executorProvider_(boost::make_shared<ExecutorServiceProvider>(NUMBER_OF_LOOKUP_THREADS)),
-    authenticationPtr_(authData),
-    lookupTimeoutInSeconds_(clientConfiguration.getOperationTimeoutSeconds()) {
-        if (lookupUrl[lookupUrl.length() - 1] == '/') {
-            // Remove trailing '/'
-            adminUrl_ = lookupUrl.substr(0, lookupUrl.length() - 1);
-        } else {
-            adminUrl_ = lookupUrl;
-        }
+      authenticationPtr_(authData),
+      lookupTimeoutInSeconds_(clientConfiguration.getOperationTimeoutSeconds()) {
+    if (lookupUrl[lookupUrl.length() - 1] == '/') {
+        // Remove trailing '/'
+        adminUrl_ = lookupUrl.substr(0, lookupUrl.length() - 1);
+    } else {
+        adminUrl_ = lookupUrl;
     }
+}
 
-    Future<Result, LookupDataResultPtr> HTTPLookupService::lookupAsync(const std::string &destinationName) {
-        LookupPromise promise;
-        boost::shared_ptr<DestinationName> dn = DestinationName::get(destinationName);
-        if (!dn) {
-            LOG_ERROR("Unable to parse destination - " << destinationName);
-            promise.setFailed(ResultInvalidTopicName);
-            return promise.getFuture();
-        }
-
-        std::stringstream completeUrlStream;
-        completeUrlStream << adminUrl_ << V2_PATH << "persistent/" << dn->getProperty() << '/' << dn->getCluster()
-        << '/' << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName();
-        executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(), promise, completeUrlStream.str(), Lookup));
+Future<Result, LookupDataResultPtr> HTTPLookupService::lookupAsync(const std::string &destinationName) {
+    LookupPromise promise;
+    boost::shared_ptr<DestinationName> dn = DestinationName::get(destinationName);
+    if (!dn) {
+        LOG_ERROR("Unable to parse destination - " << destinationName);
+        promise.setFailed(ResultInvalidTopicName);
         return promise.getFuture();
     }
 
-    Future<Result, LookupDataResultPtr> HTTPLookupService::getPartitionMetadataAsync(const DestinationNamePtr &dn) {
-        LookupPromise promise;
-        std::stringstream completeUrlStream;
-        completeUrlStream << adminUrl_ << PARTITION_PATH << dn->getProperty() << '/' << dn->getCluster()
-        << '/' << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName() << '/'
-        << PARTITION_METHOD_NAME;
-        executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(), promise, completeUrlStream.str(), PartitionMetaData));
-        return promise.getFuture();
-    }
+    std::stringstream completeUrlStream;
+    completeUrlStream << adminUrl_ << V2_PATH << "persistent/" << dn->getProperty() << '/' << dn->getCluster()
+                      << '/' << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName();
+    executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(),
+                                                   promise, completeUrlStream.str(), Lookup));
+    return promise.getFuture();
+}
+
+Future<Result, LookupDataResultPtr> HTTPLookupService::getPartitionMetadataAsync(
+    const DestinationNamePtr &dn) {
+    LookupPromise promise;
+    std::stringstream completeUrlStream;
+    completeUrlStream << adminUrl_ << PARTITION_PATH << dn->getProperty() << '/' << dn->getCluster() << '/'
+                      << dn->getNamespacePortion() << '/' << dn->getEncodedLocalName() << '/'
+                      << PARTITION_METHOD_NAME;
+    executorProvider_->get()->postWork(boost::bind(&HTTPLookupService::sendHTTPRequest, shared_from_this(),
+                                                   promise, completeUrlStream.str(), PartitionMetaData));
+    return promise.getFuture();
+}
 
-    static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb, void *responseDataPtr) {
-        ((std::string*)responseDataPtr)->append((char*)contents, size * nmemb);
-        return size * nmemb;
+static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb, void *responseDataPtr) {
+    ((std::string *)responseDataPtr)->append((char *)contents, size * nmemb);
+    return size * nmemb;
+}
+
+void HTTPLookupService::sendHTTPRequest(LookupPromise promise, const std::string completeUrl,
+                                        RequestType requestType) {
+    CURL *handle;
+    CURLcode res;
+    std::string responseData;
+    std::string version = std::string("Pulsar-CPP-v") + _PULSAR_VERSION_;
+    handle = curl_easy_init();
+
+    if (!handle) {
+        LOG_ERROR("Unable to curl_easy_init for url " << completeUrl);
+        promise.setFailed(ResultLookupError);
+        // No curl_easy_cleanup required since handle not initialized
+        return;
+    }
+    // set URL
+    curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
+
+    // Write callback
+    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
+    curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
+
+    // New connection is made for each call
+    curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
+    curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
+
+    // Skipping signal handling - results in timeouts not honored during the DNS lookup
+    curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
+
+    // Timer
+    curl_easy_setopt(handle, CURLOPT_TIMEOUT, lookupTimeoutInSeconds_);
+
+    // Set User Agent
+    curl_easy_setopt(handle, CURLOPT_USERAGENT, version.c_str());
+
+    // Redirects
+    curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
+    curl_easy_setopt(handle, CURLOPT_MAXREDIRS, MAX_HTTP_REDIRECTS);
+
+    // Fail if HTTP return code >=400
+    curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
+
+    // Authorization data
+    AuthenticationDataPtr authDataContent;
+    Result authResult = authenticationPtr_->getAuthData(authDataContent);
+    if (authResult != ResultOk) {
+        LOG_ERROR(
+            "All Authentication methods should have AuthenticationData and return true on getAuthData for "
+            "url "
+            << completeUrl);
+        promise.setFailed(authResult);
+        curl_easy_cleanup(handle);
+        return;
+    }
+    struct curl_slist *list = NULL;
+    if (authDataContent->hasDataForHttp()) {
+        list = curl_slist_append(list, authDataContent->getHttpHeaders().c_str());
     }
+    curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
 
-    void HTTPLookupService::sendHTTPRequest(LookupPromise promise, const std::string completeUrl,
-            RequestType requestType) {
-        CURL *handle;
-        CURLcode res;
-        std::string responseData;
-        std::string version = std::string("Pulsar-CPP-v") + _PULSAR_VERSION_;
-        handle = curl_easy_init();
+    LOG_INFO("Curl Lookup Request sent for" << completeUrl);
 
-        if(!handle) {
-            LOG_ERROR("Unable to curl_easy_init for url " << completeUrl);
-            promise.setFailed(ResultLookupError);
-            // No curl_easy_cleanup required since handle not initialized
-            return;
-        }
-        // set URL
-        curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
-
-        // Write callback
-        curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
-        curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
-
-        // New connection is made for each call
-        curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
-        curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
-
-        // Skipping signal handling - results in timeouts not honored during the DNS lookup
-        curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
-
-        // Timer
-        curl_easy_setopt(handle, CURLOPT_TIMEOUT, lookupTimeoutInSeconds_);
-
-        // Set User Agent 
-        curl_easy_setopt(handle, CURLOPT_USERAGENT, version.c_str());
-
-        // Redirects
-        curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
-        curl_easy_setopt(handle, CURLOPT_MAXREDIRS, MAX_HTTP_REDIRECTS);
-
-        // Fail if HTTP return code >=400
-        curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
-
-        // Authorization data
-        AuthenticationDataPtr authDataContent;
-        Result authResult = authenticationPtr_->getAuthData(authDataContent);
-        if (authResult != ResultOk) {
-            LOG_ERROR("All Authentication methods should have AuthenticationData and return true on getAuthData for url " << completeUrl);
-            promise.setFailed(authResult);
-            curl_easy_cleanup(handle);
-            return;
-        }
-        struct curl_slist *list = NULL;
-        if (authDataContent->hasDataForHttp()) {
-            list = curl_slist_append(list, authDataContent->getHttpHeaders().c_str());
-        }
-        curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
-
-        LOG_INFO("Curl Lookup Request sent for" << completeUrl);
-
-        // Make get call to server
-        res = curl_easy_perform(handle);
-
-        // Free header list
-        curl_slist_free_all(list);
-
-        switch(res) {
-            case CURLE_OK:
-                long response_code;
-                curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response_code);
-                LOG_INFO("Response received for url " << completeUrl << " code " << response_code);
-                if (response_code == 200) {
-                    promise.setValue((requestType == PartitionMetaData) ? parsePartitionData(responseData) : parseLookupData(responseData));
-                } else {
-                    promise.setFailed(ResultLookupError);
-                }
-                break;
-            case CURLE_COULDNT_CONNECT:
-            case CURLE_COULDNT_RESOLVE_PROXY:
-            case CURLE_COULDNT_RESOLVE_HOST:
-            case CURLE_HTTP_RETURNED_ERROR:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
-                promise.setFailed(ResultConnectError);
-                break;
-            case CURLE_READ_ERROR:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
-                promise.setFailed(ResultReadError);
-                break;
-            case CURLE_OPERATION_TIMEDOUT:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
-                promise.setFailed(ResultTimeout);
-                break;
-            default:
-                LOG_ERROR("Response failed for url "<<completeUrl << ". Error Code "<<res);
+    // Make get call to server
+    res = curl_easy_perform(handle);
+
+    // Free header list
+    curl_slist_free_all(list);
+
+    switch (res) {
+        case CURLE_OK:
+            long response_code;
+            curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response_code);
+            LOG_INFO("Response received for url " << completeUrl << " code " << response_code);
+            if (response_code == 200) {
+                promise.setValue((requestType == PartitionMetaData) ? parsePartitionData(responseData)
+                                                                    : parseLookupData(responseData));
+            } else {
                 promise.setFailed(ResultLookupError);
-                break;
-        }
-        curl_easy_cleanup(handle);
+            }
+            break;
+        case CURLE_COULDNT_CONNECT:
+        case CURLE_COULDNT_RESOLVE_PROXY:
+        case CURLE_COULDNT_RESOLVE_HOST:
+        case CURLE_HTTP_RETURNED_ERROR:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultConnectError);
+            break;
+        case CURLE_READ_ERROR:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultReadError);
+            break;
+        case CURLE_OPERATION_TIMEDOUT:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultTimeout);
+            break;
+        default:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            promise.setFailed(ResultLookupError);
+            break;
     }
+    curl_easy_cleanup(handle);
+}
 
-    LookupDataResultPtr HTTPLookupService::parsePartitionData(const std::string &json) {
-        Json::Value root;
-        Json::Reader reader;
-        if (!reader.parse(json, root, false)) {
-            LOG_ERROR("Failed to parse json of Partition Metadata: " << reader.getFormatedErrorMessages()
-                    << "\nInput Json = " << json);
-            return LookupDataResultPtr();
-        }
-        LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
-        lookupDataResultPtr->setPartitions(root.get("partitions", 0).asInt());
-        LOG_INFO("parsePartitionData = "<<*lookupDataResultPtr);
-        return lookupDataResultPtr;
+LookupDataResultPtr HTTPLookupService::parsePartitionData(const std::string &json) {
+    Json::Value root;
+    Json::Reader reader;
+    if (!reader.parse(json, root, false)) {
+        LOG_ERROR("Failed to parse json of Partition Metadata: " << reader.getFormatedErrorMessages()
+                                                                 << "\nInput Json = " << json);
+        return LookupDataResultPtr();
     }
+    LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
+    lookupDataResultPtr->setPartitions(root.get("partitions", 0).asInt());
+    LOG_INFO("parsePartitionData = " << *lookupDataResultPtr);
+    return lookupDataResultPtr;
+}
 
-    LookupDataResultPtr HTTPLookupService::parseLookupData(const std::string &json) {
-        Json::Value root;
-        Json::Reader reader;
-        if (!reader.parse(json, root, false)) {
-            LOG_ERROR("Failed to parse json : " << reader.getFormatedErrorMessages()
-                    << "\nInput Json = " << json);
-            return LookupDataResultPtr();
-        }
-        const std::string defaultNotFoundString = "Url Not found";
-        const std::string brokerUrl = root.get("brokerUrl", defaultNotFoundString).asString();
-        if (brokerUrl == defaultNotFoundString) {
-            LOG_ERROR("malformed json! - brokerUrl not present" << json);
-            return LookupDataResultPtr();
-        }
-
-        const std::string brokerUrlSsl = root.get("brokerUrlSsl", defaultNotFoundString).asString();
-        if (brokerUrlSsl == defaultNotFoundString) {
-            LOG_ERROR("malformed json! - brokerUrlSsl not present" << json);
-            return LookupDataResultPtr();
-        }
-
-        LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
-        lookupDataResultPtr->setBrokerUrl(brokerUrl);
-        lookupDataResultPtr->setBrokerUrlSsl(brokerUrlSsl);
-        LOG_INFO("parseLookupData = "<<*lookupDataResultPtr);
-        return lookupDataResultPtr;
+LookupDataResultPtr HTTPLookupService::parseLookupData(const std::string &json) {
+    Json::Value root;
+    Json::Reader reader;
+    if (!reader.parse(json, root, false)) {
+        LOG_ERROR("Failed to parse json : " << reader.getFormatedErrorMessages()
+                                            << "\nInput Json = " << json);
+        return LookupDataResultPtr();
     }
+    const std::string defaultNotFoundString = "Url Not found";
+    const std::string brokerUrl = root.get("brokerUrl", defaultNotFoundString).asString();
+    if (brokerUrl == defaultNotFoundString) {
+        LOG_ERROR("malformed json! - brokerUrl not present" << json);
+        return LookupDataResultPtr();
+    }
+
+    const std::string brokerUrlSsl = root.get("brokerUrlSsl", defaultNotFoundString).asString();
+    if (brokerUrlSsl == defaultNotFoundString) {
+        LOG_ERROR("malformed json! - brokerUrlSsl not present" << json);
+        return LookupDataResultPtr();
+    }
+
+    LookupDataResultPtr lookupDataResultPtr = boost::make_shared<LookupDataResult>();
+    lookupDataResultPtr->setBrokerUrl(brokerUrl);
+    lookupDataResultPtr->setBrokerUrlSsl(brokerUrlSsl);
+    LOG_INFO("parseLookupData = " << *lookupDataResultPtr);
+    return lookupDataResultPtr;
+}
 }
diff --git a/pulsar-client-cpp/lib/HTTPLookupService.h b/pulsar-client-cpp/lib/HTTPLookupService.h
index 10bee0c6a..2feb8c6c2 100644
--- a/pulsar-client-cpp/lib/HTTPLookupService.h
+++ b/pulsar-client-cpp/lib/HTTPLookupService.h
@@ -29,36 +29,38 @@
 #include <lib/Version.h>
 
 namespace pulsar {
-    class HTTPLookupService : public LookupService, public boost::enable_shared_from_this<HTTPLookupService> {
-        class CurlInitializer {
-         public:
-            CurlInitializer() {
-                // Once per application - https://curl.haxx.se/mail/lib-2015-11/0052.html
-                curl_global_init (CURL_GLOBAL_ALL);
-            }
-            ~CurlInitializer() {
-                curl_global_cleanup();
-            }
-        };
-        static CurlInitializer curlInitializer;
-        enum RequestType {Lookup, PartitionMetaData};
-        typedef Promise<Result, LookupDataResultPtr> LookupPromise;
-        ExecutorServiceProviderPtr executorProvider_;
-        std::string adminUrl_;
-        AuthenticationPtr authenticationPtr_;
-        int lookupTimeoutInSeconds_;
+class HTTPLookupService : public LookupService, public boost::enable_shared_from_this<HTTPLookupService> {
+    class CurlInitializer {
+       public:
+        CurlInitializer() {
+            // Once per application - https://curl.haxx.se/mail/lib-2015-11/0052.html
+            curl_global_init(CURL_GLOBAL_ALL);
+        }
+        ~CurlInitializer() { curl_global_cleanup(); }
+    };
+    static CurlInitializer curlInitializer;
+    enum RequestType
+    {
+        Lookup,
+        PartitionMetaData
+    };
+    typedef Promise<Result, LookupDataResultPtr> LookupPromise;
+    ExecutorServiceProviderPtr executorProvider_;
+    std::string adminUrl_;
+    AuthenticationPtr authenticationPtr_;
+    int lookupTimeoutInSeconds_;
 
-        static LookupDataResultPtr parsePartitionData(const std::string&);
-        static LookupDataResultPtr parseLookupData(const std::string&);
-        void sendHTTPRequest(LookupPromise, const std::string, RequestType);
-     public:
-        HTTPLookupService(const std::string&, const ClientConfiguration&, const AuthenticationPtr&);
+    static LookupDataResultPtr parsePartitionData(const std::string&);
+    static LookupDataResultPtr parseLookupData(const std::string&);
+    void sendHTTPRequest(LookupPromise, const std::string, RequestType);
 
-        Future<Result, LookupDataResultPtr> lookupAsync(const std::string&);
+   public:
+    HTTPLookupService(const std::string&, const ClientConfiguration&, const AuthenticationPtr&);
 
-        Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr&);
-    };
+    Future<Result, LookupDataResultPtr> lookupAsync(const std::string&);
 
+    Future<Result, LookupDataResultPtr> getPartitionMetadataAsync(const DestinationNamePtr&);
+};
 }
 
-#endif //PULSAR_CPP_HTTPLOOKUPSERVICE_H
+#endif  // PULSAR_CPP_HTTPLOOKUPSERVICE_H
diff --git a/pulsar-client-cpp/lib/HandlerBase.cc b/pulsar-client-cpp/lib/HandlerBase.cc
index a0a068647..071a8d4d0 100644
--- a/pulsar-client-cpp/lib/HandlerBase.cc
+++ b/pulsar-client-cpp/lib/HandlerBase.cc
@@ -28,24 +28,19 @@ DECLARE_LOG_OBJECT()
 namespace pulsar {
 
 HandlerBase::HandlerBase(const ClientImplPtr& client, const std::string& topic, const Backoff& backoff)
-        : client_(client),
-          topic_(topic),
-          connection_(),
-          mutex_(),
-          creationTimestamp_(now()),
-          operationTimeut_(seconds(client->conf().getOperationTimeoutSeconds())),
-          state_(Pending),
-          backoff_(backoff),
-          timer_(client->getIOExecutorProvider()->get()->createDeadlineTimer()) {
-}
+    : client_(client),
+      topic_(topic),
+      connection_(),
+      mutex_(),
+      creationTimestamp_(now()),
+      operationTimeut_(seconds(client->conf().getOperationTimeoutSeconds())),
+      state_(Pending),
+      backoff_(backoff),
+      timer_(client->getIOExecutorProvider()->get()->createDeadlineTimer()) {}
 
-HandlerBase::~HandlerBase() {
-    timer_->cancel();
-}
+HandlerBase::~HandlerBase() { timer_->cancel(); }
 
-void HandlerBase::start() {
-    grabCnx();
-}
+void HandlerBase::start() { grabCnx(); }
 
 void HandlerBase::grabCnx() {
     Lock lock(mutex_);
@@ -58,8 +53,7 @@ void HandlerBase::grabCnx() {
     LOG_INFO(getName() << "Getting connection from pool");
     ClientImplPtr client = client_.lock();
     Future<Result, ClientConnectionWeakPtr> future = client->getConnection(topic_);
-    future.addListener(
-            boost::bind(&HandlerBase::handleNewConnection, _1, _2, get_weak_from_this()));
+    future.addListener(boost::bind(&HandlerBase::handleNewConnection, _1, _2, get_weak_from_this()));
 }
 
 void HandlerBase::handleNewConnection(Result result, ClientConnectionWeakPtr connection,
@@ -96,8 +90,8 @@ void HandlerBase::handleDisconnection(Result result, ClientConnectionWeakPtr con
 
     ClientConnectionPtr currentConnection = handler->connection_.lock();
     if (currentConnection && connection.lock().get() != currentConnection.get()) {
-        LOG_WARN(
-                handler->getName() << "Ignoring connection closed since we are already attached to a newer connection");
+        LOG_WARN(handler->getName()
+                 << "Ignoring connection closed since we are already attached to a newer connection");
         return;
     }
 
@@ -112,8 +106,8 @@ void HandlerBase::handleDisconnection(Result result, ClientConnectionWeakPtr con
         case Closing:
         case Closed:
         case Failed:
-            LOG_DEBUG(handler->getName() <<
-                    "Ignoring connection closed event since the handler is not used anymore");
+            LOG_DEBUG(handler->getName()
+                      << "Ignoring connection closed event since the handler is not used anymore");
             break;
     }
 }
@@ -131,27 +125,25 @@ void HandlerBase::scheduleReconnection(HandlerBasePtr handler) {
     if (handler->state_ == Pending || handler->state_ == Ready) {
         TimeDuration delay = handler->backoff_.next();
 
-        LOG_INFO(
-                handler->getName() << "Schedule reconnection in " << (delay.total_milliseconds() / 1000.0) << " s");
+        LOG_INFO(handler->getName() << "Schedule reconnection in " << (delay.total_milliseconds() / 1000.0)
+                                    << " s");
         handler->timer_->expires_from_now(delay);
-        //passing shared_ptr here since time_ will get destroyed, so tasks will be cancelled
-        //so we will not run into the case where grabCnx is invoked on out of scope handler
+        // passing shared_ptr here since time_ will get destroyed, so tasks will be cancelled
+        // so we will not run into the case where grabCnx is invoked on out of scope handler
         handler->timer_->async_wait(boost::bind(&HandlerBase::handleTimeout, _1, handler));
     }
 }
 
 void HandlerBase::handleTimeout(const boost::system::error_code& ec, HandlerBasePtr handler) {
     if (ec) {
-        LOG_DEBUG(handler->getName() << "Ignoring timer cancelled event, code[" << ec <<"]");
+        LOG_DEBUG(handler->getName() << "Ignoring timer cancelled event, code[" << ec << "]");
         return;
     } else {
         handler->grabCnx();
     }
 }
 
-ptime now() {
-    return microsec_clock::universal_time();
-}
+ptime now() { return microsec_clock::universal_time(); }
 
 int64_t currentTimeMillis() {
     static ptime time_t_epoch(boost::gregorian::date(1970, 1, 1));
@@ -159,5 +151,4 @@ int64_t currentTimeMillis() {
     time_duration diff = now() - time_t_epoch;
     return diff.total_milliseconds();
 }
-
 }
diff --git a/pulsar-client-cpp/lib/HandlerBase.h b/pulsar-client-cpp/lib/HandlerBase.h
index 70e2c6262..d4fef5a4a 100644
--- a/pulsar-client-cpp/lib/HandlerBase.h
+++ b/pulsar-client-cpp/lib/HandlerBase.h
@@ -40,8 +40,7 @@ typedef boost::weak_ptr<HandlerBase> HandlerBaseWeakPtr;
 typedef boost::shared_ptr<HandlerBase> HandlerBasePtr;
 
 class HandlerBase {
-
- public:
+   public:
     HandlerBase(const ClientImplPtr&, const std::string&, const Backoff&);
 
     virtual ~HandlerBase();
@@ -52,11 +51,9 @@ class HandlerBase {
      * get method for derived class to access weak ptr to connection so that they
      * have to check if they can get a shared_ptr out of it or not
      */
-    ClientConnectionWeakPtr getCnx() {
-        return connection_;
-    }
+    ClientConnectionWeakPtr getCnx() { return connection_; }
 
- protected:
+   protected:
     /*
      * tries reconnection and sets connection_ to valid object
      */
@@ -83,15 +80,13 @@ class HandlerBase {
 
     virtual const std::string& getName() const = 0;
 
- private:
-    static void handleNewConnection(Result result, ClientConnectionWeakPtr connection,
-                                    HandlerBaseWeakPtr wp);
-    static void handleDisconnection(Result result, ClientConnectionWeakPtr connection,
-                                    HandlerBaseWeakPtr wp);
+   private:
+    static void handleNewConnection(Result result, ClientConnectionWeakPtr connection, HandlerBaseWeakPtr wp);
+    static void handleDisconnection(Result result, ClientConnectionWeakPtr connection, HandlerBaseWeakPtr wp);
 
     static void handleTimeout(const boost::system::error_code& ec, HandlerBasePtr handler);
 
- protected:
+   protected:
     ClientImplWeakPtr client_;
     const std::string topic_;
     ClientConnectionWeakPtr connection_;
@@ -101,7 +96,8 @@ class HandlerBase {
     const TimeDuration operationTimeut_;
     typedef boost::unique_lock<boost::mutex> Lock;
 
-    enum State {
+    enum State
+    {
         Pending,
         Ready,
         Closing,
@@ -112,7 +108,7 @@ class HandlerBase {
     State state_;
     Backoff backoff_;
 
- private:
+   private:
     DeadlineTimerPtr timer_;
     friend class ClientConnection;
     friend class PulsarFriend;
diff --git a/pulsar-client-cpp/lib/Latch.cc b/pulsar-client-cpp/lib/Latch.cc
index f183d1ad2..bc5b16e42 100644
--- a/pulsar-client-cpp/lib/Latch.cc
+++ b/pulsar-client-cpp/lib/Latch.cc
@@ -25,19 +25,12 @@ namespace pulsar {
 struct CountIsZero {
     const int& count_;
 
-    CountIsZero(const int& count)
-            : count_(count) {
-    }
+    CountIsZero(const int& count) : count_(count) {}
 
-    bool operator()() const {
-        return count_ == 0;
-    }
+    bool operator()() const { return count_ == 0; }
 };
 
-Latch::Latch(int count)
-        : state_(boost::make_shared<InternalState>()) {
-    state_->count = count;
-}
+Latch::Latch(int count) : state_(boost::make_shared<InternalState>()) { state_->count = count; }
 
 void Latch::countdown() {
     Lock lock(state_->mutex);
@@ -53,7 +46,6 @@ int Latch::getCount() {
     Lock lock(state_->mutex);
 
     return state_->count;
-
 }
 
 void Latch::wait() {
diff --git a/pulsar-client-cpp/lib/Latch.h b/pulsar-client-cpp/lib/Latch.h
index b80a1226a..9665a19e3 100644
--- a/pulsar-client-cpp/lib/Latch.h
+++ b/pulsar-client-cpp/lib/Latch.h
@@ -28,7 +28,7 @@
 namespace pulsar {
 
 class Latch {
- public:
+   public:
     Latch(int count);
 
     void countdown();
@@ -39,7 +39,7 @@ class Latch {
 
     int getCount();
 
- private:
+   private:
     struct InternalState {
         boost::mutex mutex;
         boost::condition_variable condition;
diff --git a/pulsar-client-cpp/lib/LogUtils.cc b/pulsar-client-cpp/lib/LogUtils.cc
index 6500ff7c9..70507d94f 100644
--- a/pulsar-client-cpp/lib/LogUtils.cc
+++ b/pulsar-client-cpp/lib/LogUtils.cc
@@ -34,7 +34,7 @@ void LogUtils::init(const std::string& logfilePath) {
                 LogManager::getLoggerRepository()->setConfigured(true);
                 LoggerPtr root = Logger::getRootLogger();
                 static const LogString TTCC_CONVERSION_PATTERN(
-                        LOG4CXX_STR("%d{HH:mm:ss.SSS} [%t] %-5p %l - %m%n"));
+                    LOG4CXX_STR("%d{HH:mm:ss.SSS} [%t] %-5p %l - %m%n"));
                 LayoutPtr layout(new PatternLayout(TTCC_CONVERSION_PATTERN));
                 AppenderPtr appender(new ConsoleAppender(layout));
                 root->setLevel(log4cxx::Level::getInfo());
@@ -44,10 +44,9 @@ void LogUtils::init(const std::string& logfilePath) {
             log4cxx::PropertyConfigurator::configure(logfilePath);
         }
     } catch (const std::exception& e) {
-        std::cerr << "exception caught while configuring log4cpp via '" << logfilePath << "': "
-                  << e.what() << std::endl;
-    } catch (...) {
-        std::cerr << "unknown exception while configuring log4cpp via '" << logfilePath << "'."
+        std::cerr << "exception caught while configuring log4cpp via '" << logfilePath << "': " << e.what()
                   << std::endl;
+    } catch (...) {
+        std::cerr << "unknown exception while configuring log4cpp via '" << logfilePath << "'." << std::endl;
     }
 }
diff --git a/pulsar-client-cpp/lib/LogUtils.h b/pulsar-client-cpp/lib/LogUtils.h
index 3ca59fc30..6371efed0 100644
--- a/pulsar-client-cpp/lib/LogUtils.h
+++ b/pulsar-client-cpp/lib/LogUtils.h
@@ -23,47 +23,67 @@
 #include <log4cxx/logger.h>
 #include <string>
 
-#define DECLARE_LOG_OBJECT()                                \
-    static log4cxx::LoggerPtr& logger()                     \
-    {                                                       \
-        static boost::thread_specific_ptr<log4cxx::LoggerPtr> threadSpecificLogPtr; \
-        log4cxx::LoggerPtr* ptr = threadSpecificLogPtr.get(); \
-        if (!ptr) { \
-            threadSpecificLogPtr.reset(new log4cxx::LoggerPtr(log4cxx::Logger::getLogger(LOG_CATEGORY_NAME __FILE__)));\
-            ptr = threadSpecificLogPtr.get(); \
-        } \
-        return *ptr;                                      \
+#define DECLARE_LOG_OBJECT()                                                                     \
+    static log4cxx::LoggerPtr& logger() {                                                        \
+        static boost::thread_specific_ptr<log4cxx::LoggerPtr> threadSpecificLogPtr;              \
+        log4cxx::LoggerPtr* ptr = threadSpecificLogPtr.get();                                    \
+        if (!ptr) {                                                                              \
+            threadSpecificLogPtr.reset(                                                          \
+                new log4cxx::LoggerPtr(log4cxx::Logger::getLogger(LOG_CATEGORY_NAME __FILE__))); \
+            ptr = threadSpecificLogPtr.get();                                                    \
+        }                                                                                        \
+        return *ptr;                                                                             \
     }
 
-#define LOG_DEBUG(message) { \
-        if (LOG4CXX_UNLIKELY(logger()->isDebugEnabled())) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getDebug(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_DEBUG(message)                                                                                \
+    {                                                                                                     \
+        if (LOG4CXX_UNLIKELY(logger()->isDebugEnabled())) {                                               \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                       \
+            logger()->forcedLog(::log4cxx::Level::getDebug(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                        \
+        }                                                                                                 \
+    }
 
-#define LOG_INFO(message) { \
-        if (logger()->isInfoEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getInfo(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_INFO(message)                                                                                \
+    {                                                                                                    \
+        if (logger()->isInfoEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                      \
+            logger()->forcedLog(::log4cxx::Level::getInfo(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                       \
+        }                                                                                                \
+    }
 
-#define LOG_WARN(message) { \
-        if (logger()->isWarnEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getWarn(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_WARN(message)                                                                                \
+    {                                                                                                    \
+        if (logger()->isWarnEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                      \
+            logger()->forcedLog(::log4cxx::Level::getWarn(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                       \
+        }                                                                                                \
+    }
 
-#define LOG_ERROR(message) { \
-        if (logger()->isErrorEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getError(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_ERROR(message)                                                                                \
+    {                                                                                                     \
+        if (logger()->isErrorEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                       \
+            logger()->forcedLog(::log4cxx::Level::getError(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                        \
+        }                                                                                                 \
+    }
 
-#define LOG_FATAL(message) { \
-        if (logger()->isFatalEnabled()) {\
-           ::log4cxx::helpers::MessageBuffer oss_; \
-           logger()->forcedLog(::log4cxx::Level::getFatal(), oss_.str(((std::ostream&)oss_) << message), LOG4CXX_LOCATION); }}
+#define LOG_FATAL(message)                                                                                \
+    {                                                                                                     \
+        if (logger()->isFatalEnabled()) {                                                                 \
+            ::log4cxx::helpers::MessageBuffer oss_;                                                       \
+            logger()->forcedLog(::log4cxx::Level::getFatal(), oss_.str(((std::ostream&)oss_) << message), \
+                                LOG4CXX_LOCATION);                                                        \
+        }                                                                                                 \
+    }
 
 #pragma GCC visibility push(default)
 
 class LogUtils {
- public:
+   public:
     static void init(const std::string& logConfFilePath);
 };
 
diff --git a/pulsar-client-cpp/lib/LookupDataResult.h b/pulsar-client-cpp/lib/LookupDataResult.h
index ed43af977..21cdec879 100644
--- a/pulsar-client-cpp/lib/LookupDataResult.h
+++ b/pulsar-client-cpp/lib/LookupDataResult.h
@@ -29,45 +29,25 @@ typedef Promise<Result, LookupDataResultPtr> LookupDataResultPromise;
 typedef boost::shared_ptr<LookupDataResultPromise> LookupDataResultPromisePtr;
 
 class LookupDataResult {
- public:
-    void setBrokerUrl(const std::string& brokerUrl) {
-        brokerUrl_ = brokerUrl;
-    }
-    void setBrokerUrlSsl(const std::string& brokerUrlSsl) {
-        brokerUrlSsl_ = brokerUrlSsl;
-    }
-    std::string getBrokerUrl() {
-        return brokerUrl_;
-    }
-    std::string getBrokerUrlSsl() {
-        return brokerUrlSsl_;
-    }
+   public:
+    void setBrokerUrl(const std::string& brokerUrl) { brokerUrl_ = brokerUrl; }
+    void setBrokerUrlSsl(const std::string& brokerUrlSsl) { brokerUrlSsl_ = brokerUrlSsl; }
+    std::string getBrokerUrl() { return brokerUrl_; }
+    std::string getBrokerUrlSsl() { return brokerUrlSsl_; }
 
-    bool isAuthoritative() const {
-        return authoritative;
-    }
+    bool isAuthoritative() const { return authoritative; }
 
-    void setAuthoritative(bool authoritative) {
-        this->authoritative = authoritative;
-    }
+    void setAuthoritative(bool authoritative) { this->authoritative = authoritative; }
 
-    int getPartitions() const {
-        return partitions;
-    }
+    int getPartitions() const { return partitions; }
 
-    void setPartitions(int partitions) {
-        this->partitions = partitions;
-    }
+    void setPartitions(int partitions) { this->partitions = partitions; }
 
-    bool isRedirect() const {
-        return redirect;
-    }
+    bool isRedirect() const { return redirect; }
 
-    void setRedirect(bool redirect) {
-        this->redirect = redirect;
-    }
+    void setRedirect(bool redirect) { this->redirect = redirect; }
 
- private:
+   private:
     friend inline std::ostream& operator<<(std::ostream& os, const LookupDataResult& b);
     std::string brokerUrl_;
     std::string brokerUrlSsl_;
@@ -77,14 +57,11 @@ class LookupDataResult {
 };
 
 std::ostream& operator<<(std::ostream& os, const LookupDataResult& b) {
-    os << "{ LookupDataResult [brokerUrl_ = " << b.brokerUrl_ << "] [brokerUrlSsl_ = "
-            << b.brokerUrlSsl_ << "] [partitions = "
-            << b.partitions << "] [authoritative = "
-            << b.authoritative << "] [redirect = " << b.redirect
-            << "]";
+    os << "{ LookupDataResult [brokerUrl_ = " << b.brokerUrl_ << "] [brokerUrlSsl_ = " << b.brokerUrlSsl_
+       << "] [partitions = " << b.partitions << "] [authoritative = " << b.authoritative
+       << "] [redirect = " << b.redirect << "]";
     return os;
 }
-
 }
 
-#endif // _PULSAR_LOOKUP_DATA_RESULT_HEADER_
+#endif  // _PULSAR_LOOKUP_DATA_RESULT_HEADER_
diff --git a/pulsar-client-cpp/lib/LookupService.h b/pulsar-client-cpp/lib/LookupService.h
index cbcd72358..f29626717 100644
--- a/pulsar-client-cpp/lib/LookupService.h
+++ b/pulsar-client-cpp/lib/LookupService.h
@@ -27,7 +27,7 @@
 
 namespace pulsar {
 class LookupService {
-public:
+   public:
     /*
      * @param    destinationName - topic name
      *
@@ -44,4 +44,4 @@ class LookupService {
 };
 typedef boost::shared_ptr<LookupService> LookupServicePtr;
 }
-#endif //PULSAR_CPP_LOOKUPSERVICE_H
+#endif  // PULSAR_CPP_LOOKUPSERVICE_H
diff --git a/pulsar-client-cpp/lib/Message.cc b/pulsar-client-cpp/lib/Message.cc
index e814980a2..22d510404 100644
--- a/pulsar-client-cpp/lib/Message.cc
+++ b/pulsar-client-cpp/lib/Message.cc
@@ -36,9 +36,7 @@ namespace pulsar {
 const static std::string emptyString;
 const static BatchMessageId invalidMessageId;
 
-const Message::StringMap& Message::getProperties() const {
-    return impl_->properties();
-}
+const Message::StringMap& Message::getProperties() const { return impl_->properties(); }
 
 bool Message::hasProperty(const std::string& name) const {
     const StringMap& m = impl_->properties();
@@ -54,36 +52,26 @@ const std::string& Message::getProperty(const std::string& name) const {
     }
 }
 
-const void* Message::getData() const {
-    return impl_->payload.data();
-}
+const void* Message::getData() const { return impl_->payload.data(); }
 
-std::size_t Message::getLength() const {
-    return impl_->payload.readableBytes();
-}
+std::size_t Message::getLength() const { return impl_->payload.readableBytes(); }
 
-std::string Message::getDataAsString() const {
-    return std::string((const char*) getData(), getLength());
-}
+std::string Message::getDataAsString() const { return std::string((const char*)getData(), getLength()); }
 
-Message::Message()
-        : impl_() {
-}
+Message::Message() : impl_() {}
 
-Message::Message(MessageImplPtr& impl)
-        : impl_(impl) {
-}
+Message::Message(MessageImplPtr& impl) : impl_(impl) {}
 
-Message::Message(const proto::CommandMessage& msg, proto::MessageMetadata& metadata,
-                 SharedBuffer& payload)
-        : impl_(boost::make_shared<MessageImpl>()) {
+Message::Message(const proto::CommandMessage& msg, proto::MessageMetadata& metadata, SharedBuffer& payload)
+    : impl_(boost::make_shared<MessageImpl>()) {
     impl_->messageId = BatchMessageId(msg.message_id().ledgerid(), msg.message_id().entryid());
     impl_->metadata = metadata;
     impl_->payload = payload;
 }
 
-Message::Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload, proto::SingleMessageMetadata& singleMetadata)
-: impl_(boost::make_shared<MessageImpl>()) {
+Message::Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload,
+                 proto::SingleMessageMetadata& singleMetadata)
+    : impl_(boost::make_shared<MessageImpl>()) {
     impl_->messageId = messageID;
     impl_->metadata = metadata;
     impl_->payload = payload;
@@ -98,8 +86,8 @@ const MessageId& Message::getMessageId() const {
     }
 }
 
-bool Message::hasPartitionKey() const{
-    if(impl_) {
+bool Message::hasPartitionKey() const {
+    if (impl_) {
         return impl_->hasPartitionKey();
     }
     return false;
@@ -112,13 +100,9 @@ const std::string& Message::getPartitionKey() const {
     return impl_->getPartitionKey();
 }
 
-uint64_t Message::getPublishTimestamp() const {
-    return impl_ ? impl_->getPublishTimestamp() : 0ull;
-}
+uint64_t Message::getPublishTimestamp() const { return impl_ ? impl_->getPublishTimestamp() : 0ull; }
 
-uint64_t Message::getEventTimestamp() const {
-    return impl_ ? impl_->getEventTimestamp() : 0ull;
-}
+uint64_t Message::getEventTimestamp() const { return impl_ ? impl_->getEventTimestamp() : 0ull; }
 
 #pragma GCC visibility push(default)
 
@@ -148,13 +132,12 @@ std::ostream& operator<<(std::ostream& s, const Message& msg) {
     assert(msg.impl_.get());
     assert(msg.impl_->metadata.has_sequence_id());
     assert(msg.impl_->metadata.has_publish_time());
-    s << "Message(prod=" << msg.impl_->metadata.producer_name() << ", seq="
-      << msg.impl_->metadata.sequence_id() << ", publish_time="
-      << msg.impl_->metadata.publish_time() << ", payload_size=" << msg.getLength() << ", msg_id="
-      << msg.getMessageId() << ", props=" << msg.getProperties() << ')';
+    s << "Message(prod=" << msg.impl_->metadata.producer_name()
+      << ", seq=" << msg.impl_->metadata.sequence_id()
+      << ", publish_time=" << msg.impl_->metadata.publish_time() << ", payload_size=" << msg.getLength()
+      << ", msg_id=" << msg.getMessageId() << ", props=" << msg.getProperties() << ')';
     return s;
 }
 
 #pragma GCC visibility pop
-
 }
diff --git a/pulsar-client-cpp/lib/MessageBuilder.cc b/pulsar-client-cpp/lib/MessageBuilder.cc
index 5f232e376..497efa2d4 100644
--- a/pulsar-client-cpp/lib/MessageBuilder.cc
+++ b/pulsar-client-cpp/lib/MessageBuilder.cc
@@ -35,22 +35,16 @@ namespace pulsar {
 
 ObjectPool<MessageImpl, 100000> messagePool;
 
-boost::shared_ptr<MessageImpl> MessageBuilder::createMessageImpl() {
-    return messagePool.create();
-}
+boost::shared_ptr<MessageImpl> MessageBuilder::createMessageImpl() { return messagePool.create(); }
 
-MessageBuilder::MessageBuilder() {
-    impl_ = createMessageImpl();
-}
+MessageBuilder::MessageBuilder() { impl_ = createMessageImpl(); }
 
 MessageBuilder& MessageBuilder::create() {
     impl_ = createMessageImpl();
     return *this;
 }
 
-Message MessageBuilder::build() {
-    return Message(impl_);
-}
+Message MessageBuilder::build() { return Message(impl_); }
 
 void MessageBuilder::checkMetadata() {
     if (!impl_.get()) {
@@ -61,25 +55,25 @@ void MessageBuilder::checkMetadata() {
 
 MessageBuilder& MessageBuilder::setContent(const void* data, size_t size) {
     checkMetadata();
-    impl_->payload = SharedBuffer::copy((char *) data, size);
+    impl_->payload = SharedBuffer::copy((char*)data, size);
     return *this;
 }
 
 MessageBuilder& MessageBuilder::setAllocatedContent(void* data, size_t size) {
     checkMetadata();
-    impl_->payload = SharedBuffer::wrap((char *) data, size);
+    impl_->payload = SharedBuffer::wrap((char*)data, size);
     return *this;
 }
 
 MessageBuilder& MessageBuilder::setContent(const std::string& data) {
     checkMetadata();
-    impl_->payload = SharedBuffer::copy((char *) data.c_str(), data.length());
+    impl_->payload = SharedBuffer::copy((char*)data.c_str(), data.length());
     return *this;
 }
 
 MessageBuilder& MessageBuilder::setProperty(const std::string& name, const std::string& value) {
     checkMetadata();
-    proto::KeyValue *keyValue = proto::KeyValue().New();
+    proto::KeyValue* keyValue = proto::KeyValue().New();
     keyValue->set_key(name);
     keyValue->set_value(value);
     impl_->metadata.mutable_properties()->AddAllocated(keyValue);
@@ -131,5 +125,4 @@ MessageBuilder& MessageBuilder::disableReplication(bool flag) {
     r.Swap(impl_->metadata.mutable_replicate_to());
     return *this;
 }
-
 }
diff --git a/pulsar-client-cpp/lib/MessageId.cc b/pulsar-client-cpp/lib/MessageId.cc
index 0cb0b810f..be7f63281 100644
--- a/pulsar-client-cpp/lib/MessageId.cc
+++ b/pulsar-client-cpp/lib/MessageId.cc
@@ -30,12 +30,7 @@
 
 namespace pulsar {
 
-
-MessageId::MessageId()
-        : ledgerId_(-1),
-          entryId_(-1),
-          partition_(-1) {
-}
+MessageId::MessageId() : ledgerId_(-1), entryId_(-1), partition_(-1) {}
 
 MessageId& MessageId::operator=(const MessageId& m) {
     entryId_ = m.entryId_;
@@ -45,11 +40,9 @@ MessageId& MessageId::operator=(const MessageId& m) {
 }
 
 MessageId::MessageId(int64_t ledgerId, int64_t entryId)
-        : ledgerId_(ledgerId),
-          entryId_(entryId),
-          partition_(-1) {
-     // partition is set explicitly in consumerImpl when message is received
-     // consumer's partition is assigned to this partition
+    : ledgerId_(ledgerId), entryId_(entryId), partition_(-1) {
+    // partition is set explicitly in consumerImpl when message is received
+    // consumer's partition is assigned to this partition
 }
 
 int64_t MessageId::getBatchIndex() const {
@@ -64,8 +57,7 @@ const MessageId& MessageId::earliest() {
 
 const MessageId& MessageId::latest() {
     // For entry-id we only have 48bits
-    static const BatchMessageId _latest(std::numeric_limits<int64_t>::max(),
-                                        (int64_t)(pow(2, 47) - 1));
+    static const BatchMessageId _latest(std::numeric_limits<int64_t>::max(), (int64_t)(pow(2, 47) - 1));
     return _latest;
 }
 
@@ -89,11 +81,9 @@ boost::shared_ptr<MessageId> MessageId::deserialize(const std::string& serialize
         throw "Failed to parse serialized message id";
     }
 
-    return boost::make_shared<BatchMessageId>(idData.ledgerid(), idData.entryid(),
-                                              idData.batch_index());
+    return boost::make_shared<BatchMessageId>(idData.ledgerid(), idData.entryid(), idData.batch_index());
 }
 
-
 #pragma GCC visibility push(default)
 std::ostream& operator<<(std::ostream& s, const pulsar::MessageId& messageId) {
     s << '(' << messageId.ledgerId_ << ',' << messageId.entryId_ << ',' << messageId.partition_ << ')';
@@ -119,5 +109,4 @@ bool MessageId::operator==(const MessageId& other) const {
 }
 
 #pragma GCC visibility pop
-
 }
diff --git a/pulsar-client-cpp/lib/MessageImpl.cc b/pulsar-client-cpp/lib/MessageImpl.cc
index f86c08488..b5f02125d 100644
--- a/pulsar-client-cpp/lib/MessageImpl.cc
+++ b/pulsar-client-cpp/lib/MessageImpl.cc
@@ -20,73 +20,62 @@
 
 namespace pulsar {
 
-    MessageImpl::MessageImpl()
-        : metadata(),
-          payload(),
-          messageId(),
-          cnx_(0) {
-    }
+MessageImpl::MessageImpl() : metadata(), payload(), messageId(), cnx_(0) {}
 
-    const Message::StringMap& MessageImpl::properties() {
-        if (properties_.size() == 0) {
-            for (int i = 0; i < metadata.properties_size(); i++) {
-                const std::string& key = metadata.properties(i).key();
-                const std::string& value = metadata.properties(i).value();
-                properties_.insert(std::make_pair(key, value));
-            }
+const Message::StringMap& MessageImpl::properties() {
+    if (properties_.size() == 0) {
+        for (int i = 0; i < metadata.properties_size(); i++) {
+            const std::string& key = metadata.properties(i).key();
+            const std::string& value = metadata.properties(i).value();
+            properties_.insert(std::make_pair(key, value));
         }
-        return properties_;
     }
+    return properties_;
+}
 
-    const std::string& MessageImpl::getPartitionKey() const {
-            return metadata.partition_key();
-    }
+const std::string& MessageImpl::getPartitionKey() const { return metadata.partition_key(); }
 
-    bool MessageImpl::hasPartitionKey() const {
-        return metadata.has_partition_key();
-    }
+bool MessageImpl::hasPartitionKey() const { return metadata.has_partition_key(); }
 
-    uint64_t MessageImpl::getPublishTimestamp() const {
-        if (metadata.has_publish_time()) {
-            return metadata.publish_time();
-        } else {
-            return 0ull;
-        }
+uint64_t MessageImpl::getPublishTimestamp() const {
+    if (metadata.has_publish_time()) {
+        return metadata.publish_time();
+    } else {
+        return 0ull;
     }
+}
 
-    uint64_t MessageImpl::getEventTimestamp() const {
-        if (metadata.has_event_time()) {
-            return metadata.event_time();
-        } else {
-            return 0ull;
-        }
+uint64_t MessageImpl::getEventTimestamp() const {
+    if (metadata.has_event_time()) {
+        return metadata.event_time();
+    } else {
+        return 0ull;
     }
+}
 
-    void MessageImpl::setReplicationClusters(const std::vector<std::string>& clusters) {
-        google::protobuf::RepeatedPtrField<std::string> r(clusters.begin(), clusters.end());
-        r.Swap(metadata.mutable_replicate_to());
-    }
+void MessageImpl::setReplicationClusters(const std::vector<std::string>& clusters) {
+    google::protobuf::RepeatedPtrField<std::string> r(clusters.begin(), clusters.end());
+    r.Swap(metadata.mutable_replicate_to());
+}
 
-    void MessageImpl::disableReplication(bool flag) {
-        google::protobuf::RepeatedPtrField<std::string> r;
-        if (flag) {
-            r.AddAllocated(new std::string("__local__"));
-        }
-        r.Swap(metadata.mutable_replicate_to());
+void MessageImpl::disableReplication(bool flag) {
+    google::protobuf::RepeatedPtrField<std::string> r;
+    if (flag) {
+        r.AddAllocated(new std::string("__local__"));
     }
+    r.Swap(metadata.mutable_replicate_to());
+}
 
-    void MessageImpl::setProperty(const std::string& name, const std::string& value) {
-        proto::KeyValue *keyValue = proto::KeyValue().New();
-        keyValue->set_key(name);
-        keyValue->set_value(value);
-        metadata.mutable_properties()->AddAllocated(keyValue);
-    }
+void MessageImpl::setProperty(const std::string& name, const std::string& value) {
+    proto::KeyValue* keyValue = proto::KeyValue().New();
+    keyValue->set_key(name);
+    keyValue->set_value(value);
+    metadata.mutable_properties()->AddAllocated(keyValue);
+}
 
-    void MessageImpl::setPartitionKey(const std::string& partitionKey) {
-        metadata.set_partition_key(partitionKey);
-    }
+void MessageImpl::setPartitionKey(const std::string& partitionKey) {
+    metadata.set_partition_key(partitionKey);
+}
 
-    void MessageImpl::setEventTimestamp(uint64_t eventTimestamp) {
-        metadata.set_event_time(eventTimestamp);
-    }
+void MessageImpl::setEventTimestamp(uint64_t eventTimestamp) { metadata.set_event_time(eventTimestamp); }
 }
diff --git a/pulsar-client-cpp/lib/MessageImpl.h b/pulsar-client-cpp/lib/MessageImpl.h
index 80d29e2b4..5f37ac0ab 100644
--- a/pulsar-client-cpp/lib/MessageImpl.h
+++ b/pulsar-client-cpp/lib/MessageImpl.h
@@ -35,7 +35,7 @@ class ClientConnection;
 class BatchMessageContainer;
 
 class MessageImpl {
- public:
+   public:
     MessageImpl();
 
     const Message::StringMap& properties();
@@ -53,7 +53,8 @@ class MessageImpl {
 
     friend class PulsarWrapper;
     friend class MessageBuilder;
-private:
+
+   private:
     void setReplicationClusters(const std::vector<std::string>& clusters);
     void setProperty(const std::string& name, const std::string& value);
     void disableReplication(bool flag);
@@ -61,7 +62,6 @@ class MessageImpl {
     void setEventTimestamp(uint64_t eventTimestamp);
     Message::StringMap properties_;
 };
-
 }
 
 #endif /* LIB_MESSAGEIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/NamedEntity.h b/pulsar-client-cpp/lib/NamedEntity.h
index 4f78cb058..443760262 100644
--- a/pulsar-client-cpp/lib/NamedEntity.h
+++ b/pulsar-client-cpp/lib/NamedEntity.h
@@ -22,9 +22,10 @@
 #include <boost/regex.hpp>
 
 class NamedEntity {
- private:
+   private:
     static const boost::regex pattern;
- public:
+
+   public:
     static bool checkName(const std::string& name);
 };
 #endif
diff --git a/pulsar-client-cpp/lib/NamespaceName.cc b/pulsar-client-cpp/lib/NamespaceName.cc
index 5f0631ac8..27308bbad 100644
--- a/pulsar-client-cpp/lib/NamespaceName.cc
+++ b/pulsar-client-cpp/lib/NamespaceName.cc
@@ -28,8 +28,7 @@
 
 DECLARE_LOG_OBJECT()
 
-boost::shared_ptr<NamespaceName> NamespaceName::get(const std::string& property,
-                                                    const std::string& cluster,
+boost::shared_ptr<NamespaceName> NamespaceName::get(const std::string& property, const std::string& cluster,
                                                     const std::string& namespaceName) {
     if (validateNamespace(property, cluster, namespaceName)) {
         boost::shared_ptr<NamespaceName> ptr(new NamespaceName(property, cluster, namespaceName));
@@ -53,8 +52,8 @@ NamespaceName::NamespaceName(const std::string& property, const std::string& clu
 bool NamespaceName::validateNamespace(const std::string& property, const std::string& cluster,
                                       const std::string& namespaceName) {
     if (!property.empty() && !cluster.empty() && !namespaceName.empty()) {
-        return NamedEntity::checkName(property) && NamedEntity::checkName(cluster)
-                && NamedEntity::checkName(namespaceName);
+        return NamedEntity::checkName(property) && NamedEntity::checkName(cluster) &&
+               NamedEntity::checkName(namespaceName);
     } else {
         LOG_DEBUG("Empty parameters passed for validating namespace");
         return false;
@@ -65,18 +64,12 @@ boost::shared_ptr<NamespaceName> NamespaceName::getNamespaceObject() {
     return boost::shared_ptr<NamespaceName>(this);
 }
 
-bool NamespaceName::operator ==(const NamespaceName& namespaceName) {
+bool NamespaceName::operator==(const NamespaceName& namespaceName) {
     return this->namespace_.compare(namespaceName.namespace_) == 0;
 }
 
-std::string NamespaceName::getProperty() {
-    return this->property_;
-}
+std::string NamespaceName::getProperty() { return this->property_; }
 
-std::string NamespaceName::getCluster() {
-    return this->cluster_;
-}
+std::string NamespaceName::getCluster() { return this->cluster_; }
 
-std::string NamespaceName::getLocalName() {
-    return this->localName_;
-}
+std::string NamespaceName::getLocalName() { return this->localName_; }
diff --git a/pulsar-client-cpp/lib/NamespaceName.h b/pulsar-client-cpp/lib/NamespaceName.h
index 8c231d623..f0016caeb 100644
--- a/pulsar-client-cpp/lib/NamespaceName.h
+++ b/pulsar-client-cpp/lib/NamespaceName.h
@@ -24,29 +24,26 @@
 #include <string>
 #include <boost/shared_ptr.hpp>
 
-
 #pragma GCC visibility push(default)
 
 class NamespaceName : public ServiceUnitId {
- public:
+   public:
     boost::shared_ptr<NamespaceName> getNamespaceObject();
     std::string getProperty();
     std::string getCluster();
     std::string getLocalName();
-    static boost::shared_ptr<NamespaceName> get(const std::string& property,
-                                                const std::string& cluster,
+    static boost::shared_ptr<NamespaceName> get(const std::string& property, const std::string& cluster,
                                                 const std::string& namespaceName);
-    bool operator ==(const NamespaceName& namespaceName);
+    bool operator==(const NamespaceName& namespaceName);
 
- private:
+   private:
     std::string namespace_;
     std::string property_;
     std::string cluster_;
     std::string localName_;
     static bool validateNamespace(const std::string& property, const std::string& cluster,
                                   const std::string& namespace_);
-    NamespaceName(const std::string& property, const std::string& cluster,
-                  const std::string& namespace_);
+    NamespaceName(const std::string& property, const std::string& cluster, const std::string& namespace_);
 };
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/lib/ObjectPool.h b/pulsar-client-cpp/lib/ObjectPool.h
index 834838c6e..ddaeded35 100644
--- a/pulsar-client-cpp/lib/ObjectPool.h
+++ b/pulsar-client-cpp/lib/ObjectPool.h
@@ -28,12 +28,12 @@
 
 namespace pulsar {
 
-template<typename T, int MaxSize>
+template <typename T, int MaxSize>
 class Allocator {
-    public:
+   public:
     // Allocator must be stateless, so put everything in this static
     class Impl {
-        public:
+       public:
         // cheap lock to acquire
         static boost::mutex mutex_;
 
@@ -42,16 +42,16 @@ class Allocator {
             Node* next;
             explicit Node(Node* n) : next(n) {}
         };
-        Node *head_;
+        Node* head_;
         int pushSize_;
 
         struct GlobalPool {
-            Node *node_;
+            Node* node_;
             int nodeCount_;
-            GlobalPool *next_;
+            GlobalPool* next_;
             explicit GlobalPool(GlobalPool* n) : next_(n) {}
         };
-        static struct GlobalPool *globalPool_;
+        static struct GlobalPool* globalPool_;
         static int globalNodeCount_;
 
         Impl(const Impl&);
@@ -66,13 +66,12 @@ class Allocator {
                     return NULL;
                 }
 
-                GlobalPool *poolEntry = globalPool_;
+                GlobalPool* poolEntry = globalPool_;
                 head_ = globalPool_->node_;
                 pushSize_ += globalPool_->nodeCount_;
                 globalNodeCount_ -= globalPool_->nodeCount_;
                 globalPool_ = globalPool_->next_;
                 delete poolEntry;
-
             }
             void* result = head_;
             if (result) {
@@ -83,10 +82,8 @@ class Allocator {
         }
 
         bool push(void* p) {
-
             // Once thread specific entries reaches 10% of max size, push them to GlobalPool
-            if (pushSize_ >= MaxSize*0.1) {
-
+            if (pushSize_ >= MaxSize * 0.1) {
                 bool deleteList = true;
                 {
                     // Move the entries to global pool
@@ -95,7 +92,6 @@ class Allocator {
                     // If total node count reached max allowed cache limit,
                     // skip adding to global pool.
                     if ((globalNodeCount_ + pushSize_) <= MaxSize) {
-
                         deleteList = false;
 
                         globalPool_ = new GlobalPool(globalPool_);
@@ -103,18 +99,17 @@ class Allocator {
                         globalPool_->nodeCount_ = pushSize_;
                         globalNodeCount_ += pushSize_;
                     }
-
                 }
                 if (deleteList) {
                     pushSize_ = 0;
                     deleteLinkedList(head_);
                 }
-                head_ = new(p) Node(0);
+                head_ = new (p) Node(0);
                 pushSize_ = 1;
                 return true;
             }
 
-            head_ = new(p) Node(head_);
+            head_ = new (p) Node(head_);
             pushSize_++;
             return true;
         }
@@ -127,7 +122,8 @@ class Allocator {
                 ::operator delete(p);
             }
         }
-    public:
+
+       public:
         Impl() {
             pushSize_ = 0;
             head_ = 0;
@@ -159,30 +155,25 @@ class Allocator {
     typedef T* pointer;
     typedef const void* const_pointer;
 
-    Allocator() {
-    }
+    Allocator() {}
 
-    Allocator(const Allocator& /*other*/) {
-    }
+    Allocator(const Allocator& /*other*/) {}
 
-    template<typename Other, int OtherSize>
-    Allocator(const Allocator<Other, OtherSize>& /*other*/) {
-    }
+    template <typename Other, int OtherSize>
+    Allocator(const Allocator<Other, OtherSize>& /*other*/) {}
 
-    pointer allocate(size_type n, const void * /*hint*/ = 0) {
-        Impl *impl = implPtr_.get();
+    pointer allocate(size_type n, const void* /*hint*/ = 0) {
+        Impl* impl = implPtr_.get();
         if (!impl) {
             implPtr_.reset(new Impl);
             impl = implPtr_.get();
         }
-        void* p = (n == 1)
-            ? impl->allocate()
-            : operator new(n * sizeof(T));
+        void* p = (n == 1) ? impl->allocate() : operator new(n * sizeof(T));
         return static_cast<T*>(p);
     }
 
     void deallocate(pointer ptr, size_type n) {
-        Impl *impl = implPtr_.get();
+        Impl* impl = implPtr_.get();
         if (!impl) {
             implPtr_.reset(new Impl);
             impl = implPtr_.get();
@@ -193,7 +184,8 @@ class Allocator {
             ::operator delete(ptr);
     }
 
-    template<typename Other> struct rebind {
+    template <typename Other>
+    struct rebind {
         typedef Allocator<Other, MaxSize> other;
     };
 };
@@ -201,46 +193,42 @@ class Allocator {
 // typename Allocator<Type,MaxSize>::Impl is important else the compiler
 // doesn't understand that it is a type
 template <typename Type, int MaxSize>
-boost::thread_specific_ptr<typename Allocator<Type,MaxSize>::Impl> Allocator<Type,MaxSize>::implPtr_;
+boost::thread_specific_ptr<typename Allocator<Type, MaxSize>::Impl> Allocator<Type, MaxSize>::implPtr_;
 
 template <typename Type, int MaxSize>
-boost::mutex Allocator<Type,MaxSize>::Impl::mutex_;
+boost::mutex Allocator<Type, MaxSize>::Impl::mutex_;
 
 template <typename Type, int MaxSize>
-struct Allocator<Type,MaxSize>::Impl::GlobalPool *Allocator<Type,MaxSize>::Impl::globalPool_;
+struct Allocator<Type, MaxSize>::Impl::GlobalPool* Allocator<Type, MaxSize>::Impl::globalPool_;
 
 template <typename Type, int MaxSize>
-int Allocator<Type,MaxSize>::Impl::globalNodeCount_;
+int Allocator<Type, MaxSize>::Impl::globalNodeCount_;
 
-template<typename Type, int MaxSize>
+template <typename Type, int MaxSize>
 class ObjectPool {
     typedef boost::shared_ptr<Type> TypeSharedPtr;
 
     Allocator<Type, MaxSize> allocator_;
 
- public:
-    ObjectPool() {
-
-    }
+   public:
+    ObjectPool() {}
 
-    TypeSharedPtr create() {
-        return boost::allocate_shared<Type>(allocator_);
-    }
+    TypeSharedPtr create() { return boost::allocate_shared<Type>(allocator_); }
 
     ~ObjectPool() {
-
-        struct Allocator<Type,MaxSize>::Impl::GlobalPool *poolEntry = Allocator<Type,MaxSize>::Impl::globalPool_;
-        while(poolEntry) {
+        struct Allocator<Type, MaxSize>::Impl::GlobalPool* poolEntry =
+            Allocator<Type, MaxSize>::Impl::globalPool_;
+        while (poolEntry) {
             Allocator<Type, MaxSize>::Impl::deleteLinkedList(poolEntry->node_);
-            struct Allocator<Type,MaxSize>::Impl::GlobalPool *delEntry = poolEntry;
+            struct Allocator<Type, MaxSize>::Impl::GlobalPool* delEntry = poolEntry;
             poolEntry = poolEntry->next_;
             ::operator delete(delEntry);
         }
     }
- private:
+
+   private:
     ObjectPool<Type, MaxSize>(const ObjectPool<Type, MaxSize>&);
     ObjectPool<Type, MaxSize>& operator=(const ObjectPool<Type, MaxSize>&);
 };
-
 }
 #endif /* LIB_OBJECTPOOL_H_ */
diff --git a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc
index 54da934f0..b10f57dbe 100644
--- a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc
+++ b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.cc
@@ -23,147 +23,141 @@
 
 namespace pulsar {
 
-    const std::string PartitionedBrokerConsumerStatsImpl::DELIMITER = ";";
+const std::string PartitionedBrokerConsumerStatsImpl::DELIMITER = ";";
 
-    PartitionedBrokerConsumerStatsImpl::PartitionedBrokerConsumerStatsImpl(size_t size) {
-        statsList_.resize(size);
-    }
+PartitionedBrokerConsumerStatsImpl::PartitionedBrokerConsumerStatsImpl(size_t size) {
+    statsList_.resize(size);
+}
 
-    bool PartitionedBrokerConsumerStatsImpl::isValid() const {
-        bool isValid = true;
-        for (int i = 0; i<statsList_.size(); i++) {
-            isValid &= statsList_[i].isValid();
-        }
-        return isValid;
+bool PartitionedBrokerConsumerStatsImpl::isValid() const {
+    bool isValid = true;
+    for (int i = 0; i < statsList_.size(); i++) {
+        isValid &= statsList_[i].isValid();
     }
+    return isValid;
+}
 
-    std::ostream& operator<<(std::ostream &os, const PartitionedBrokerConsumerStatsImpl& obj) {
-        os << "\nPartitionedBrokerConsumerStatsImpl ["
-           << "validTill_ = " << obj.isValid()
-           << ", msgRateOut_ = " << obj.getMsgRateOut()
-           << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
-           << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
-           << ", consumerName_ = " << obj.getConsumerName()
-           << ", availablePermits_ = " << obj.getAvailablePermits()
-           << ", unackedMessages_ = " << obj.getUnackedMessages()
-           << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
-           << ", address_ = " << obj.getAddress()
-           << ", connectedSince_ = " << obj.getConnectedSince()
-           << ", type_ = " << obj.getType()
-           << ", msgRateExpired_ = " << obj.getMsgRateExpired()
-           << ", msgBacklog_ = " << obj.getMsgBacklog()
-           << "]";
-        return os;
-    }
+std::ostream& operator<<(std::ostream& os, const PartitionedBrokerConsumerStatsImpl& obj) {
+    os << "\nPartitionedBrokerConsumerStatsImpl ["
+       << "validTill_ = " << obj.isValid() << ", msgRateOut_ = " << obj.getMsgRateOut()
+       << ", msgThroughputOut_ = " << obj.getMsgThroughputOut()
+       << ", msgRateRedeliver_ = " << obj.getMsgRateRedeliver()
+       << ", consumerName_ = " << obj.getConsumerName()
+       << ", availablePermits_ = " << obj.getAvailablePermits()
+       << ", unackedMessages_ = " << obj.getUnackedMessages()
+       << ", blockedConsumerOnUnackedMsgs_ = " << obj.isBlockedConsumerOnUnackedMsgs()
+       << ", address_ = " << obj.getAddress() << ", connectedSince_ = " << obj.getConnectedSince()
+       << ", type_ = " << obj.getType() << ", msgRateExpired_ = " << obj.getMsgRateExpired()
+       << ", msgBacklog_ = " << obj.getMsgBacklog() << "]";
+    return os;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgRateOut() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgRateOut();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgRateOut() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgRateOut();
     }
+    return sum;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgThroughputOut() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgThroughputOut();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgThroughputOut() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgThroughputOut();
     }
+    return sum;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgRateRedeliver() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgRateRedeliver();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgRateRedeliver() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgRateRedeliver();
     }
+    return sum;
+}
 
-    const std::string PartitionedBrokerConsumerStatsImpl::getConsumerName() const {
-        std::string str;
-        for (int i = 0; i<statsList_.size(); i++) {
-            str += statsList_[i].getConsumerName() + DELIMITER;
-        }
-        return str;
+const std::string PartitionedBrokerConsumerStatsImpl::getConsumerName() const {
+    std::string str;
+    for (int i = 0; i < statsList_.size(); i++) {
+        str += statsList_[i].getConsumerName() + DELIMITER;
     }
+    return str;
+}
 
-    uint64_t PartitionedBrokerConsumerStatsImpl::getAvailablePermits() const {
-        uint64_t sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getAvailablePermits();
-        }
-        return sum;
+uint64_t PartitionedBrokerConsumerStatsImpl::getAvailablePermits() const {
+    uint64_t sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getAvailablePermits();
     }
+    return sum;
+}
 
-    uint64_t PartitionedBrokerConsumerStatsImpl::getUnackedMessages() const {
-        uint64_t sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getUnackedMessages();
-        }
-        return sum;
+uint64_t PartitionedBrokerConsumerStatsImpl::getUnackedMessages() const {
+    uint64_t sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getUnackedMessages();
     }
+    return sum;
+}
 
-    bool PartitionedBrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const {
-        if (statsList_.size() == 0) {
-            return false;
-        }
-
-        bool isValid = true;
-        for (int i = 0; i<statsList_.size(); i++) {
-            isValid &= statsList_[i].isValid();
-        }
-        return isValid;
+bool PartitionedBrokerConsumerStatsImpl::isBlockedConsumerOnUnackedMsgs() const {
+    if (statsList_.size() == 0) {
+        return false;
     }
 
-    const std::string PartitionedBrokerConsumerStatsImpl::getAddress() const {
-        std::string str;
-        for (int i = 0; i<statsList_.size(); i++) {
-            str += statsList_[i].getAddress() + DELIMITER;
-        }
-        return str;
+    bool isValid = true;
+    for (int i = 0; i < statsList_.size(); i++) {
+        isValid &= statsList_[i].isValid();
     }
+    return isValid;
+}
 
-    const std::string PartitionedBrokerConsumerStatsImpl::getConnectedSince() const {
-        std::string str;
-        for (int i = 0; i<statsList_.size(); i++) {
-            str += statsList_[i].getConnectedSince() + DELIMITER;
-        }
-        return str;
+const std::string PartitionedBrokerConsumerStatsImpl::getAddress() const {
+    std::string str;
+    for (int i = 0; i < statsList_.size(); i++) {
+        str += statsList_[i].getAddress() + DELIMITER;
     }
+    return str;
+}
 
-    const ConsumerType PartitionedBrokerConsumerStatsImpl::getType() const {
-        if (! statsList_.size()) {
-            return ConsumerExclusive;
-        }
-        return statsList_[0].getType();
+const std::string PartitionedBrokerConsumerStatsImpl::getConnectedSince() const {
+    std::string str;
+    for (int i = 0; i < statsList_.size(); i++) {
+        str += statsList_[i].getConnectedSince() + DELIMITER;
     }
+    return str;
+}
 
-    double PartitionedBrokerConsumerStatsImpl::getMsgRateExpired() const {
-        double sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgRateExpired();
-        }
-        return sum;
+const ConsumerType PartitionedBrokerConsumerStatsImpl::getType() const {
+    if (!statsList_.size()) {
+        return ConsumerExclusive;
     }
+    return statsList_[0].getType();
+}
 
-    uint64_t PartitionedBrokerConsumerStatsImpl::getMsgBacklog() const {
-        uint64_t sum = 0;
-        for (int i = 0; i<statsList_.size(); i++) {
-            sum += statsList_[i].getMsgBacklog();
-        }
-        return sum;
+double PartitionedBrokerConsumerStatsImpl::getMsgRateExpired() const {
+    double sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgRateExpired();
     }
+    return sum;
+}
 
-    BrokerConsumerStats PartitionedBrokerConsumerStatsImpl::getBrokerConsumerStats(int index) {
-        return statsList_[index];
+uint64_t PartitionedBrokerConsumerStatsImpl::getMsgBacklog() const {
+    uint64_t sum = 0;
+    for (int i = 0; i < statsList_.size(); i++) {
+        sum += statsList_[i].getMsgBacklog();
     }
+    return sum;
+}
 
-    void PartitionedBrokerConsumerStatsImpl::add(BrokerConsumerStats stats, int index) {
-        statsList_[index] = stats;
-    }
+BrokerConsumerStats PartitionedBrokerConsumerStatsImpl::getBrokerConsumerStats(int index) {
+    return statsList_[index];
+}
 
-    void PartitionedBrokerConsumerStatsImpl::clear() {
-        statsList_.clear();
-    }
+void PartitionedBrokerConsumerStatsImpl::add(BrokerConsumerStats stats, int index) {
+    statsList_[index] = stats;
+}
+
+void PartitionedBrokerConsumerStatsImpl::clear() { statsList_.clear(); }
 }
diff --git a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h
index 321bc698e..4b50eb515 100644
--- a/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h
+++ b/pulsar-client-cpp/lib/PartitionedBrokerConsumerStatsImpl.h
@@ -31,11 +31,11 @@
 #pragma GCC visibility push(default)
 namespace pulsar {
 class PartitionedBrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
- private:
+   private:
     std::vector<BrokerConsumerStats> statsList_;
     static const std::string DELIMITER;
- public:
 
+   public:
     PartitionedBrokerConsumerStatsImpl(size_t size);
 
     /** Returns true if the Stats are still valid **/
@@ -84,10 +84,9 @@ class PartitionedBrokerConsumerStatsImpl : public BrokerConsumerStatsImplBase {
 
     void clear();
 
-    friend std::ostream& operator<<(std::ostream &os, const PartitionedBrokerConsumerStatsImpl &obj);
+    friend std::ostream &operator<<(std::ostream &os, const PartitionedBrokerConsumerStatsImpl &obj);
 };
 typedef boost::shared_ptr<PartitionedBrokerConsumerStatsImpl> PartitionedBrokerConsumerStatsPtr;
-
 }
 #pragma GCC visibility pop
-#endif //PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
+#endif  // PULSAR_CPP_BROKERCONSUMERSTATSIMPL_H
diff --git a/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc b/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
index e25fd27c2..5e2330b52 100644
--- a/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
+++ b/pulsar-client-cpp/lib/PartitionedConsumerImpl.cc
@@ -22,393 +22,383 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    PartitionedConsumerImpl::PartitionedConsumerImpl(ClientImplPtr client,
-            const std::string& subscriptionName,
-            const DestinationNamePtr destinationName,
-            const unsigned int numPartitions,
-            const ConsumerConfiguration& conf)
+PartitionedConsumerImpl::PartitionedConsumerImpl(ClientImplPtr client, const std::string& subscriptionName,
+                                                 const DestinationNamePtr destinationName,
+                                                 const unsigned int numPartitions,
+                                                 const ConsumerConfiguration& conf)
     : client_(client),
-    subscriptionName_(subscriptionName),
-    destinationName_(destinationName),
-    numPartitions_(numPartitions),
-    numConsumersCreated_(0),
-    conf_(conf),
-    state_(Pending),
-    unsubscribedSoFar_(0),
-    messages_(1000),
-    listenerExecutor_(client->getListenerExecutorProvider()->get()),
-    messageListener_(conf.getMessageListener()),
-    topic_(destinationName->toString())
-    {
-        std::stringstream consumerStrStream;
-        consumerStrStream << "[Partitioned Consumer: " << topic_ << "," << subscriptionName << "," << numPartitions << "]";
-        if(conf.getUnAckedMessagesTimeoutMs() != 0) {
-            unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
-        } else {
-            unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerDisabled());
-        }
+      subscriptionName_(subscriptionName),
+      destinationName_(destinationName),
+      numPartitions_(numPartitions),
+      numConsumersCreated_(0),
+      conf_(conf),
+      state_(Pending),
+      unsubscribedSoFar_(0),
+      messages_(1000),
+      listenerExecutor_(client->getListenerExecutorProvider()->get()),
+      messageListener_(conf.getMessageListener()),
+      topic_(destinationName->toString()) {
+    std::stringstream consumerStrStream;
+    consumerStrStream << "[Partitioned Consumer: " << topic_ << "," << subscriptionName << ","
+                      << numPartitions << "]";
+    if (conf.getUnAckedMessagesTimeoutMs() != 0) {
+        unAckedMessageTrackerPtr_.reset(
+            new UnAckedMessageTrackerEnabled(conf.getUnAckedMessagesTimeoutMs(), client, *this));
+    } else {
+        unAckedMessageTrackerPtr_.reset(new UnAckedMessageTrackerDisabled());
     }
+}
 
-    PartitionedConsumerImpl::~PartitionedConsumerImpl() {
-    }
+PartitionedConsumerImpl::~PartitionedConsumerImpl() {}
 
-    Future<Result, ConsumerImplBaseWeakPtr> PartitionedConsumerImpl::getConsumerCreatedFuture() {
-        return partitionedConsumerCreatedPromise_.getFuture();
-    }
-    const std::string& PartitionedConsumerImpl::getSubscriptionName() const {
-        return subscriptionName_;
-    }
+Future<Result, ConsumerImplBaseWeakPtr> PartitionedConsumerImpl::getConsumerCreatedFuture() {
+    return partitionedConsumerCreatedPromise_.getFuture();
+}
+const std::string& PartitionedConsumerImpl::getSubscriptionName() const { return subscriptionName_; }
 
-    const std::string& PartitionedConsumerImpl::getTopic() const {
-        return topic_;
+const std::string& PartitionedConsumerImpl::getTopic() const { return topic_; }
+
+Result PartitionedConsumerImpl::receive(Message& msg) {
+    Lock lock(mutex_);
+    if (state_ != Ready) {
+        lock.unlock();
+        return ResultAlreadyClosed;
     }
 
-    Result PartitionedConsumerImpl::receive(Message& msg) {
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            return ResultAlreadyClosed;
-        }
+    if (messageListener_) {
+        LOG_ERROR("Can not receive when a listener has been set");
+        return ResultInvalidConfiguration;
+    }
 
-        if (messageListener_) {
-            LOG_ERROR("Can not receive when a listener has been set");
-            return ResultInvalidConfiguration;
-        }
+    messages_.pop(msg);
+    unAckedMessageTrackerPtr_->add(msg.getMessageId());
+    return ResultOk;
+}
 
-        messages_.pop(msg);
-        unAckedMessageTrackerPtr_->add(msg.getMessageId());
-        return ResultOk;
+Result PartitionedConsumerImpl::receive(Message& msg, int timeout) {
+    Lock lock(mutex_);
+    if (state_ != Ready) {
+        lock.unlock();
+        return ResultAlreadyClosed;
     }
 
-    Result PartitionedConsumerImpl::receive(Message& msg, int timeout) {
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            return ResultAlreadyClosed;
-        }
-
-       if (messageListener_) {
-            LOG_ERROR("Can not receive when a listener has been set");
-            return ResultInvalidConfiguration;
-        }
+    if (messageListener_) {
+        LOG_ERROR("Can not receive when a listener has been set");
+        return ResultInvalidConfiguration;
+    }
 
-        if (messages_.pop(msg, milliseconds(timeout))) {
-            unAckedMessageTrackerPtr_->add(msg.getMessageId());
-            return ResultOk;
-        } else {
-            return ResultTimeout;
-        }
+    if (messages_.pop(msg, milliseconds(timeout))) {
+        unAckedMessageTrackerPtr_->add(msg.getMessageId());
+        return ResultOk;
+    } else {
+        return ResultTimeout;
     }
+}
 
-    void PartitionedConsumerImpl::unsubscribeAsync(ResultCallback callback) {
-        LOG_INFO("[" << destinationName_->toString() << "," << subscriptionName_ << "] Unsubscribing");
-        // change state to Closing, so that no Ready state operation is permitted during unsubscribe
-        setState(Closing);
-        // do not accept un subscribe until we have subscribe to all of the partitions of a topic
-        // it's a logical single topic so it should behave like a single topic, even if it's sharded
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            unsigned int index = 0;
-            for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end(); consumer++) {
-                LOG_DEBUG("Unsubcribing Consumer - " << index << " for Subscription - "
-                 << subscriptionName_ << " for Topic - " << destinationName_->toString());
-                (*consumer)->unsubscribeAsync(boost::bind(&PartitionedConsumerImpl::handleUnsubscribeAsync,
-                                                          shared_from_this(),
-                                                          _1, index++, callback));
-            }
+void PartitionedConsumerImpl::unsubscribeAsync(ResultCallback callback) {
+    LOG_INFO("[" << destinationName_->toString() << "," << subscriptionName_ << "] Unsubscribing");
+    // change state to Closing, so that no Ready state operation is permitted during unsubscribe
+    setState(Closing);
+    // do not accept un subscribe until we have subscribe to all of the partitions of a topic
+    // it's a logical single topic so it should behave like a single topic, even if it's sharded
+    Lock lock(mutex_);
+    if (state_ != Ready) {
+        lock.unlock();
+        unsigned int index = 0;
+        for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end();
+             consumer++) {
+            LOG_DEBUG("Unsubcribing Consumer - " << index << " for Subscription - " << subscriptionName_
+                                                 << " for Topic - " << destinationName_->toString());
+            (*consumer)->unsubscribeAsync(boost::bind(&PartitionedConsumerImpl::handleUnsubscribeAsync,
+                                                      shared_from_this(), _1, index++, callback));
         }
     }
+}
 
-    void PartitionedConsumerImpl::handleUnsubscribeAsync(Result result,
-                                                         unsigned int consumerIndex,
-                                                         ResultCallback callback) {
-
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            lock.unlock();
-            // we have already informed the client that unsubcribe has failed so, ignore this callbacks
-            // or do we still go ahead and check how many could we close successfully?
-            LOG_DEBUG("handleUnsubscribeAsync callback received in Failed State for consumerIndex - "
-                      << consumerIndex << "with Result - " << result << " for Subscription - "
-                      << subscriptionName_ << " for Topic - " << destinationName_->toString());
-            return;
-        }
+void PartitionedConsumerImpl::handleUnsubscribeAsync(Result result, unsigned int consumerIndex,
+                                                     ResultCallback callback) {
+    Lock lock(mutex_);
+    if (state_ == Failed) {
         lock.unlock();
-        if (result != ResultOk) {
-            setState(Failed);
-            LOG_ERROR("Error Closing one of the parition consumers, consumerIndex - " << consumerIndex);
-            callback(ResultUnknownError);
-            return;
-        }
-        assert (unsubscribedSoFar_ <= numPartitions_);
-        assert (consumerIndex <= numPartitions_);
-        // this means we have successfully closed this partition consumer and no unsubscribe has failed so far
-        LOG_INFO("Successfully Unsubscribed Consumer - " << consumerIndex << " for Subscription - "
-                 << subscriptionName_ << " for Topic - " << destinationName_->toString());
-        unsubscribedSoFar_++;
-        if (unsubscribedSoFar_ == numPartitions_) {
-            LOG_DEBUG("Unsubscribed all of the partition consumer for subscription - " << subscriptionName_);
-            setState(Closed);
-            callback(ResultOk);
-            return;
-        }
+        // we have already informed the client that unsubcribe has failed so, ignore this callbacks
+        // or do we still go ahead and check how many could we close successfully?
+        LOG_DEBUG("handleUnsubscribeAsync callback received in Failed State for consumerIndex - "
+                  << consumerIndex << "with Result - " << result << " for Subscription - "
+                  << subscriptionName_ << " for Topic - " << destinationName_->toString());
+        return;
+    }
+    lock.unlock();
+    if (result != ResultOk) {
+        setState(Failed);
+        LOG_ERROR("Error Closing one of the parition consumers, consumerIndex - " << consumerIndex);
+        callback(ResultUnknownError);
+        return;
+    }
+    assert(unsubscribedSoFar_ <= numPartitions_);
+    assert(consumerIndex <= numPartitions_);
+    // this means we have successfully closed this partition consumer and no unsubscribe has failed so far
+    LOG_INFO("Successfully Unsubscribed Consumer - " << consumerIndex << " for Subscription - "
+                                                     << subscriptionName_ << " for Topic - "
+                                                     << destinationName_->toString());
+    unsubscribedSoFar_++;
+    if (unsubscribedSoFar_ == numPartitions_) {
+        LOG_DEBUG("Unsubscribed all of the partition consumer for subscription - " << subscriptionName_);
+        setState(Closed);
+        callback(ResultOk);
+        return;
     }
+}
 
-    void PartitionedConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback){
-        int partition = msgId.partition_;
-        assert (partition < numPartitions_ && partition >= 0 && consumers_.size() > partition);
-        unAckedMessageTrackerPtr_->remove(msgId);
-        consumers_[partition]->acknowledgeAsync(msgId, callback);
-    }
-
-    void PartitionedConsumerImpl::acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback){
-        callback(ResultOperationNotSupported);
-    }
-
-    void PartitionedConsumerImpl::start(){
-        ExecutorServicePtr internalListenerExecutor = client_->getPartitionListenerExecutorProvider()->get();
-        boost::shared_ptr<ConsumerImpl> consumer;
-        ConsumerConfiguration config;
-        // all the partitioned-consumer belonging to one partitioned topic should have same name
-        config.setConsumerName(conf_.getConsumerName());
-        config.setConsumerType(conf_.getConsumerType());
-        config.setBrokerConsumerStatsCacheTimeInMs(conf_.getBrokerConsumerStatsCacheTimeInMs());
-        config.setMessageListener(boost::bind(&PartitionedConsumerImpl::messageReceived, shared_from_this(), _1, _2));
-        // create consumer on each partition
-        for (unsigned int i = 0; i < numPartitions_; i++ ) {
-            std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
-            consumer = boost::make_shared<ConsumerImpl>(client_, topicPartitionName,
-                                                        subscriptionName_, config,
-                                                        internalListenerExecutor, Partitioned);
-            consumer->getConsumerCreatedFuture().addListener(boost::bind(&PartitionedConsumerImpl::handleSinglePartitionConsumerCreated,
-                                                                         shared_from_this(), _1, _2, i));
-            consumer->setPartitionIndex(i);
-            consumers_.push_back(consumer);
-
-            LOG_DEBUG("Creating Consumer for single Partition - " << topicPartitionName << "SubName - " << subscriptionName_);
-        }
-        for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end(); consumer++) {
-            (*consumer)->start();
-        }
+void PartitionedConsumerImpl::acknowledgeAsync(const MessageId& msgId, ResultCallback callback) {
+    int partition = msgId.partition_;
+    assert(partition < numPartitions_ && partition >= 0 && consumers_.size() > partition);
+    unAckedMessageTrackerPtr_->remove(msgId);
+    consumers_[partition]->acknowledgeAsync(msgId, callback);
+}
+
+void PartitionedConsumerImpl::acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback) {
+    callback(ResultOperationNotSupported);
+}
 
+void PartitionedConsumerImpl::start() {
+    ExecutorServicePtr internalListenerExecutor = client_->getPartitionListenerExecutorProvider()->get();
+    boost::shared_ptr<ConsumerImpl> consumer;
+    ConsumerConfiguration config;
+    // all the partitioned-consumer belonging to one partitioned topic should have same name
+    config.setConsumerName(conf_.getConsumerName());
+    config.setConsumerType(conf_.getConsumerType());
+    config.setBrokerConsumerStatsCacheTimeInMs(conf_.getBrokerConsumerStatsCacheTimeInMs());
+    config.setMessageListener(
+        boost::bind(&PartitionedConsumerImpl::messageReceived, shared_from_this(), _1, _2));
+    // create consumer on each partition
+    for (unsigned int i = 0; i < numPartitions_; i++) {
+        std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
+        consumer = boost::make_shared<ConsumerImpl>(client_, topicPartitionName, subscriptionName_, config,
+                                                    internalListenerExecutor, Partitioned);
+        consumer->getConsumerCreatedFuture().addListener(boost::bind(
+            &PartitionedConsumerImpl::handleSinglePartitionConsumerCreated, shared_from_this(), _1, _2, i));
+        consumer->setPartitionIndex(i);
+        consumers_.push_back(consumer);
+
+        LOG_DEBUG("Creating Consumer for single Partition - " << topicPartitionName << "SubName - "
+                                                              << subscriptionName_);
     }
+    for (ConsumerList::const_iterator consumer = consumers_.begin(); consumer != consumers_.end();
+         consumer++) {
+        (*consumer)->start();
+    }
+}
 
-    void PartitionedConsumerImpl::handleSinglePartitionConsumerCreated(Result result,
-                                                                       ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
-                                                                       unsigned int partitionIndex) {
-        ResultCallback nullCallbackForCleanup = NULL;
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // one of the consumer creation failed, and we are cleaning up
-            return;
-        }
-        assert (numConsumersCreated_ < numPartitions_);
-
-        if (result != ResultOk) {
-            state_ = Failed;
-            lock.unlock();
-            partitionedConsumerCreatedPromise_.setFailed(result);
-            // unsubscribed all of the successfully subscribed partitioned consumers
-            closeAsync(nullCallbackForCleanup);
-            LOG_DEBUG("Unable to create Consumer for partition - " << partitionIndex << " Error - " << result);
-            return;
-        }
+void PartitionedConsumerImpl::handleSinglePartitionConsumerCreated(
+    Result result, ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr, unsigned int partitionIndex) {
+    ResultCallback nullCallbackForCleanup = NULL;
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // one of the consumer creation failed, and we are cleaning up
+        return;
+    }
+    assert(numConsumersCreated_ < numPartitions_);
 
-        assert(partitionIndex < numPartitions_ && partitionIndex >= 0);
-        numConsumersCreated_++;
-        if(numConsumersCreated_ == numPartitions_) {
-            LOG_INFO("Successfully Subscribed to Partitioned Topic - "
-                     << destinationName_->toString() << " with - " << numPartitions_ << " Partitions.");
-            state_ = Ready;
-            lock.unlock();
-            receiveMessages();
-            partitionedConsumerCreatedPromise_.setValue(shared_from_this());
-            return;
-        }
+    if (result != ResultOk) {
+        state_ = Failed;
+        lock.unlock();
+        partitionedConsumerCreatedPromise_.setFailed(result);
+        // unsubscribed all of the successfully subscribed partitioned consumers
+        closeAsync(nullCallbackForCleanup);
+        LOG_DEBUG("Unable to create Consumer for partition - " << partitionIndex << " Error - " << result);
+        return;
+    }
 
+    assert(partitionIndex < numPartitions_ && partitionIndex >= 0);
+    numConsumersCreated_++;
+    if (numConsumersCreated_ == numPartitions_) {
+        LOG_INFO("Successfully Subscribed to Partitioned Topic - "
+                 << destinationName_->toString() << " with - " << numPartitions_ << " Partitions.");
+        state_ = Ready;
+        lock.unlock();
+        receiveMessages();
+        partitionedConsumerCreatedPromise_.setValue(shared_from_this());
+        return;
     }
+}
 
-    void PartitionedConsumerImpl::handleSinglePartitionConsumerClose (Result result, unsigned int partitionIndex, CloseCallback callback) {
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // we should have already notified the client by callback
-            return;
-        }
-        if (result != ResultOk) {
-            state_ = Failed;
-            LOG_ERROR("Closing the consumer failed for partition - " << partitionIndex);
-            lock.unlock();
-            partitionedConsumerCreatedPromise_.setFailed(result);
-            if (!callback.empty()) {
-                callback(result);
-            }
-            return;
-        }
-        assert (partitionIndex < numPartitions_ && partitionIndex >= 0);
-        if(numConsumersCreated_ > 0) {
-            numConsumersCreated_--;
-        }
-        // closed all successfully
-        if(!numConsumersCreated_) {
-            state_ = Closed;
-            lock.unlock();
-            // set the producerCreatedPromise to failure
-            partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
-            if (!callback.empty()) {
-                callback(result);
-            }
-            return;
+void PartitionedConsumerImpl::handleSinglePartitionConsumerClose(Result result, unsigned int partitionIndex,
+                                                                 CloseCallback callback) {
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // we should have already notified the client by callback
+        return;
+    }
+    if (result != ResultOk) {
+        state_ = Failed;
+        LOG_ERROR("Closing the consumer failed for partition - " << partitionIndex);
+        lock.unlock();
+        partitionedConsumerCreatedPromise_.setFailed(result);
+        if (!callback.empty()) {
+            callback(result);
         }
+        return;
     }
-    void PartitionedConsumerImpl::closeAsync(ResultCallback callback) {
-        if (consumers_.empty()) {
-            notifyResult(callback);
-            return;
+    assert(partitionIndex < numPartitions_ && partitionIndex >= 0);
+    if (numConsumersCreated_ > 0) {
+        numConsumersCreated_--;
+    }
+    // closed all successfully
+    if (!numConsumersCreated_) {
+        state_ = Closed;
+        lock.unlock();
+        // set the producerCreatedPromise to failure
+        partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
+        if (!callback.empty()) {
+            callback(result);
         }
-        setState(Closed);
-        int consumerIndex = 0;
-        unsigned int consumerAlreadyClosed = 0;
-        // close successfully subscribed consumers
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            ConsumerImplPtr consumer = *i;
-            if(!consumer->isClosed()) {
-                consumer->closeAsync(boost::bind(&PartitionedConsumerImpl::handleSinglePartitionConsumerClose,
+        return;
+    }
+}
+void PartitionedConsumerImpl::closeAsync(ResultCallback callback) {
+    if (consumers_.empty()) {
+        notifyResult(callback);
+        return;
+    }
+    setState(Closed);
+    int consumerIndex = 0;
+    unsigned int consumerAlreadyClosed = 0;
+    // close successfully subscribed consumers
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        ConsumerImplPtr consumer = *i;
+        if (!consumer->isClosed()) {
+            consumer->closeAsync(boost::bind(&PartitionedConsumerImpl::handleSinglePartitionConsumerClose,
                                              shared_from_this(), _1, consumerIndex, callback));
-            } else {
-                if(++consumerAlreadyClosed == consumers_.size()) {
-                    //everything is closed already. so we are good.
-                    notifyResult(callback);
-                    return;
-                }
+        } else {
+            if (++consumerAlreadyClosed == consumers_.size()) {
+                // everything is closed already. so we are good.
+                notifyResult(callback);
+                return;
             }
         }
     }
+}
 
-    void PartitionedConsumerImpl::notifyResult(CloseCallback closeCallback) {
-        if(closeCallback) {
-            // this means client invoked the closeAsync with a valid callback
-            setState(Closed);
-            closeCallback(ResultOk);
-        } else {
-            // consumer create failed, closeAsync called to cleanup the successfully created producers
-            setState(Failed);
-            partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
-        }
+void PartitionedConsumerImpl::notifyResult(CloseCallback closeCallback) {
+    if (closeCallback) {
+        // this means client invoked the closeAsync with a valid callback
+        setState(Closed);
+        closeCallback(ResultOk);
+    } else {
+        // consumer create failed, closeAsync called to cleanup the successfully created producers
+        setState(Failed);
+        partitionedConsumerCreatedPromise_.setFailed(ResultUnknownError);
     }
+}
 
-    void PartitionedConsumerImpl::setState(const PartitionedConsumerState state) {
-        Lock lock(mutex_);
-        state_ = state;
-        lock.unlock();
-    }
+void PartitionedConsumerImpl::setState(const PartitionedConsumerState state) {
+    Lock lock(mutex_);
+    state_ = state;
+    lock.unlock();
+}
 
-    void PartitionedConsumerImpl::shutdown(){}
+void PartitionedConsumerImpl::shutdown() {}
 
-    bool PartitionedConsumerImpl::isClosed(){
-        return state_ == Closed;
-    }
+bool PartitionedConsumerImpl::isClosed() { return state_ == Closed; }
 
-    bool PartitionedConsumerImpl::isOpen() {
-        Lock lock(mutex_);
-        return state_ == Ready;
-    }
+bool PartitionedConsumerImpl::isOpen() {
+    Lock lock(mutex_);
+    return state_ == Ready;
+}
 
-    void PartitionedConsumerImpl::messageReceived(Consumer consumer, const Message& msg) {
-        LOG_DEBUG("Received Message from one of the partition - " << msg.impl_->messageId.partition_);
-        messages_.push(msg);
-        if (messageListener_) {
-            listenerExecutor_->postWork(boost::bind(&PartitionedConsumerImpl::internalListener, shared_from_this(), consumer));
-        }
+void PartitionedConsumerImpl::messageReceived(Consumer consumer, const Message& msg) {
+    LOG_DEBUG("Received Message from one of the partition - " << msg.impl_->messageId.partition_);
+    messages_.push(msg);
+    if (messageListener_) {
+        listenerExecutor_->postWork(
+            boost::bind(&PartitionedConsumerImpl::internalListener, shared_from_this(), consumer));
     }
+}
 
-    void PartitionedConsumerImpl::internalListener(Consumer consumer) {
-        Message m;
-        messages_.pop(m);
-        try {
-            messageListener_(Consumer(shared_from_this()), m);
-        } catch (const std::exception& e) {
-            LOG_ERROR("Exception thrown from listener of Partitioned Consumer" << e.what());
-        }
+void PartitionedConsumerImpl::internalListener(Consumer consumer) {
+    Message m;
+    messages_.pop(m);
+    try {
+        messageListener_(Consumer(shared_from_this()), m);
+    } catch (const std::exception& e) {
+        LOG_ERROR("Exception thrown from listener of Partitioned Consumer" << e.what());
     }
+}
 
-    void PartitionedConsumerImpl::receiveMessages() {
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            ConsumerImplPtr consumer = *i;
-            consumer->receiveMessages(consumer->getCnx().lock(), conf_.getReceiverQueueSize());
-            LOG_DEBUG("Sending FLOW command for consumer - " << consumer->getConsumerId());
-        }
+void PartitionedConsumerImpl::receiveMessages() {
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        ConsumerImplPtr consumer = *i;
+        consumer->receiveMessages(consumer->getCnx().lock(), conf_.getReceiverQueueSize());
+        LOG_DEBUG("Sending FLOW command for consumer - " << consumer->getConsumerId());
     }
+}
 
-
-    Result PartitionedConsumerImpl::pauseMessageListener() {
-        if (!messageListener_) {
-            return ResultInvalidConfiguration;
-        }
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            (*i)->pauseMessageListener();
-        }
-        return ResultOk;
+Result PartitionedConsumerImpl::pauseMessageListener() {
+    if (!messageListener_) {
+        return ResultInvalidConfiguration;
     }
-
-    Result PartitionedConsumerImpl::resumeMessageListener() {
-        if (!messageListener_) {
-            return ResultInvalidConfiguration;
-        }
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            (*i)->resumeMessageListener();
-        }
-        return ResultOk;
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        (*i)->pauseMessageListener();
     }
+    return ResultOk;
+}
 
-    void PartitionedConsumerImpl::redeliverUnacknowledgedMessages() {
-        LOG_DEBUG("Sending RedeliverUnacknowledgedMessages command for partitioned consumer.");
-        for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
-            (*i)->redeliverUnacknowledgedMessages();
-        }
+Result PartitionedConsumerImpl::resumeMessageListener() {
+    if (!messageListener_) {
+        return ResultInvalidConfiguration;
     }
-
-    const std::string& PartitionedConsumerImpl::getName() const {
-        return partitionStr_;
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        (*i)->resumeMessageListener();
     }
+    return ResultOk;
+}
 
-    int PartitionedConsumerImpl::getNumOfPrefetchedMessages() const {
-        return messages_.size();
+void PartitionedConsumerImpl::redeliverUnacknowledgedMessages() {
+    LOG_DEBUG("Sending RedeliverUnacknowledgedMessages command for partitioned consumer.");
+    for (ConsumerList::const_iterator i = consumers_.begin(); i != consumers_.end(); i++) {
+        (*i)->redeliverUnacknowledgedMessages();
     }
+}
 
-    void PartitionedConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) {
-        Lock lock(mutex_);
-        if (state_ != Ready) {
-            lock.unlock();
-            callback(ResultConsumerNotInitialized, BrokerConsumerStats());
-            return;
-        }
-        PartitionedBrokerConsumerStatsPtr statsPtr = boost::make_shared<PartitionedBrokerConsumerStatsImpl>(numPartitions_);
-        LatchPtr latchPtr = boost::make_shared<Latch>(numPartitions_);
-        ConsumerList consumerList = consumers_;
+const std::string& PartitionedConsumerImpl::getName() const { return partitionStr_; }
+
+int PartitionedConsumerImpl::getNumOfPrefetchedMessages() const { return messages_.size(); }
+
+void PartitionedConsumerImpl::getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback) {
+    Lock lock(mutex_);
+    if (state_ != Ready) {
         lock.unlock();
-        for (int i = 0; i<consumerList.size(); i++) {
-            consumerList[i]->getBrokerConsumerStatsAsync(boost::bind(&PartitionedConsumerImpl::handleGetConsumerStats,
-                                                               shared_from_this(), _1, _2, latchPtr,
-                                                               statsPtr, i, callback));
-        }
+        callback(ResultConsumerNotInitialized, BrokerConsumerStats());
+        return;
     }
+    PartitionedBrokerConsumerStatsPtr statsPtr =
+        boost::make_shared<PartitionedBrokerConsumerStatsImpl>(numPartitions_);
+    LatchPtr latchPtr = boost::make_shared<Latch>(numPartitions_);
+    ConsumerList consumerList = consumers_;
+    lock.unlock();
+    for (int i = 0; i < consumerList.size(); i++) {
+        consumerList[i]->getBrokerConsumerStatsAsync(
+            boost::bind(&PartitionedConsumerImpl::handleGetConsumerStats, shared_from_this(), _1, _2,
+                        latchPtr, statsPtr, i, callback));
+    }
+}
 
-    void PartitionedConsumerImpl::handleGetConsumerStats(Result res, BrokerConsumerStats brokerConsumerStats,
-                                                         LatchPtr latchPtr, PartitionedBrokerConsumerStatsPtr statsPtr,
-                                                         size_t index, BrokerConsumerStatsCallback callback) {
-        Lock lock(mutex_);
-        if (res == ResultOk) {
-            latchPtr->countdown();
-            statsPtr->add(brokerConsumerStats, index);
-        } else {
-            lock.unlock();
-            callback(res, BrokerConsumerStats());
-            return;
-        }
-        if (latchPtr->getCount() == 0) {
-            lock.unlock();
-            callback(ResultOk, BrokerConsumerStats(statsPtr));
-        }
+void PartitionedConsumerImpl::handleGetConsumerStats(Result res, BrokerConsumerStats brokerConsumerStats,
+                                                     LatchPtr latchPtr,
+                                                     PartitionedBrokerConsumerStatsPtr statsPtr, size_t index,
+                                                     BrokerConsumerStatsCallback callback) {
+    Lock lock(mutex_);
+    if (res == ResultOk) {
+        latchPtr->countdown();
+        statsPtr->add(brokerConsumerStats, index);
+    } else {
+        lock.unlock();
+        callback(res, BrokerConsumerStats());
+        return;
     }
+    if (latchPtr->getCount() == 0) {
+        lock.unlock();
+        callback(ResultOk, BrokerConsumerStats(statsPtr));
+    }
+}
 }
diff --git a/pulsar-client-cpp/lib/PartitionedConsumerImpl.h b/pulsar-client-cpp/lib/PartitionedConsumerImpl.h
index 9270039b8..7b38f8a70 100644
--- a/pulsar-client-cpp/lib/PartitionedConsumerImpl.h
+++ b/pulsar-client-cpp/lib/PartitionedConsumerImpl.h
@@ -31,79 +31,77 @@
 #include <lib/PartitionedBrokerConsumerStatsImpl.h>
 
 namespace pulsar {
-    class PartitionedConsumerImpl;
-    class PartitionedConsumerImpl: public ConsumerImplBase, public boost::enable_shared_from_this<PartitionedConsumerImpl> {
-    public:
-        enum PartitionedConsumerState {
-            Pending,
-            Ready,
-            Closing,
-            Closed,
-            Failed
-        };
-        PartitionedConsumerImpl(ClientImplPtr client,
-                                const std::string& subscriptionName,
-                                const DestinationNamePtr destinationName,
-                                const unsigned int numPartitions,
-                                const ConsumerConfiguration& conf);
-        virtual ~PartitionedConsumerImpl ();
-        virtual Future<Result, ConsumerImplBaseWeakPtr> getConsumerCreatedFuture();
-        virtual const std::string& getSubscriptionName() const;
-        virtual const std::string& getTopic() const;
-        virtual Result receive(Message& msg);
-        virtual Result receive(Message& msg, int timeout);
-        virtual void unsubscribeAsync(ResultCallback callback);
-        virtual void acknowledgeAsync(const MessageId& msgId, ResultCallback callback);
-        virtual void acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback);
-        virtual void closeAsync(ResultCallback callback);
-        virtual void start();
-        virtual void shutdown();
-        virtual bool isClosed();
-        virtual bool isOpen();
-        virtual Result pauseMessageListener();
-        virtual Result resumeMessageListener();
-        virtual void redeliverUnacknowledgedMessages();
-        virtual const std::string& getName() const;
-        virtual int getNumOfPrefetchedMessages() const ;
-        virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
-        void handleGetConsumerStats(Result , BrokerConsumerStats, LatchPtr,
-                                    PartitionedBrokerConsumerStatsPtr, size_t, BrokerConsumerStatsCallback);
-
-    private:
-        const ClientImplPtr client_;
-        const std::string subscriptionName_;
-        const DestinationNamePtr destinationName_;
-        unsigned int numPartitions_;
-        unsigned int numConsumersCreated_;
-        const ConsumerConfiguration conf_;
-        typedef std::vector<ConsumerImplPtr> ConsumerList;
-        ConsumerList consumers_;
-        boost::mutex mutex_;
-        PartitionedConsumerState state_;
-        unsigned int unsubscribedSoFar_;
-        BlockingQueue<Message> messages_;
-        ExecutorServicePtr listenerExecutor_;
-        MessageListener messageListener_;
-        const std::string topic_;
-        const std::string name_;
-        const std::string partitionStr_;
-        /* methods */
-        void setState(PartitionedConsumerState state);
-        void handleUnsubscribeAsync(Result result,
-                                    unsigned int consumerIndex,
-                                    ResultCallback callback);
-        void handleSinglePartitionConsumerCreated(Result result,
-                                                  ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
-                                                  unsigned int partitionIndex);
-        void handleSinglePartitionConsumerClose(Result result, unsigned int partitionIndex, CloseCallback callback);
-        void notifyResult(CloseCallback closeCallback);
-        void messageReceived(Consumer consumer, const Message& msg);
-        void internalListener(Consumer consumer);
-        void receiveMessages();
-        Promise<Result, ConsumerImplBaseWeakPtr> partitionedConsumerCreatedPromise_;
-        UnAckedMessageTrackerScopedPtr unAckedMessageTrackerPtr_;
+class PartitionedConsumerImpl;
+class PartitionedConsumerImpl : public ConsumerImplBase,
+                                public boost::enable_shared_from_this<PartitionedConsumerImpl> {
+   public:
+    enum PartitionedConsumerState
+    {
+        Pending,
+        Ready,
+        Closing,
+        Closed,
+        Failed
     };
-    typedef boost::weak_ptr<PartitionedConsumerImpl> PartitionedConsumerImplWeakPtr;
-    typedef boost::shared_ptr<PartitionedConsumerImpl> PartitionedConsumerImplPtr;
+    PartitionedConsumerImpl(ClientImplPtr client, const std::string& subscriptionName,
+                            const DestinationNamePtr destinationName, const unsigned int numPartitions,
+                            const ConsumerConfiguration& conf);
+    virtual ~PartitionedConsumerImpl();
+    virtual Future<Result, ConsumerImplBaseWeakPtr> getConsumerCreatedFuture();
+    virtual const std::string& getSubscriptionName() const;
+    virtual const std::string& getTopic() const;
+    virtual Result receive(Message& msg);
+    virtual Result receive(Message& msg, int timeout);
+    virtual void unsubscribeAsync(ResultCallback callback);
+    virtual void acknowledgeAsync(const MessageId& msgId, ResultCallback callback);
+    virtual void acknowledgeCumulativeAsync(const MessageId& msgId, ResultCallback callback);
+    virtual void closeAsync(ResultCallback callback);
+    virtual void start();
+    virtual void shutdown();
+    virtual bool isClosed();
+    virtual bool isOpen();
+    virtual Result pauseMessageListener();
+    virtual Result resumeMessageListener();
+    virtual void redeliverUnacknowledgedMessages();
+    virtual const std::string& getName() const;
+    virtual int getNumOfPrefetchedMessages() const;
+    virtual void getBrokerConsumerStatsAsync(BrokerConsumerStatsCallback callback);
+    void handleGetConsumerStats(Result, BrokerConsumerStats, LatchPtr, PartitionedBrokerConsumerStatsPtr,
+                                size_t, BrokerConsumerStatsCallback);
+
+   private:
+    const ClientImplPtr client_;
+    const std::string subscriptionName_;
+    const DestinationNamePtr destinationName_;
+    unsigned int numPartitions_;
+    unsigned int numConsumersCreated_;
+    const ConsumerConfiguration conf_;
+    typedef std::vector<ConsumerImplPtr> ConsumerList;
+    ConsumerList consumers_;
+    boost::mutex mutex_;
+    PartitionedConsumerState state_;
+    unsigned int unsubscribedSoFar_;
+    BlockingQueue<Message> messages_;
+    ExecutorServicePtr listenerExecutor_;
+    MessageListener messageListener_;
+    const std::string topic_;
+    const std::string name_;
+    const std::string partitionStr_;
+    /* methods */
+    void setState(PartitionedConsumerState state);
+    void handleUnsubscribeAsync(Result result, unsigned int consumerIndex, ResultCallback callback);
+    void handleSinglePartitionConsumerCreated(Result result, ConsumerImplBaseWeakPtr consumerImplBaseWeakPtr,
+                                              unsigned int partitionIndex);
+    void handleSinglePartitionConsumerClose(Result result, unsigned int partitionIndex,
+                                            CloseCallback callback);
+    void notifyResult(CloseCallback closeCallback);
+    void messageReceived(Consumer consumer, const Message& msg);
+    void internalListener(Consumer consumer);
+    void receiveMessages();
+    Promise<Result, ConsumerImplBaseWeakPtr> partitionedConsumerCreatedPromise_;
+    UnAckedMessageTrackerScopedPtr unAckedMessageTrackerPtr_;
+};
+typedef boost::weak_ptr<PartitionedConsumerImpl> PartitionedConsumerImplWeakPtr;
+typedef boost::shared_ptr<PartitionedConsumerImpl> PartitionedConsumerImplPtr;
 }
-#endif //PULSAR_PARTITIONED_CONSUMER_HEADER
+#endif  // PULSAR_PARTITIONED_CONSUMER_HEADER
diff --git a/pulsar-client-cpp/lib/PartitionedProducerImpl.cc b/pulsar-client-cpp/lib/PartitionedProducerImpl.cc
index ec919fb8b..9a18205e0 100644
--- a/pulsar-client-cpp/lib/PartitionedProducerImpl.cc
+++ b/pulsar-client-cpp/lib/PartitionedProducerImpl.cc
@@ -31,208 +31,205 @@ DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    const std::string PartitionedProducerImpl::PARTITION_NAME_SUFFIX = "-partition-";
-
-    PartitionedProducerImpl::PartitionedProducerImpl(ClientImplPtr client,
-                                                     const DestinationNamePtr destinationName,
-                                                     const unsigned int numPartitions,
-                                                     const ProducerConfiguration& config):client_(client),
-                                                                                          destinationName_(destinationName),
-                                                                                          topic_(destinationName_->toString()),
-                                                                                          conf_(config),
-                                                                                          state_(Pending),
-                                                                                          topicMetadata_(new TopicMetadataImpl(numPartitions))
-    {
-        numProducersCreated_ = 0;
-        cleanup_ = false;
-        routerPolicy_ = getMessageRouter();
-    }
+const std::string PartitionedProducerImpl::PARTITION_NAME_SUFFIX = "-partition-";
+
+PartitionedProducerImpl::PartitionedProducerImpl(ClientImplPtr client,
+                                                 const DestinationNamePtr destinationName,
+                                                 const unsigned int numPartitions,
+                                                 const ProducerConfiguration& config)
+    : client_(client),
+      destinationName_(destinationName),
+      topic_(destinationName_->toString()),
+      conf_(config),
+      state_(Pending),
+      topicMetadata_(new TopicMetadataImpl(numPartitions)) {
+    numProducersCreated_ = 0;
+    cleanup_ = false;
+    routerPolicy_ = getMessageRouter();
+}
 
-    MessageRoutingPolicyPtr PartitionedProducerImpl::getMessageRouter() {
-        switch (conf_.getPartitionsRoutingMode()) {
-            case ProducerConfiguration::RoundRobinDistribution:
-                return boost::make_shared<RoundRobinMessageRouter>();
-            case ProducerConfiguration::CustomPartition:
-                return conf_.getMessageRouterPtr();
-            case ProducerConfiguration::UseSinglePartition:
-            default:
-                unsigned int random = rand();
-                return boost::make_shared<SinglePartitionMessageRouter>(random % topicMetadata_->getNumPartitions());
-        }
+MessageRoutingPolicyPtr PartitionedProducerImpl::getMessageRouter() {
+    switch (conf_.getPartitionsRoutingMode()) {
+        case ProducerConfiguration::RoundRobinDistribution:
+            return boost::make_shared<RoundRobinMessageRouter>();
+        case ProducerConfiguration::CustomPartition:
+            return conf_.getMessageRouterPtr();
+        case ProducerConfiguration::UseSinglePartition:
+        default:
+            unsigned int random = rand();
+            return boost::make_shared<SinglePartitionMessageRouter>(random %
+                                                                    topicMetadata_->getNumPartitions());
     }
+}
 
-    PartitionedProducerImpl::~PartitionedProducerImpl() {
-    }
-    //override
-    const std::string& PartitionedProducerImpl::getTopic() const {
-        return topic_;
+PartitionedProducerImpl::~PartitionedProducerImpl() {}
+// override
+const std::string& PartitionedProducerImpl::getTopic() const { return topic_; }
+
+// override
+void PartitionedProducerImpl::start() {
+    boost::shared_ptr<ProducerImpl> producer;
+    // create producer per partition
+    for (unsigned int i = 0; i < topicMetadata_->getNumPartitions(); i++) {
+        std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
+        producer = boost::make_shared<ProducerImpl>(client_, topicPartitionName, conf_);
+        producer->getProducerCreatedFuture().addListener(boost::bind(
+            &PartitionedProducerImpl::handleSinglePartitionProducerCreated, shared_from_this(), _1, _2, i));
+        producers_.push_back(producer);
+        LOG_DEBUG("Creating Producer for single Partition - " << topicPartitionName);
     }
 
-    //override
-    void PartitionedProducerImpl::start() {
-        boost::shared_ptr<ProducerImpl> producer;
-        // create producer per partition
-        for (unsigned int i = 0; i < topicMetadata_->getNumPartitions(); i++) {
-            std::string topicPartitionName = destinationName_->getTopicPartitionName(i);
-            producer = boost::make_shared<ProducerImpl>(client_, topicPartitionName, conf_);
-            producer->getProducerCreatedFuture().addListener(boost::bind(&PartitionedProducerImpl::handleSinglePartitionProducerCreated,
-                                                                         shared_from_this(), _1, _2, i));
-            producers_.push_back(producer);
-            LOG_DEBUG("Creating Producer for single Partition - " << topicPartitionName);
-        }
-
-        for (ProducerList::const_iterator prod = producers_.begin(); prod != producers_.end(); prod++) {
-            (*prod)->start();
-        }
+    for (ProducerList::const_iterator prod = producers_.begin(); prod != producers_.end(); prod++) {
+        (*prod)->start();
     }
+}
 
-
-    void PartitionedProducerImpl::handleSinglePartitionProducerCreated(Result result,
-                                                                       ProducerImplBaseWeakPtr producerWeakPtr,
-                                                                       unsigned int partitionIndex) {
-        // to indicate, we are doing cleanup using closeAsync after producer create
-        // has failed and the invocation of closeAsync is not from client
-        CloseCallback closeCallback = NULL;
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // Ignore, we have already informed client that producer creation failed
-            return;
-        }
-        assert(numProducersCreated_ <= topicMetadata_->getNumPartitions());
-        if (result != ResultOk) {
-            state_ = Failed;
-            lock.unlock();
-            closeAsync(closeCallback);
-            partitionedProducerCreatedPromise_.setFailed(result);
-            LOG_DEBUG("Unable to create Producer for partition - " << partitionIndex << " Error - " << result);
-            return;
-        }
-
-        assert(partitionIndex <= topicMetadata_->getNumPartitions());
-        numProducersCreated_++;
-        if(numProducersCreated_ == topicMetadata_->getNumPartitions()) {
-            lock.unlock();
-            partitionedProducerCreatedPromise_.setValue(shared_from_this());
-        }
+void PartitionedProducerImpl::handleSinglePartitionProducerCreated(Result result,
+                                                                   ProducerImplBaseWeakPtr producerWeakPtr,
+                                                                   unsigned int partitionIndex) {
+    // to indicate, we are doing cleanup using closeAsync after producer create
+    // has failed and the invocation of closeAsync is not from client
+    CloseCallback closeCallback = NULL;
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // Ignore, we have already informed client that producer creation failed
+        return;
     }
-
-    //override
-    void PartitionedProducerImpl::sendAsync(const Message& msg, SendCallback callback) {
-        //get partition for this message from router policy
-        short partition = (short)(routerPolicy_->getPartition(msg, *topicMetadata_));
-        if (partition >= topicMetadata_->getNumPartitions() || partition >= producers_.size()) {
-            LOG_ERROR("Got Invalid Partition for message from Router Policy, Partition - " << partition);
-            //change me: abort or notify failure in callback?
-            //          change to appropriate error if callback
-            callback(ResultUnknownError, msg);
-            return;
-        }
-        //find a producer for that partition, index should start from 0
-        ProducerImplPtr& producer = producers_[partition];
-        msg.impl_->messageId.partition_ = partition;
-        //send message on that partition
-        producer->sendAsync(msg, callback);
+    assert(numProducersCreated_ <= topicMetadata_->getNumPartitions());
+    if (result != ResultOk) {
+        state_ = Failed;
+        lock.unlock();
+        closeAsync(closeCallback);
+        partitionedProducerCreatedPromise_.setFailed(result);
+        LOG_DEBUG("Unable to create Producer for partition - " << partitionIndex << " Error - " << result);
+        return;
     }
 
-    //override
-    void PartitionedProducerImpl::shutdown() {
-        setState(Closed);
+    assert(partitionIndex <= topicMetadata_->getNumPartitions());
+    numProducersCreated_++;
+    if (numProducersCreated_ == topicMetadata_->getNumPartitions()) {
+        lock.unlock();
+        partitionedProducerCreatedPromise_.setValue(shared_from_this());
     }
+}
 
-    void PartitionedProducerImpl::setState(const PartitionedProducerState state) {
-        Lock lock(mutex_);
-        state_ = state;
-        lock.unlock();
+// override
+void PartitionedProducerImpl::sendAsync(const Message& msg, SendCallback callback) {
+    // get partition for this message from router policy
+    short partition = (short)(routerPolicy_->getPartition(msg, *topicMetadata_));
+    if (partition >= topicMetadata_->getNumPartitions() || partition >= producers_.size()) {
+        LOG_ERROR("Got Invalid Partition for message from Router Policy, Partition - " << partition);
+        // change me: abort or notify failure in callback?
+        //          change to appropriate error if callback
+        callback(ResultUnknownError, msg);
+        return;
     }
+    // find a producer for that partition, index should start from 0
+    ProducerImplPtr& producer = producers_[partition];
+    msg.impl_->messageId.partition_ = partition;
+    // send message on that partition
+    producer->sendAsync(msg, callback);
+}
+
+// override
+void PartitionedProducerImpl::shutdown() { setState(Closed); }
 
-    const std::string& PartitionedProducerImpl::getProducerName() const {
-        return producers_[0]->getProducerName();
+void PartitionedProducerImpl::setState(const PartitionedProducerState state) {
+    Lock lock(mutex_);
+    state_ = state;
+    lock.unlock();
+}
+
+const std::string& PartitionedProducerImpl::getProducerName() const {
+    return producers_[0]->getProducerName();
+}
+
+int64_t PartitionedProducerImpl::getLastSequenceId() const {
+    int64_t currentMax = -1L;
+    for (int i = 0; i < producers_.size(); i++) {
+        currentMax = std::max(currentMax, producers_[i]->getLastSequenceId());
     }
 
-    int64_t PartitionedProducerImpl::getLastSequenceId() const {
-        int64_t currentMax = -1L;
-        for (int i = 0; i < producers_.size(); i++) {
-            currentMax = std::max(currentMax, producers_[i]->getLastSequenceId());
-        }
+    return currentMax;
+}
 
-        return currentMax;
+/*
+ * if createProducerCallback is set, it means the closeAsync is called from CreateProducer API which failed to
+ * create
+ * one or many producers for partitions. So, we have to notify with ERROR on createProducerFailure
+ */
+void PartitionedProducerImpl::closeAsync(CloseCallback closeCallback) {
+    int producerIndex = 0;
+    unsigned int producerAlreadyClosed = 0;
+
+    for (ProducerList::const_iterator i = producers_.begin(); i != producers_.end(); i++) {
+        ProducerImplPtr prod = *i;
+        if (!prod->isClosed()) {
+            prod->closeAsync(boost::bind(&PartitionedProducerImpl::handleSinglePartitionProducerClose,
+                                         shared_from_this(), _1, producerIndex, closeCallback));
+        } else {
+            producerAlreadyClosed++;
+        }
     }
 
     /*
-     * if createProducerCallback is set, it means the closeAsync is called from CreateProducer API which failed to create
-     * one or many producers for partitions. So, we have to notify with ERROR on createProducerFailure
+     * No need to set state since:-
+     * a. If closeAsync before creation then state == Closed, since producers_.size() = producerAlreadyClosed
+     * = 0
+     * b. If closeAsync called after all sub partitioned producer connected -
+     * handleSinglePartitionProducerClose handles the closing
+     * c. If closeAsync called due to failure in creating just one sub producer then state is set by
+     * handleSinglePartitionProducerCreated
      */
-    void PartitionedProducerImpl::closeAsync(CloseCallback closeCallback) {
-        int producerIndex = 0;
-        unsigned int producerAlreadyClosed = 0;
-
-        for (ProducerList::const_iterator i = producers_.begin(); i != producers_.end(); i++) {
-            ProducerImplPtr prod = *i;
-            if(!prod->isClosed()) {
-                prod->closeAsync(boost::bind(&PartitionedProducerImpl::handleSinglePartitionProducerClose,
-                                             shared_from_this(), _1, producerIndex, closeCallback));
-            } else {
-                producerAlreadyClosed++;
-            }
-        }
-
-        /*
-         * No need to set state since:-
-         * a. If closeAsync before creation then state == Closed, since producers_.size() = producerAlreadyClosed = 0
-         * b. If closeAsync called after all sub partitioned producer connected - handleSinglePartitionProducerClose handles the closing
-         * c. If closeAsync called due to failure in creating just one sub producer then state is set by handleSinglePartitionProducerCreated
-         */
-        if (producerAlreadyClosed == producers_.size() && closeCallback) {
-            setState(Closed);
-            closeCallback(ResultOk);
-        }
+    if (producerAlreadyClosed == producers_.size() && closeCallback) {
+        setState(Closed);
+        closeCallback(ResultOk);
     }
+}
 
-    void PartitionedProducerImpl::handleSinglePartitionProducerClose(Result result,
-                                                                     const unsigned int partitionIndex,
-                                                                     CloseCallback callback) {
-        Lock lock(mutex_);
-        if (state_ == Failed) {
-            // we should have already notified the client by callback
-            return;
-        }
-        if (result != ResultOk) {
-            state_ = Failed;
-            lock.unlock();
-            LOG_ERROR("Closing the producer failed for partition - " << partitionIndex);
-            if (callback) {
-                callback(result);
-            }
-            return;
-        }
-        assert (partitionIndex < topicMetadata_->getNumPartitions());
-        if(numProducersCreated_ > 0) {
-            numProducersCreated_--;
+void PartitionedProducerImpl::handleSinglePartitionProducerClose(Result result,
+                                                                 const unsigned int partitionIndex,
+                                                                 CloseCallback callback) {
+    Lock lock(mutex_);
+    if (state_ == Failed) {
+        // we should have already notified the client by callback
+        return;
+    }
+    if (result != ResultOk) {
+        state_ = Failed;
+        lock.unlock();
+        LOG_ERROR("Closing the producer failed for partition - " << partitionIndex);
+        if (callback) {
+            callback(result);
         }
-        // closed all successfully
-        if(!numProducersCreated_) {
-            state_ = Closed;
-            lock.unlock();
-            // set the producerCreatedPromise to failure, if client called
-            // closeAsync and it's not failure to create producer, the promise
-            // is set second time here, first time it was successful. So check
-            // if there's any adverse effect of setting it again. It should not
-            // be but must check. MUSTCHECK changeme
-            partitionedProducerCreatedPromise_.setFailed(ResultUnknownError);
-            if (callback) {
-                callback(result);
-            }
-            return;
+        return;
+    }
+    assert(partitionIndex < topicMetadata_->getNumPartitions());
+    if (numProducersCreated_ > 0) {
+        numProducersCreated_--;
+    }
+    // closed all successfully
+    if (!numProducersCreated_) {
+        state_ = Closed;
+        lock.unlock();
+        // set the producerCreatedPromise to failure, if client called
+        // closeAsync and it's not failure to create producer, the promise
+        // is set second time here, first time it was successful. So check
+        // if there's any adverse effect of setting it again. It should not
+        // be but must check. MUSTCHECK changeme
+        partitionedProducerCreatedPromise_.setFailed(ResultUnknownError);
+        if (callback) {
+            callback(result);
         }
+        return;
     }
+}
 
-    //override
-    Future<Result, ProducerImplBaseWeakPtr> PartitionedProducerImpl::getProducerCreatedFuture() {
-        return partitionedProducerCreatedPromise_.getFuture();
-    }
+// override
+Future<Result, ProducerImplBaseWeakPtr> PartitionedProducerImpl::getProducerCreatedFuture() {
+    return partitionedProducerCreatedPromise_.getFuture();
+}
 
-    //override
-    bool PartitionedProducerImpl::isClosed() {
-        return state_ == Closed;
-    }
+// override
+bool PartitionedProducerImpl::isClosed() { return state_ == Closed; }
 }
diff --git a/pulsar-client-cpp/lib/PartitionedProducerImpl.h b/pulsar-client-cpp/lib/PartitionedProducerImpl.h
index 8bc453c2c..6eecc6cc1 100644
--- a/pulsar-client-cpp/lib/PartitionedProducerImpl.h
+++ b/pulsar-client-cpp/lib/PartitionedProducerImpl.h
@@ -28,24 +28,23 @@
 
 namespace pulsar {
 
-  class PartitionedProducerImpl: public ProducerImplBase, public boost::enable_shared_from_this<PartitionedProducerImpl> {
-
- public:
-    enum PartitionedProducerState {
-      Pending,
-      Ready,
-      Closing,
-      Closed,
-      Failed
+class PartitionedProducerImpl : public ProducerImplBase,
+                                public boost::enable_shared_from_this<PartitionedProducerImpl> {
+   public:
+    enum PartitionedProducerState
+    {
+        Pending,
+        Ready,
+        Closing,
+        Closed,
+        Failed
     };
     const static std::string PARTITION_NAME_SUFFIX;
 
     typedef boost::unique_lock<boost::mutex> Lock;
 
-    PartitionedProducerImpl(ClientImplPtr ptr,
-                            const DestinationNamePtr destinationName,
-                            const unsigned int numPartitions,
-                            const ProducerConfiguration& config);
+    PartitionedProducerImpl(ClientImplPtr ptr, const DestinationNamePtr destinationName,
+                            const unsigned int numPartitions, const ProducerConfiguration& config);
     virtual ~PartitionedProducerImpl();
 
     virtual void sendAsync(const Message& msg, SendCallback callback);
@@ -70,12 +69,10 @@ namespace pulsar {
 
     virtual Future<Result, ProducerImplBaseWeakPtr> getProducerCreatedFuture();
 
-    void handleSinglePartitionProducerCreated(Result result,
-                                              ProducerImplBaseWeakPtr producerBaseWeakPtr,
+    void handleSinglePartitionProducerCreated(Result result, ProducerImplBaseWeakPtr producerBaseWeakPtr,
                                               const unsigned int partitionIndex);
 
-    void handleSinglePartitionProducerClose(Result result,
-                                            const unsigned int partitionIndex,
+    void handleSinglePartitionProducerClose(Result result, const unsigned int partitionIndex,
                                             CloseCallback callback);
 
     void notifyResult(CloseCallback closeCallback);
@@ -84,7 +81,7 @@ namespace pulsar {
 
     friend class PulsarFriend;
 
- private:
+   private:
     const ClientImplPtr client_;
 
     const DestinationNamePtr destinationName_;
@@ -115,7 +112,7 @@ namespace pulsar {
     // only set this promise to value, when producers on all partitions are created.
     Promise<Result, ProducerImplBaseWeakPtr> partitionedProducerCreatedPromise_;
 
-      MessageRoutingPolicyPtr getMessageRouter();
-  };
+    MessageRoutingPolicyPtr getMessageRouter();
+};
 
-} //ends namespace Pulsar
+}  // ends namespace Pulsar
diff --git a/pulsar-client-cpp/lib/Producer.cc b/pulsar-client-cpp/lib/Producer.cc
index b6268ceed..8b0f73102 100644
--- a/pulsar-client-cpp/lib/Producer.cc
+++ b/pulsar-client-cpp/lib/Producer.cc
@@ -27,17 +27,11 @@ namespace pulsar {
 
 static const std::string EMPTY_STRING;
 
-Producer::Producer()
-        : impl_() {
-}
+Producer::Producer() : impl_() {}
 
-Producer::Producer(ProducerImplBasePtr impl)
-        : impl_(impl) {
-}
+Producer::Producer(ProducerImplBasePtr impl) : impl_(impl) {}
 
-const std::string& Producer::getTopic() const {
-    return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING;
-}
+const std::string& Producer::getTopic() const { return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING; }
 
 Result Producer::send(const Message& msg) {
     Promise<Result, Message> promise;
@@ -57,13 +51,9 @@ void Producer::sendAsync(const Message& msg, SendCallback callback) {
     impl_->sendAsync(msg, callback);
 }
 
-const std::string& Producer::getProducerName() const {
-    return impl_->getProducerName();
-}
+const std::string& Producer::getProducerName() const { return impl_->getProducerName(); }
 
-int64_t Producer::getLastSequenceId() const {
-    return impl_->getLastSequenceId();
-}
+int64_t Producer::getLastSequenceId() const { return impl_->getLastSequenceId(); }
 
 Result Producer::close() {
     Promise<bool, Result> promise;
@@ -82,5 +72,4 @@ void Producer::closeAsync(CloseCallback callback) {
 
     impl_->closeAsync(callback);
 }
-
 }
diff --git a/pulsar-client-cpp/lib/ProducerConfiguration.cc b/pulsar-client-cpp/lib/ProducerConfiguration.cc
index 8c5290882..bbd85330b 100644
--- a/pulsar-client-cpp/lib/ProducerConfiguration.cc
+++ b/pulsar-client-cpp/lib/ProducerConfiguration.cc
@@ -18,18 +18,12 @@
  */
 #include <lib/ProducerConfigurationImpl.h>
 
-
 namespace pulsar {
-ProducerConfiguration::ProducerConfiguration()
-        : impl_(boost::make_shared<ProducerConfigurationImpl>()) {
-}
+ProducerConfiguration::ProducerConfiguration() : impl_(boost::make_shared<ProducerConfigurationImpl>()) {}
 
-ProducerConfiguration::~ProducerConfiguration() {
-}
+ProducerConfiguration::~ProducerConfiguration() {}
 
-ProducerConfiguration::ProducerConfiguration(const ProducerConfiguration& x)
-        : impl_(x.impl_) {
-}
+ProducerConfiguration::ProducerConfiguration(const ProducerConfiguration& x) : impl_(x.impl_) {}
 
 ProducerConfiguration& ProducerConfiguration::operator=(const ProducerConfiguration& x) {
     impl_ = x.impl_;
@@ -60,18 +54,14 @@ ProducerConfiguration& ProducerConfiguration::setSendTimeout(int sendTimeoutMs)
     return *this;
 }
 
-int ProducerConfiguration::getSendTimeout() const {
-    return impl_->sendTimeoutMs;
-}
+int ProducerConfiguration::getSendTimeout() const { return impl_->sendTimeoutMs; }
 
 ProducerConfiguration& ProducerConfiguration::setCompressionType(CompressionType compressionType) {
     impl_->compressionType = compressionType;
     return *this;
 }
 
-CompressionType ProducerConfiguration::getCompressionType() const {
-    return impl_->compressionType;
-}
+CompressionType ProducerConfiguration::getCompressionType() const { return impl_->compressionType; }
 
 ProducerConfiguration& ProducerConfiguration::setMaxPendingMessages(int maxPendingMessages) {
     if (maxPendingMessages <= 0) {
@@ -81,12 +71,9 @@ ProducerConfiguration& ProducerConfiguration::setMaxPendingMessages(int maxPendi
     return *this;
 }
 
-int ProducerConfiguration::getMaxPendingMessages() const {
-    return impl_->maxPendingMessages;
-}
+int ProducerConfiguration::getMaxPendingMessages() const { return impl_->maxPendingMessages; }
 
-ProducerConfiguration& ProducerConfiguration::setPartitionsRoutingMode(
-        const PartitionsRoutingMode& mode) {
+ProducerConfiguration& ProducerConfiguration::setPartitionsRoutingMode(const PartitionsRoutingMode& mode) {
     impl_->routingMode = mode;
     return *this;
 }
@@ -95,8 +82,7 @@ ProducerConfiguration::PartitionsRoutingMode ProducerConfiguration::getPartition
     return impl_->routingMode;
 }
 
-ProducerConfiguration& ProducerConfiguration::setMessageRouter(
-        const MessageRoutingPolicyPtr& router) {
+ProducerConfiguration& ProducerConfiguration::setMessageRouter(const MessageRoutingPolicyPtr& router) {
     impl_->routingMode = ProducerConfiguration::CustomPartition;
     impl_->messageRouter = router;
     return *this;
@@ -111,20 +97,16 @@ ProducerConfiguration& ProducerConfiguration::setBlockIfQueueFull(bool flag) {
     return *this;
 }
 
-bool ProducerConfiguration::getBlockIfQueueFull() const {
-    return impl_->blockIfQueueFull;
-}
+bool ProducerConfiguration::getBlockIfQueueFull() const { return impl_->blockIfQueueFull; }
 
 ProducerConfiguration& ProducerConfiguration::setBatchingEnabled(const bool& batchingEnabled) {
     impl_->batchingEnabled = batchingEnabled;
     return *this;
 }
-const bool& ProducerConfiguration::getBatchingEnabled() const {
-    return impl_->batchingEnabled;
-}
+const bool& ProducerConfiguration::getBatchingEnabled() const { return impl_->batchingEnabled; }
 
 ProducerConfiguration& ProducerConfiguration::setBatchingMaxMessages(
-        const unsigned int& batchingMaxMessages) {
+    const unsigned int& batchingMaxMessages) {
     if (batchingMaxMessages <= 1) {
         throw "batchingMaxMessages needs to be greater than 1";
     }
@@ -137,7 +119,7 @@ const unsigned int& ProducerConfiguration::getBatchingMaxMessages() const {
 }
 
 ProducerConfiguration& ProducerConfiguration::setBatchingMaxAllowedSizeInBytes(
-        const unsigned long& batchingMaxAllowedSizeInBytes) {
+    const unsigned long& batchingMaxAllowedSizeInBytes) {
     impl_->batchingMaxAllowedSizeInBytes = batchingMaxAllowedSizeInBytes;
     return *this;
 }
@@ -146,7 +128,7 @@ const unsigned long& ProducerConfiguration::getBatchingMaxAllowedSizeInBytes() c
 }
 
 ProducerConfiguration& ProducerConfiguration::setBatchingMaxPublishDelayMs(
-        const unsigned long& batchingMaxPublishDelayMs) {
+    const unsigned long& batchingMaxPublishDelayMs) {
     impl_->batchingMaxPublishDelayMs = batchingMaxPublishDelayMs;
     return *this;
 }
diff --git a/pulsar-client-cpp/lib/ProducerConfigurationImpl.h b/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
index 29a03d33e..8c1b24a1b 100644
--- a/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ProducerConfigurationImpl.h
@@ -40,19 +40,17 @@ struct ProducerConfigurationImpl {
     unsigned long batchingMaxAllowedSizeInBytes;
     unsigned long batchingMaxPublishDelayMs;
     ProducerConfigurationImpl()
-            : sendTimeoutMs(30000),
-              compressionType(CompressionNone),
-              maxPendingMessages(1000),
-              routingMode(ProducerConfiguration::UseSinglePartition),
-              blockIfQueueFull(false),
-              batchingEnabled(false),
-              batchingMaxMessages(1000),
-              batchingMaxAllowedSizeInBytes(128 * 1024), // 128 KB
-              batchingMaxPublishDelayMs(10) { // 10 milli seconds
+        : sendTimeoutMs(30000),
+          compressionType(CompressionNone),
+          maxPendingMessages(1000),
+          routingMode(ProducerConfiguration::UseSinglePartition),
+          blockIfQueueFull(false),
+          batchingEnabled(false),
+          batchingMaxMessages(1000),
+          batchingMaxAllowedSizeInBytes(128 * 1024),  // 128 KB
+          batchingMaxPublishDelayMs(10) {             // 10 milli seconds
     }
 };
 }
 
-
-
 #endif /* LIB_PRODUCERCONFIGURATIONIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/ProducerImpl.cc b/pulsar-client-cpp/lib/ProducerImpl.cc
index 31bd982e5..e2152d7ec 100644
--- a/pulsar-client-cpp/lib/ProducerImpl.cc
+++ b/pulsar-client-cpp/lib/ProducerImpl.cc
@@ -29,40 +29,29 @@
 namespace pulsar {
 DECLARE_LOG_OBJECT()
 
-OpSendMsg ::OpSendMsg()
-        : msg_(),
-          sendCallback_(),
-          producerId_(),
-          sequenceId_(),
-          timeout_() {
-}
+OpSendMsg::OpSendMsg() : msg_(), sendCallback_(), producerId_(), sequenceId_(), timeout_() {}
 
 OpSendMsg::OpSendMsg(uint64_t producerId, uint64_t sequenceId, const Message& msg,
                      const SendCallback& sendCallback, const ProducerConfiguration& conf)
-        : msg_(msg),
-          sendCallback_(sendCallback),
-          producerId_(producerId),
-          sequenceId_(sequenceId),
-          timeout_(now() + milliseconds(conf.getSendTimeout())) {
-}
-
-ProducerImpl::ProducerImpl(ClientImplPtr client, const std::string& topic,
-                           const ProducerConfiguration& conf)
-        : HandlerBase(
-                  client,
-                  topic,
-                  Backoff(milliseconds(100), seconds(60),
-                          milliseconds(std::max(100, conf.getSendTimeout() - 100)))),
-          conf_(conf),
-          executor_(client->getIOExecutorProvider()->get()),
-          pendingMessagesQueue_(conf_.getMaxPendingMessages()),
-          producerName_(conf_.getProducerName()),
-          producerStr_("[" + topic_ + ", " + producerName_ + "] "),
-          producerId_(client->newProducerId()),
-          msgSequenceGenerator_(0),
-          sendTimer_() {
-    LOG_DEBUG(
-            "ProducerName - " << producerName_ << " Created producer on topic " << topic_ << " id: " << producerId_);
+    : msg_(msg),
+      sendCallback_(sendCallback),
+      producerId_(producerId),
+      sequenceId_(sequenceId),
+      timeout_(now() + milliseconds(conf.getSendTimeout())) {}
+
+ProducerImpl::ProducerImpl(ClientImplPtr client, const std::string& topic, const ProducerConfiguration& conf)
+    : HandlerBase(client, topic, Backoff(milliseconds(100), seconds(60),
+                                         milliseconds(std::max(100, conf.getSendTimeout() - 100)))),
+      conf_(conf),
+      executor_(client->getIOExecutorProvider()->get()),
+      pendingMessagesQueue_(conf_.getMaxPendingMessages()),
+      producerName_(conf_.getProducerName()),
+      producerStr_("[" + topic_ + ", " + producerName_ + "] "),
+      producerId_(client->newProducerId()),
+      msgSequenceGenerator_(0),
+      sendTimer_() {
+    LOG_DEBUG("ProducerName - " << producerName_ << " Created producer on topic " << topic_
+                                << " id: " << producerId_);
 
     int64_t initialSequenceId = conf.getInitialSequenceId();
     lastSequenceIdPublished_ = initialSequenceId;
@@ -75,8 +64,8 @@ ProducerImpl::ProducerImpl(ClientImplPtr client, const std::string& topic,
 
     unsigned int statsIntervalInSeconds = client->getClientConfig().getStatsIntervalInSeconds();
     if (statsIntervalInSeconds) {
-        producerStatsBasePtr_ = boost::make_shared<ProducerStatsImpl>(producerStr_, executor_->createDeadlineTimer(),
-                                                                        statsIntervalInSeconds);
+        producerStatsBasePtr_ = boost::make_shared<ProducerStatsImpl>(
+            producerStr_, executor_->createDeadlineTimer(), statsIntervalInSeconds);
     } else {
         producerStatsBasePtr_ = boost::make_shared<ProducerStatsDisabled>();
     }
@@ -88,17 +77,11 @@ ProducerImpl::~ProducerImpl() {
     printStats();
 }
 
-const std::string& ProducerImpl::getTopic() const {
-    return topic_;
-}
+const std::string& ProducerImpl::getTopic() const { return topic_; }
 
-const std::string& ProducerImpl::getProducerName() const {
-    return producerName_;
-}
+const std::string& ProducerImpl::getProducerName() const { return producerName_; }
 
-int64_t ProducerImpl::getLastSequenceId() const {
-    return lastSequenceIdPublished_;
-}
+int64_t ProducerImpl::getLastSequenceId() const { return lastSequenceIdPublished_; }
 
 void ProducerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
     Lock lock(mutex_);
@@ -113,8 +96,8 @@ void ProducerImpl::connectionOpened(const ClientConnectionPtr& cnx) {
     int requestId = client->newRequestId();
 
     SharedBuffer cmd = Commands::newProducer(topic_, producerId_, producerName_, requestId);
-    cnx->sendRequestWithId(cmd, requestId).addListener(
-            boost::bind(&ProducerImpl::handleCreateProducer, shared_from_this(), cnx, _1, _2));
+    cnx->sendRequestWithId(cmd, requestId)
+        .addListener(boost::bind(&ProducerImpl::handleCreateProducer, shared_from_this(), cnx, _1, _2));
 }
 
 void ProducerImpl::connectionFailed(Result result) {
@@ -162,8 +145,7 @@ void ProducerImpl::handleCreateProducer(const ClientConnectionPtr& cnx, Result r
         if (!sendTimer_ && conf_.getSendTimeout() > 0) {
             sendTimer_ = executor_->createDeadlineTimer();
             sendTimer_->expires_from_now(milliseconds(conf_.getSendTimeout()));
-            sendTimer_->async_wait(
-                    boost::bind(&ProducerImpl::handleSendTimeout, shared_from_this(), _1));
+            sendTimer_->async_wait(boost::bind(&ProducerImpl::handleSendTimeout, shared_from_this(), _1));
         }
 
         producerCreatedPromise_.setValue(shared_from_this());
@@ -183,8 +165,7 @@ void ProducerImpl::handleCreateProducer(const ClientConnectionPtr& cnx, Result r
                 LOG_WARN(getName() << "Backlog is exceeded on topic. Sending exception to producer");
                 failPendingMessages(ResultProducerBlockedQuotaExceededException);
             } else if (result == ResultProducerBlockedQuotaExceededError) {
-                LOG_WARN(
-                        getName() << "Producer is blocked on creation because backlog is exceeded on topic");
+                LOG_WARN(getName() << "Producer is blocked on creation because backlog is exceeded on topic");
             }
 
             // Producer had already been initially created, we need to retry connecting in any case
@@ -213,8 +194,8 @@ void ProducerImpl::failPendingMessages(Result result) {
 
     // Iterate over a copy of the pending messages queue, to trigger the future completion
     // without holding producer mutex.
-    for (MessageQueue::const_iterator it = pendingMessagesQueue_.begin();
-            it != pendingMessagesQueue_.end(); it++) {
+    for (MessageQueue::const_iterator it = pendingMessagesQueue_.begin(); it != pendingMessagesQueue_.end();
+         it++) {
         messagesToFail.push_back(*it);
     }
 
@@ -225,8 +206,8 @@ void ProducerImpl::failPendingMessages(Result result) {
     }
     pendingMessagesQueue_.clear();
     lock.unlock();
-    for (std::vector<OpSendMsg>::const_iterator it = messagesToFail.begin();
-            it != messagesToFail.end(); it++) {
+    for (std::vector<OpSendMsg>::const_iterator it = messagesToFail.begin(); it != messagesToFail.end();
+         it++) {
         it->sendCallback_(result, it->msg_);
     }
 
@@ -241,29 +222,30 @@ void ProducerImpl::resendMessages(ClientConnectionPtr cnx) {
 
     LOG_DEBUG(getName() << "Re-Sending " << pendingMessagesQueue_.size() << " messages to server");
 
-    for (MessageQueue::const_iterator it = pendingMessagesQueue_.begin();
-            it != pendingMessagesQueue_.end(); ++it) {
+    for (MessageQueue::const_iterator it = pendingMessagesQueue_.begin(); it != pendingMessagesQueue_.end();
+         ++it) {
         LOG_DEBUG(getName() << "Re-Sending " << it->sequenceId_);
         cnx->sendMessage(*it);
     }
 }
 
-void ProducerImpl::setMessageMetadata(const Message &msg, const uint64_t& sequenceId, const uint32_t& uncompressedSize) {
+void ProducerImpl::setMessageMetadata(const Message& msg, const uint64_t& sequenceId,
+                                      const uint32_t& uncompressedSize) {
     // Call this function after acquiring the mutex_
     proto::MessageMetadata& msgMetadata = msg.impl_->metadata;
-    if (! batchMessageContainer) {
+    if (!batchMessageContainer) {
         msgMetadata.set_producer_name(producerName_);
     }
     msgMetadata.set_publish_time(currentTimeMillis());
     msgMetadata.set_sequence_id(sequenceId);
     if (conf_.getCompressionType() != CompressionNone) {
-        msgMetadata.set_compression(
-                CompressionCodecProvider::convertType(conf_.getCompressionType()));
+        msgMetadata.set_compression(CompressionCodecProvider::convertType(conf_.getCompressionType()));
         msgMetadata.set_uncompressed_size(uncompressedSize);
     }
 }
 
-void ProducerImpl::statsCallBackHandler(Result res, const Message& msg, SendCallback callback, boost::posix_time::ptime publishTime) {
+void ProducerImpl::statsCallBackHandler(Result res, const Message& msg, SendCallback callback,
+                                        boost::posix_time::ptime publishTime) {
     producerStatsBasePtr_->messageReceived(res, publishTime);
     if (callback) {
         callback(res, msg);
@@ -272,21 +254,22 @@ void ProducerImpl::statsCallBackHandler(Result res, const Message& msg, SendCall
 
 void ProducerImpl::sendAsync(const Message& msg, SendCallback callback) {
     producerStatsBasePtr_->messageSent(msg);
-    SendCallback cb = boost::bind(&ProducerImpl::statsCallBackHandler, this, _1, _2, callback, boost::posix_time::microsec_clock::universal_time());
+    SendCallback cb = boost::bind(&ProducerImpl::statsCallBackHandler, this, _1, _2, callback,
+                                  boost::posix_time::microsec_clock::universal_time());
 
     // Compress the payload if required
     SharedBuffer& payload = msg.impl_->payload;
 
     uint32_t uncompressedSize = payload.readableBytes();
 
-    if (! batchMessageContainer) {
+    if (!batchMessageContainer) {
         // If batching is enabled we compress all the payloads together before sending the batch
         payload = CompressionCodecProvider::getCodec(conf_.getCompressionType()).encode(payload);
     }
     uint32_t compressedSize = payload.readableBytes();
     if (compressedSize > Commands::MaxMessageSize) {
-        LOG_DEBUG(
-                getName() << " - compressed Message payload size" << compressedSize << "cannot exceed " << Commands::MaxMessageSize << " bytes");
+        LOG_DEBUG(getName() << " - compressed Message payload size" << compressedSize << "cannot exceed "
+                            << Commands::MaxMessageSize << " bytes");
         cb(ResultMessageTooBig, msg);
         return;
     }
@@ -353,8 +336,8 @@ void ProducerImpl::sendAsync(const Message& msg, SendCallback callback) {
 // b. call this function after acquiring the ProducerImpl mutex_
 void ProducerImpl::sendMessage(const Message& msg, SendCallback callback) {
     const uint64_t& sequenceId = msg.impl_->metadata.sequence_id();
-    LOG_DEBUG(
-            getName() << "Sending msg: " << sequenceId << " -- queue_size: " << pendingMessagesQueue_.size());
+    LOG_DEBUG(getName() << "Sending msg: " << sequenceId
+                        << " -- queue_size: " << pendingMessagesQueue_.size());
 
     OpSendMsg op(producerId_, sequenceId, msg, callback, conf_);
 
@@ -375,7 +358,7 @@ void ProducerImpl::sendMessage(const Message& msg, SendCallback callback) {
 
 void ProducerImpl::batchMessageTimeoutHandler(const boost::system::error_code& ec) {
     if (ec) {
-        LOG_DEBUG(getName() << " Ignoring timer cancelled event, code[" << ec <<"]");
+        LOG_DEBUG(getName() << " Ignoring timer cancelled event, code[" << ec << "]");
         return;
     }
     LOG_DEBUG(getName() << " - Batch Message Timer expired");
@@ -385,11 +368,10 @@ void ProducerImpl::batchMessageTimeoutHandler(const boost::system::error_code& e
 
 void ProducerImpl::printStats() {
     if (batchMessageContainer) {
-        LOG_INFO("Producer - " << producerStr_ <<
-             ", [batchMessageContainer = " << *batchMessageContainer << "]");
+        LOG_INFO("Producer - " << producerStr_ << ", [batchMessageContainer = " << *batchMessageContainer
+                               << "]");
     } else {
-        LOG_INFO("Producer - " << producerStr_ <<
-             ", [batching  = off]");
+        LOG_INFO("Producer - " << producerStr_ << ", [batching  = off]");
     }
 }
 
@@ -429,11 +411,10 @@ void ProducerImpl::closeAsync(CloseCallback callback) {
         return;
     }
     int requestId = client->newRequestId();
-    Future<Result, ResponseData> future = cnx->sendRequestWithId(
-            Commands::newCloseProducer(producerId_, requestId), requestId);
+    Future<Result, ResponseData> future =
+        cnx->sendRequestWithId(Commands::newCloseProducer(producerId_, requestId), requestId);
     if (!callback.empty()) {
-        future.addListener(
-                boost::bind(&ProducerImpl::handleClose, shared_from_this(), _1, callback));
+        future.addListener(boost::bind(&ProducerImpl::handleClose, shared_from_this(), _1, callback));
     }
 }
 
@@ -457,9 +438,7 @@ Future<Result, ProducerImplBaseWeakPtr> ProducerImpl::getProducerCreatedFuture()
     return producerCreatedPromise_.getFuture();
 }
 
-uint64_t ProducerImpl::getProducerId() const {
-    return producerId_;
-}
+uint64_t ProducerImpl::getProducerId() const { return producerId_; }
 
 void ProducerImpl::handleSendTimeout(const boost::system::error_code& err) {
     if (err == boost::asio::error::operation_aborted) {
@@ -497,20 +476,19 @@ void ProducerImpl::handleSendTimeout(const boost::system::error_code& err) {
 }
 
 bool ProducerImpl::removeCorruptMessage(uint64_t sequenceId) {
-
     OpSendMsg op;
     Lock lock(mutex_);
     bool havePendingAck = pendingMessagesQueue_.peek(op);
     if (!havePendingAck) {
         LOG_DEBUG(getName() << " -- SequenceId - " << sequenceId << "]"  //
-                << "Got send failure for expired message, ignoring it.");
+                            << "Got send failure for expired message, ignoring it.");
         return true;
     }
     uint64_t expectedSequenceId = op.sequenceId_;
     if (sequenceId > expectedSequenceId) {
-        LOG_WARN(getName() << "Got ack failure for msg " << sequenceId  //
-                << " expecting: " << expectedSequenceId << " queue size="//
-                << pendingMessagesQueue_.size() << " producer: " << producerId_);
+        LOG_WARN(getName() << "Got ack failure for msg " << sequenceId                //
+                           << " expecting: " << expectedSequenceId << " queue size="  //
+                           << pendingMessagesQueue_.size() << " producer: " << producerId_);
         return false;
     } else if (sequenceId < expectedSequenceId) {
         LOG_DEBUG(getName() << "Corrupt message is already timed out. Ignoring msg " << sequenceId);
@@ -534,7 +512,6 @@ bool ProducerImpl::removeCorruptMessage(uint64_t sequenceId) {
         }
         return true;
     }
-
 }
 
 bool ProducerImpl::ackReceived(uint64_t sequenceId) {
@@ -543,19 +520,19 @@ bool ProducerImpl::ackReceived(uint64_t sequenceId) {
     bool havePendingAck = pendingMessagesQueue_.peek(op);
     if (!havePendingAck) {
         LOG_DEBUG(getName() << " -- SequenceId - " << sequenceId << "]"  //
-                << "Got an SEND_ACK for expired message, ignoring it.");
+                            << "Got an SEND_ACK for expired message, ignoring it.");
         return true;
     }
     uint64_t expectedSequenceId = op.sequenceId_;
     if (sequenceId > expectedSequenceId) {
-        LOG_WARN(getName() << "Got ack for msg " << sequenceId  //
-                << " expecting: " << expectedSequenceId << " queue size="//
-                << pendingMessagesQueue_.size() << " producer: " << producerId_);
+        LOG_WARN(getName() << "Got ack for msg " << sequenceId                        //
+                           << " expecting: " << expectedSequenceId << " queue size="  //
+                           << pendingMessagesQueue_.size() << " producer: " << producerId_);
         return false;
     } else if (sequenceId < expectedSequenceId) {
         // Ignoring the ack since it's referring to a message that has already timed out.
         LOG_DEBUG(getName() << "Got ack for timed out msg " << sequenceId  //
-                << " last-seq: " << expectedSequenceId << " producer: " << producerId_);
+                            << " last-seq: " << expectedSequenceId << " producer: " << producerId_);
         return true;
     } else {
         // Message was persisted correctly
@@ -582,20 +559,16 @@ bool ProducerImpl::ackReceived(uint64_t sequenceId) {
 }
 
 void ProducerImpl::disconnectProducer() {
-	LOG_DEBUG("Broker notification of Closed producer: " << producerId_);
-	Lock lock(mutex_);
-	connection_.reset();
-	lock.unlock();
-	scheduleReconnection(shared_from_this());
+    LOG_DEBUG("Broker notification of Closed producer: " << producerId_);
+    Lock lock(mutex_);
+    connection_.reset();
+    lock.unlock();
+    scheduleReconnection(shared_from_this());
 }
 
-const std::string& ProducerImpl::getName() const{
-    return producerStr_;
-}
+const std::string& ProducerImpl::getName() const { return producerStr_; }
 
-void ProducerImpl::start() {
-    HandlerBase::start();
-}
+void ProducerImpl::start() { HandlerBase::start(); }
 
 void ProducerImpl::shutdown() {
     Lock lock(mutex_);
@@ -604,7 +577,7 @@ void ProducerImpl::shutdown() {
     producerCreatedPromise_.setFailed(ResultAlreadyClosed);
 }
 
-bool ProducerImplCmp::operator()(const ProducerImplPtr &a, const ProducerImplPtr &b) const {
+bool ProducerImplCmp::operator()(const ProducerImplPtr& a, const ProducerImplPtr& b) const {
     return a->getProducerId() < b->getProducerId();
 }
 
@@ -612,6 +585,5 @@ bool ProducerImpl::isClosed() {
     Lock lock(mutex_);
     return state_ == Closed;
 }
-
 }
 /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/ProducerImpl.h b/pulsar-client-cpp/lib/ProducerImpl.h
index 619bf0d23..f89823f43 100644
--- a/pulsar-client-cpp/lib/ProducerImpl.h
+++ b/pulsar-client-cpp/lib/ProducerImpl.h
@@ -22,8 +22,6 @@
 #include <boost/thread/mutex.hpp>
 #include <boost/date_time/posix_time/ptime.hpp>
 
-
-
 #include "ClientImpl.h"
 #include "BlockingQueue.h"
 #include "HandlerBase.h"
@@ -50,13 +48,14 @@ struct OpSendMsg {
     boost::posix_time::ptime timeout_;
 
     OpSendMsg();
-    OpSendMsg(uint64_t producerId, uint64_t sequenceId, const Message& msg,
-              const SendCallback& sendCallback, const ProducerConfiguration& conf);
+    OpSendMsg(uint64_t producerId, uint64_t sequenceId, const Message& msg, const SendCallback& sendCallback,
+              const ProducerConfiguration& conf);
 };
 
-class ProducerImpl : public HandlerBase, public boost::enable_shared_from_this<ProducerImpl>, public ProducerImplBase {
- public:
-
+class ProducerImpl : public HandlerBase,
+                     public boost::enable_shared_from_this<ProducerImpl>,
+                     public ProducerImplBase {
+   public:
     ProducerImpl(ClientImplPtr client, const std::string& topic,
                  const ProducerConfiguration& producerConfiguration);
     ~ProducerImpl();
@@ -87,12 +86,12 @@ class ProducerImpl : public HandlerBase, public boost::enable_shared_from_this<P
 
     bool isClosed();
 
- protected:
+   protected:
     ProducerStatsBasePtr producerStatsBasePtr_;
 
     typedef BlockingQueue<OpSendMsg> MessageQueue;
 
-    void setMessageMetadata(const Message &msg, const uint64_t& sequenceId, const uint32_t& uncompressedSize);
+    void setMessageMetadata(const Message& msg, const uint64_t& sequenceId, const uint32_t& uncompressedSize);
 
     void sendMessage(const Message& msg, SendCallback callback);
 
@@ -105,19 +104,17 @@ class ProducerImpl : public HandlerBase, public boost::enable_shared_from_this<P
     virtual void connectionOpened(const ClientConnectionPtr& connection);
     virtual void connectionFailed(Result result);
 
-    virtual HandlerBaseWeakPtr get_weak_from_this() {
-        return shared_from_this();
-    }
+    virtual HandlerBaseWeakPtr get_weak_from_this() { return shared_from_this(); }
 
     const std::string& getName() const;
 
- private:
+   private:
     void printStats();
 
     void handleCreateProducer(const ClientConnectionPtr& cnx, Result result,
                               const ResponseData& responseData);
 
-    void statsCallBackHandler(Result , const Message& , SendCallback , boost::posix_time::ptime );
+    void statsCallBackHandler(Result, const Message&, SendCallback, boost::posix_time::ptime);
 
     void handleClose(Result result, ResultCallback callback);
 
@@ -150,7 +147,7 @@ class ProducerImpl : public HandlerBase, public boost::enable_shared_from_this<P
 };
 
 struct ProducerImplCmp {
-    bool operator()(const ProducerImplPtr &a, const ProducerImplPtr &b) const;
+    bool operator()(const ProducerImplPtr& a, const ProducerImplPtr& b) const;
 };
 
 } /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/ProducerImplBase.h b/pulsar-client-cpp/lib/ProducerImplBase.h
index a6e1889bb..0445fed0f 100644
--- a/pulsar-client-cpp/lib/ProducerImplBase.h
+++ b/pulsar-client-cpp/lib/ProducerImplBase.h
@@ -28,21 +28,20 @@ typedef boost::weak_ptr<ProducerImplBase> ProducerImplBaseWeakPtr;
 typedef boost::shared_ptr<ProducerImplBase> ProducerImplBasePtr;
 
 class ProducerImplBase {
-public:
-  virtual ~ProducerImplBase(){
-  }
+   public:
+    virtual ~ProducerImplBase() {}
 
-  virtual const std::string& getProducerName() const = 0;
+    virtual const std::string& getProducerName() const = 0;
 
-  virtual int64_t getLastSequenceId() const = 0;
+    virtual int64_t getLastSequenceId() const = 0;
 
-  virtual void sendAsync(const Message& msg, SendCallback callback) = 0;
-  virtual void closeAsync(CloseCallback callback) = 0;
-  virtual void start() = 0;
-  virtual void shutdown() = 0;
-  virtual bool isClosed() = 0;
-  virtual const std::string& getTopic() const = 0;
-  virtual Future<Result, ProducerImplBaseWeakPtr> getProducerCreatedFuture() = 0;
+    virtual void sendAsync(const Message& msg, SendCallback callback) = 0;
+    virtual void closeAsync(CloseCallback callback) = 0;
+    virtual void start() = 0;
+    virtual void shutdown() = 0;
+    virtual bool isClosed() = 0;
+    virtual const std::string& getTopic() const = 0;
+    virtual Future<Result, ProducerImplBaseWeakPtr> getProducerCreatedFuture() = 0;
 };
 }
-#endif //PULSAR_PRODUCER_IMPL_BASE_HEADER
+#endif  // PULSAR_PRODUCER_IMPL_BASE_HEADER
diff --git a/pulsar-client-cpp/lib/Reader.cc b/pulsar-client-cpp/lib/Reader.cc
index b3229416e..2d4a761e9 100644
--- a/pulsar-client-cpp/lib/Reader.cc
+++ b/pulsar-client-cpp/lib/Reader.cc
@@ -27,17 +27,11 @@ namespace pulsar {
 
 static const std::string EMPTY_STRING;
 
-Reader::Reader() :
-        impl_() {
-}
+Reader::Reader() : impl_() {}
 
-Reader::Reader(ReaderImplPtr impl) :
-        impl_(impl) {
-}
+Reader::Reader(ReaderImplPtr impl) : impl_(impl) {}
 
-const std::string& Reader::getTopic() const {
-    return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING;
-}
+const std::string& Reader::getTopic() const { return impl_ != NULL ? impl_->getTopic() : EMPTY_STRING; }
 
 Result Reader::readNext(Message& msg) {
     if (!impl_) {
@@ -72,5 +66,4 @@ void Reader::closeAsync(ResultCallback callback) {
 
     impl_->closeAsync(callback);
 }
-
 }
diff --git a/pulsar-client-cpp/lib/ReaderConfiguration.cc b/pulsar-client-cpp/lib/ReaderConfiguration.cc
index 6f39bc701..871a3e078 100644
--- a/pulsar-client-cpp/lib/ReaderConfiguration.cc
+++ b/pulsar-client-cpp/lib/ReaderConfiguration.cc
@@ -20,16 +20,11 @@
 
 namespace pulsar {
 
-ReaderConfiguration::ReaderConfiguration()
-        : impl_(boost::make_shared<ReaderConfigurationImpl>()) {
-}
+ReaderConfiguration::ReaderConfiguration() : impl_(boost::make_shared<ReaderConfigurationImpl>()) {}
 
-ReaderConfiguration::~ReaderConfiguration() {
-}
+ReaderConfiguration::~ReaderConfiguration() {}
 
-ReaderConfiguration::ReaderConfiguration(const ReaderConfiguration& x)
-    : impl_(x.impl_) {
-}
+ReaderConfiguration::ReaderConfiguration(const ReaderConfiguration& x) : impl_(x.impl_) {}
 
 ReaderConfiguration& ReaderConfiguration::operator=(const ReaderConfiguration& x) {
     impl_ = x.impl_;
@@ -42,27 +37,15 @@ ReaderConfiguration& ReaderConfiguration::setReaderListener(ReaderListener reade
     return *this;
 }
 
-ReaderListener ReaderConfiguration::getReaderListener() const {
-    return impl_->readerListener;
-}
+ReaderListener ReaderConfiguration::getReaderListener() const { return impl_->readerListener; }
 
-bool ReaderConfiguration::hasReaderListener() const {
-    return impl_->hasReaderListener;
-}
+bool ReaderConfiguration::hasReaderListener() const { return impl_->hasReaderListener; }
 
-void ReaderConfiguration::setReceiverQueueSize(int size) {
-    impl_->receiverQueueSize = size;
-}
+void ReaderConfiguration::setReceiverQueueSize(int size) { impl_->receiverQueueSize = size; }
 
-int ReaderConfiguration::getReceiverQueueSize() const {
-    return impl_->receiverQueueSize;
-}
+int ReaderConfiguration::getReceiverQueueSize() const { return impl_->receiverQueueSize; }
 
-const std::string& ReaderConfiguration::getReaderName() const {
-    return impl_->readerName;
-}
+const std::string& ReaderConfiguration::getReaderName() const { return impl_->readerName; }
 
-void ReaderConfiguration::setReaderName(const std::string& readerName) {
-    impl_->readerName = readerName;
-}
+void ReaderConfiguration::setReaderName(const std::string& readerName) { impl_->readerName = readerName; }
 }
diff --git a/pulsar-client-cpp/lib/ReaderConfigurationImpl.h b/pulsar-client-cpp/lib/ReaderConfigurationImpl.h
index e6249fbdd..d5d9d4aa8 100644
--- a/pulsar-client-cpp/lib/ReaderConfigurationImpl.h
+++ b/pulsar-client-cpp/lib/ReaderConfigurationImpl.h
@@ -28,11 +28,7 @@ struct ReaderConfigurationImpl {
     bool hasReaderListener;
     int receiverQueueSize;
     std::string readerName;
-    ReaderConfigurationImpl()
-            : hasReaderListener(false),
-              receiverQueueSize(1000),
-              readerName() {
-    }
+    ReaderConfigurationImpl() : hasReaderListener(false), receiverQueueSize(1000), readerName() {}
 };
 }
 #endif /* LIB_READERCONFIGURATIONIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/ReaderImpl.cc b/pulsar-client-cpp/lib/ReaderImpl.cc
index 12eaf4c30..cf8cc1bf7 100644
--- a/pulsar-client-cpp/lib/ReaderImpl.cc
+++ b/pulsar-client-cpp/lib/ReaderImpl.cc
@@ -24,14 +24,9 @@ namespace pulsar {
 
 static ResultCallback emptyCallback;
 
-ReaderImpl::ReaderImpl(const ClientImplPtr client, const std::string& topic,
-                       const ReaderConfiguration& conf, const ExecutorServicePtr listenerExecutor,
-                       ReaderCallback readerCreatedCallback) :
-                topic_(topic),
-                    client_(client),
-                    readerConf_(conf),
-                    readerCreatedCallback_(readerCreatedCallback) {
-}
+ReaderImpl::ReaderImpl(const ClientImplPtr client, const std::string& topic, const ReaderConfiguration& conf,
+                       const ExecutorServicePtr listenerExecutor, ReaderCallback readerCreatedCallback)
+    : topic_(topic), client_(client), readerConf_(conf), readerCreatedCallback_(readerCreatedCallback) {}
 
 void ReaderImpl::start(const BatchMessageId& startMessageId) {
     ConsumerConfiguration consumerConf;
@@ -45,32 +40,27 @@ void ReaderImpl::start(const BatchMessageId& startMessageId) {
     if (readerConf_.hasReaderListener()) {
         // Adapt the message listener to be a reader-listener
         readerListener_ = readerConf_.getReaderListener();
-        consumerConf.setMessageListener(boost::bind(&ReaderImpl::messageListener,
-                                                    shared_from_this(), _1, _2));
+        consumerConf.setMessageListener(
+            boost::bind(&ReaderImpl::messageListener, shared_from_this(), _1, _2));
     }
 
     std::string subscription = "reader-" + generateRandomName();
 
-    consumer_ = boost::make_shared<ConsumerImpl>(client_.lock(), topic_, subscription, consumerConf,
-                                                 ExecutorServicePtr(), NonPartitioned,
-                                                 Commands::SubscriptionModeNonDurable,
-                                                 Optional<BatchMessageId>::of(startMessageId));
+    consumer_ = boost::make_shared<ConsumerImpl>(
+        client_.lock(), topic_, subscription, consumerConf, ExecutorServicePtr(), NonPartitioned,
+        Commands::SubscriptionModeNonDurable, Optional<BatchMessageId>::of(startMessageId));
     consumer_->getConsumerCreatedFuture().addListener(
-            boost::bind(&ReaderImpl::handleConsumerCreated, shared_from_this(), _1, _2));
+        boost::bind(&ReaderImpl::handleConsumerCreated, shared_from_this(), _1, _2));
     consumer_->start();
 }
 
-const std::string& ReaderImpl::getTopic() const {
-    return consumer_->getTopic();
-}
+const std::string& ReaderImpl::getTopic() const { return consumer_->getTopic(); }
 
 void ReaderImpl::handleConsumerCreated(Result result, ConsumerImplBaseWeakPtr consumer) {
     readerCreatedCallback_(result, Reader(shared_from_this()));
 }
 
-ConsumerImplPtr ReaderImpl::getConsumer() {
-    return consumer_;
-}
+ConsumerImplPtr ReaderImpl::getConsumer() { return consumer_; }
 
 Result ReaderImpl::readNext(Message& msg) {
     Result res = consumer_->receive(msg);
@@ -104,8 +94,5 @@ void ReaderImpl::acknowledgeIfNecessary(Result result, const Message& msg) {
     }
 }
 
-void ReaderImpl::closeAsync(ResultCallback callback) {
-    consumer_->closeAsync(callback);
-}
-
+void ReaderImpl::closeAsync(ResultCallback callback) { consumer_->closeAsync(callback); }
 }
diff --git a/pulsar-client-cpp/lib/ReaderImpl.h b/pulsar-client-cpp/lib/ReaderImpl.h
index 679e04f0a..60978fb05 100644
--- a/pulsar-client-cpp/lib/ReaderImpl.h
+++ b/pulsar-client-cpp/lib/ReaderImpl.h
@@ -31,12 +31,10 @@ class ReaderImpl;
 typedef boost::shared_ptr<ReaderImpl> ReaderImplPtr;
 typedef boost::weak_ptr<ReaderImpl> ReaderImplWeakPtr;
 
-class ReaderImpl: public boost::enable_shared_from_this<ReaderImpl> {
-public:
-    ReaderImpl(const ClientImplPtr client, const std::string& topic,
-               const ReaderConfiguration& conf,
-               const ExecutorServicePtr listenerExecutor,
-               ReaderCallback readerCreatedCallback);
+class ReaderImpl : public boost::enable_shared_from_this<ReaderImpl> {
+   public:
+    ReaderImpl(const ClientImplPtr client, const std::string& topic, const ReaderConfiguration& conf,
+               const ExecutorServicePtr listenerExecutor, ReaderCallback readerCreatedCallback);
 
     void start(const BatchMessageId& startMessageId);
 
@@ -51,7 +49,7 @@ class ReaderImpl: public boost::enable_shared_from_this<ReaderImpl> {
 
     ConsumerImplPtr getConsumer();
 
-private:
+   private:
     void handleConsumerCreated(Result result, ConsumerImplBaseWeakPtr consumer);
 
     void messageListener(Consumer consumer, const Message& msg);
@@ -65,7 +63,6 @@ class ReaderImpl: public boost::enable_shared_from_this<ReaderImpl> {
     ReaderCallback readerCreatedCallback_;
     ReaderListener readerListener_;
 };
-
 }
 
 #endif /* LIB_READERIMPL_H_ */
diff --git a/pulsar-client-cpp/lib/Result.cc b/pulsar-client-cpp/lib/Result.cc
index e58beb9fb..c988f0169 100644
--- a/pulsar-client-cpp/lib/Result.cc
+++ b/pulsar-client-cpp/lib/Result.cc
@@ -128,8 +128,6 @@ const char* pulsar::strResult(Result result) {
 
 #pragma GCC visibility push(default)
 
-std::ostream& operator<<(std::ostream& s, Result result) {
-    return s << strResult(result);
-}
+std::ostream& operator<<(std::ostream& s, Result result) { return s << strResult(result); }
 
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/lib/RoundRobinMessageRouter.cc b/pulsar-client-cpp/lib/RoundRobinMessageRouter.cc
index c4dceffe8..3ce3ea091 100644
--- a/pulsar-client-cpp/lib/RoundRobinMessageRouter.cc
+++ b/pulsar-client-cpp/lib/RoundRobinMessageRouter.cc
@@ -19,23 +19,20 @@
 #include "RoundRobinMessageRouter.h"
 
 namespace pulsar {
-    RoundRobinMessageRouter::RoundRobinMessageRouter():prevPartition_(0) {
-    }
+RoundRobinMessageRouter::RoundRobinMessageRouter() : prevPartition_(0) {}
 
-    RoundRobinMessageRouter::~RoundRobinMessageRouter() {
-    }
+RoundRobinMessageRouter::~RoundRobinMessageRouter() {}
 
-    //override
-    int RoundRobinMessageRouter::getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
-        //if message has a key, hash the key and return the partition
-        if (msg.hasPartitionKey()) {
-            static StringHash hash;
-            return hash(msg.getPartitionKey()) % topicMetadata.getNumPartitions();
-        } else {
-            Lock lock(mutex_);
-            //else pick the next partition
-            return prevPartition_++ % topicMetadata.getNumPartitions();
-        }
+// override
+int RoundRobinMessageRouter::getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
+    // if message has a key, hash the key and return the partition
+    if (msg.hasPartitionKey()) {
+        static StringHash hash;
+        return hash(msg.getPartitionKey()) % topicMetadata.getNumPartitions();
+    } else {
+        Lock lock(mutex_);
+        // else pick the next partition
+        return prevPartition_++ % topicMetadata.getNumPartitions();
     }
-
+}
 }
diff --git a/pulsar-client-cpp/lib/RoundRobinMessageRouter.h b/pulsar-client-cpp/lib/RoundRobinMessageRouter.h
index 06c56e0f6..7be971ca5 100644
--- a/pulsar-client-cpp/lib/RoundRobinMessageRouter.h
+++ b/pulsar-client-cpp/lib/RoundRobinMessageRouter.h
@@ -25,16 +25,17 @@
 #include <boost/thread/mutex.hpp>
 
 namespace pulsar {
-    class RoundRobinMessageRouter : public MessageRoutingPolicy {
-    public:
-        RoundRobinMessageRouter ();
-        virtual ~RoundRobinMessageRouter();
-        virtual int getPartition(const Message& msg, const TopicMetadata& topicMetadata);
-    private:
-        boost::mutex mutex_;
-        unsigned int prevPartition_;
-    };
-    typedef boost::hash<std::string> StringHash;
-    typedef boost::unique_lock<boost::mutex> Lock;
+class RoundRobinMessageRouter : public MessageRoutingPolicy {
+   public:
+    RoundRobinMessageRouter();
+    virtual ~RoundRobinMessageRouter();
+    virtual int getPartition(const Message& msg, const TopicMetadata& topicMetadata);
+
+   private:
+    boost::mutex mutex_;
+    unsigned int prevPartition_;
+};
+typedef boost::hash<std::string> StringHash;
+typedef boost::unique_lock<boost::mutex> Lock;
 }
-#endif // PULSAR_RR_MESSAGE_ROUTER_HEADER_
+#endif  // PULSAR_RR_MESSAGE_ROUTER_HEADER_
diff --git a/pulsar-client-cpp/lib/ServiceUnitId.h b/pulsar-client-cpp/lib/ServiceUnitId.h
index 760b8b07d..86ea31c0b 100644
--- a/pulsar-client-cpp/lib/ServiceUnitId.h
+++ b/pulsar-client-cpp/lib/ServiceUnitId.h
@@ -23,9 +23,8 @@
 #include <boost/shared_ptr.hpp>
 
 class ServiceUnitId {
- public:
-    virtual ~ServiceUnitId() {
-    }
+   public:
+    virtual ~ServiceUnitId() {}
 };
 
 #endif
diff --git a/pulsar-client-cpp/lib/SharedBuffer.h b/pulsar-client-cpp/lib/SharedBuffer.h
index 898ec38f1..e8573eed1 100644
--- a/pulsar-client-cpp/lib/SharedBuffer.h
+++ b/pulsar-client-cpp/lib/SharedBuffer.h
@@ -30,43 +30,25 @@ namespace pulsar {
 namespace detail {
 
 class SharedBufferInternal : public std::vector<char> {
- public:
-    SharedBufferInternal(int size)
-            : std::vector<char>(size) {
-    }
+   public:
+    SharedBufferInternal(int size) : std::vector<char>(size) {}
 
-    inline char* ptr() {
-        return &(*this)[0];
-    }
+    inline char* ptr() { return &(*this)[0]; }
 
-    void resize(int newSize) {
-        std::vector<char>::resize(newSize);
-    }
+    void resize(int newSize) { std::vector<char>::resize(newSize); }
 
-    int capacity() const {
-        return std::vector<char>::capacity();
-    }
+    int capacity() const { return std::vector<char>::capacity(); }
 };
-
 }
 
 class SharedBuffer {
- public:
-
-    explicit SharedBuffer()
-            : data_(),
-              ptr_(0),
-              readIdx_(0),
-              writeIdx_(0),
-              capacity_(0) {
-    }
+   public:
+    explicit SharedBuffer() : data_(), ptr_(0), readIdx_(0), writeIdx_(0), capacity_(0) {}
 
     /**
      * Allocate a buffer of given size
      */
-    static SharedBuffer allocate(const uint32_t size) {
-        return SharedBuffer(size);
-    }
+    static SharedBuffer allocate(const uint32_t size) { return SharedBuffer(size); }
 
     /**
      * Create a buffer with a copy of memory pointed by ptr
@@ -87,17 +69,11 @@ class SharedBuffer {
     /**
      * Create a buffer that wraps the passed pointer, without copying the memory
      */
-    static SharedBuffer wrap(char* ptr, size_t size) {
-        return SharedBuffer(ptr, size);
-    }
+    static SharedBuffer wrap(char* ptr, size_t size) { return SharedBuffer(ptr, size); }
 
-    inline const char* data() const {
-        return ptr_ + readIdx_;
-    }
+    inline const char* data() const { return ptr_ + readIdx_; }
 
-    inline char* mutableData() {
-        return ptr_ + writeIdx_;
-    }
+    inline char* mutableData() { return ptr_ + writeIdx_; }
 
     /**
      * Return a shared buffer that include a portion of current buffer. No memory is copied
@@ -118,45 +94,37 @@ class SharedBuffer {
 
     uint32_t readUnsignedInt() {
         assert(readableBytes() >= sizeof(uint32_t));
-        uint32_t value = ntohl(*(uint32_t* ) data());
+        uint32_t value = ntohl(*(uint32_t*)data());
         consume(sizeof(uint32_t));
         return value;
     }
 
     uint16_t readUnsignedShort() {
         assert(readableBytes() >= sizeof(uint16_t));
-        uint16_t value = ntohs(*(uint16_t* ) data());
+        uint16_t value = ntohs(*(uint16_t*)data());
         consume(sizeof(uint16_t));
         return value;
     }
 
     void writeUnsignedInt(uint32_t value) {
         assert(writableBytes() >= sizeof(uint32_t));
-        *(uint32_t*) (mutableData()) = htonl(value);
+        *(uint32_t*)(mutableData()) = htonl(value);
         bytesWritten(sizeof(value));
     }
 
     void writeUnsignedShort(uint16_t value) {
         assert(writableBytes() >= sizeof(uint16_t));
-        *(uint16_t*) (mutableData()) = htons(value);
+        *(uint16_t*)(mutableData()) = htons(value);
         bytesWritten(sizeof(value));
     }
 
-    inline uint32_t readableBytes() const {
-        return writeIdx_ - readIdx_;
-    }
+    inline uint32_t readableBytes() const { return writeIdx_ - readIdx_; }
 
-    inline uint32_t writableBytes() const {
-        return capacity_ - writeIdx_;
-    }
+    inline uint32_t writableBytes() const { return capacity_ - writeIdx_; }
 
-    inline bool readable() const {
-        return readableBytes() > 0;
-    }
+    inline bool readable() const { return readableBytes() > 0; }
 
-    inline bool writable() const {
-        return writableBytes() > 0;
-    }
+    inline bool writable() const { return writableBytes() > 0; }
 
     boost::asio::const_buffers_1 const_asio_buffer() const {
         return boost::asio::const_buffers_1(ptr_ + readIdx_, readableBytes());
@@ -181,9 +149,7 @@ class SharedBuffer {
     }
 
     // Return current writer index
-    uint32_t writerIndex() {
-        return writeIdx_;
-    }
+    uint32_t writerIndex() { return writeIdx_; }
 
     // skip writerIndex
     void skipBytes(uint32_t size) {
@@ -198,9 +164,7 @@ class SharedBuffer {
     }
 
     // Return current reader index
-    uint32_t readerIndex() {
-        return readIdx_;
-    }
+    uint32_t readerIndex() { return readIdx_; }
 
     // set readerIndex
     void setReaderIndex(uint32_t index) {
@@ -223,8 +187,7 @@ class SharedBuffer {
         writeIdx_ = 0;
     }
 
- private:
-
+   private:
     typedef boost::shared_ptr<detail::SharedBufferInternal> BufferPtr;
 
     BufferPtr data_;
@@ -233,28 +196,20 @@ class SharedBuffer {
     uint32_t writeIdx_;
     uint32_t capacity_;
 
-    SharedBuffer(char *ptr, size_t size)
-            : data_(),
-              ptr_(ptr),
-              readIdx_(0),
-              writeIdx_(size),
-              capacity_(size) {
-    }
+    SharedBuffer(char* ptr, size_t size)
+        : data_(), ptr_(ptr), readIdx_(0), writeIdx_(size), capacity_(size) {}
 
     explicit SharedBuffer(size_t size)
-            : data_(boost::make_shared<detail::SharedBufferInternal>(size)),
-              ptr_(data_->ptr()),
-              readIdx_(0),
-              writeIdx_(0),
-              capacity_(size) {
-    }
-
+        : data_(boost::make_shared<detail::SharedBufferInternal>(size)),
+          ptr_(data_->ptr()),
+          readIdx_(0),
+          writeIdx_(0),
+          capacity_(size) {}
 };
 
-template<int Size>
+template <int Size>
 class CompositeSharedBuffer {
- public:
-
+   public:
     void set(int idx, const SharedBuffer& buffer) {
         sharedBuffers_[idx] = buffer;
         asioBuffers_[idx] = buffer.const_asio_buffer();
@@ -265,21 +220,16 @@ class CompositeSharedBuffer {
     typedef boost::asio::const_buffer* iterator;
     typedef const boost::asio::const_buffer* const_iterator;
 
-    const boost::asio::const_buffer* begin() const {
-        return &(asioBuffers_.at(0));
-    }
+    const boost::asio::const_buffer* begin() const { return &(asioBuffers_.at(0)); }
 
-    const boost::asio::const_buffer* end() const {
-        return begin() + Size;
-    }
+    const boost::asio::const_buffer* end() const { return begin() + Size; }
 
- private:
+   private:
     boost::array<SharedBuffer, Size> sharedBuffers_;
     boost::array<boost::asio::const_buffer, Size> asioBuffers_;
 };
 
 typedef CompositeSharedBuffer<2> PairSharedBuffer;
-
 }
 
 #endif /* LIB_SHARED_BUFFER_H_ */
diff --git a/pulsar-client-cpp/lib/SinglePartitionMessageRouter.cc b/pulsar-client-cpp/lib/SinglePartitionMessageRouter.cc
index a83b9f37d..9d59b82b5 100644
--- a/pulsar-client-cpp/lib/SinglePartitionMessageRouter.cc
+++ b/pulsar-client-cpp/lib/SinglePartitionMessageRouter.cc
@@ -19,20 +19,20 @@
 #include "SinglePartitionMessageRouter.h"
 
 namespace pulsar {
-    SinglePartitionMessageRouter::~SinglePartitionMessageRouter(){}
-    SinglePartitionMessageRouter::SinglePartitionMessageRouter(const int partitionIndex) {
-        selectedSinglePartition_ = partitionIndex;
-    }
+SinglePartitionMessageRouter::~SinglePartitionMessageRouter() {}
+SinglePartitionMessageRouter::SinglePartitionMessageRouter(const int partitionIndex) {
+    selectedSinglePartition_ = partitionIndex;
+}
 
-    //override
-    int SinglePartitionMessageRouter::getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
-        //if message has a key, hash the key and return the partition
-        if (msg.hasPartitionKey()) {
-            StringHash hash;
-            return hash(msg.getPartitionKey()) % topicMetadata.getNumPartitions();
-        } else {
-            //else pick the next partition
-            return selectedSinglePartition_;
-        }
+// override
+int SinglePartitionMessageRouter::getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
+    // if message has a key, hash the key and return the partition
+    if (msg.hasPartitionKey()) {
+        StringHash hash;
+        return hash(msg.getPartitionKey()) % topicMetadata.getNumPartitions();
+    } else {
+        // else pick the next partition
+        return selectedSinglePartition_;
     }
 }
+}
diff --git a/pulsar-client-cpp/lib/SinglePartitionMessageRouter.h b/pulsar-client-cpp/lib/SinglePartitionMessageRouter.h
index 833eac69a..c5e547ecb 100644
--- a/pulsar-client-cpp/lib/SinglePartitionMessageRouter.h
+++ b/pulsar-client-cpp/lib/SinglePartitionMessageRouter.h
@@ -25,15 +25,15 @@
 
 namespace pulsar {
 
-    class SinglePartitionMessageRouter : public MessageRoutingPolicy {
-  public:
-		explicit SinglePartitionMessageRouter(int partitionIndex);
-        typedef boost::hash<std::string> StringHash;
-        virtual ~SinglePartitionMessageRouter();
-        virtual int getPartition(const Message& msg, const TopicMetadata& topicMetadata);
-    private:
-	int selectedSinglePartition_;
-    };
+class SinglePartitionMessageRouter : public MessageRoutingPolicy {
+   public:
+    explicit SinglePartitionMessageRouter(int partitionIndex);
+    typedef boost::hash<std::string> StringHash;
+    virtual ~SinglePartitionMessageRouter();
+    virtual int getPartition(const Message& msg, const TopicMetadata& topicMetadata);
 
+   private:
+    int selectedSinglePartition_;
+};
 }
-#endif // PULSAR_SINGLE_PARTITION_MESSAGE_ROUTER_HEADER_
+#endif  // PULSAR_SINGLE_PARTITION_MESSAGE_ROUTER_HEADER_
diff --git a/pulsar-client-cpp/lib/TopicMetadataImpl.cc b/pulsar-client-cpp/lib/TopicMetadataImpl.cc
index c48e4cf86..aad4681eb 100644
--- a/pulsar-client-cpp/lib/TopicMetadataImpl.cc
+++ b/pulsar-client-cpp/lib/TopicMetadataImpl.cc
@@ -20,11 +20,7 @@
 #include "TopicMetadataImpl.h"
 
 namespace pulsar {
-    TopicMetadataImpl::TopicMetadataImpl(const int numPartitions) : numPartitions_(numPartitions) {
+TopicMetadataImpl::TopicMetadataImpl(const int numPartitions) : numPartitions_(numPartitions) {}
 
-    }
-
-    int TopicMetadataImpl::getNumPartitions() const {
-        return numPartitions_;
-    }
+int TopicMetadataImpl::getNumPartitions() const { return numPartitions_; }
 }
\ No newline at end of file
diff --git a/pulsar-client-cpp/lib/TopicMetadataImpl.h b/pulsar-client-cpp/lib/TopicMetadataImpl.h
index 2734cf3a8..ec9370ecc 100644
--- a/pulsar-client-cpp/lib/TopicMetadataImpl.h
+++ b/pulsar-client-cpp/lib/TopicMetadataImpl.h
@@ -23,11 +23,11 @@
 
 namespace pulsar {
 class TopicMetadataImpl : public TopicMetadata {
-public:
+   public:
     TopicMetadataImpl(const int numPartitions);
     virtual int getNumPartitions() const;
 
-private:
+   private:
     int numPartitions_;
 };
 }
diff --git a/pulsar-client-cpp/lib/UnAckedMessageTrackerDisabled.h b/pulsar-client-cpp/lib/UnAckedMessageTrackerDisabled.h
index 639502673..568e88de3 100644
--- a/pulsar-client-cpp/lib/UnAckedMessageTrackerDisabled.h
+++ b/pulsar-client-cpp/lib/UnAckedMessageTrackerDisabled.h
@@ -22,19 +22,12 @@
 namespace pulsar {
 
 class UnAckedMessageTrackerDisabled : public UnAckedMessageTrackerInterface {
- public:
-    bool add(const MessageId& m) {
-        return false;
-    }
-    bool remove(const MessageId& m) {
-        return false;
-    }
-    void removeMessagesTill(const MessageId& msgId) {
-    }
+   public:
+    bool add(const MessageId& m) { return false; }
+    bool remove(const MessageId& m) { return false; }
+    void removeMessagesTill(const MessageId& msgId) {}
 
-    void clear() {
-    }
+    void clear() {}
 };
-
 }
 #endif /* LIB_UNACKEDMESSAGETRACKERDISABLED_H_ */
diff --git a/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc b/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc
index 884311f41..593060611 100644
--- a/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc
+++ b/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.cc
@@ -24,7 +24,7 @@ namespace pulsar {
 
 void UnAckedMessageTrackerEnabled::timeoutHandler(const boost::system::error_code& ec) {
     if (ec) {
-        LOG_DEBUG("Ignoring timer cancelled event, code[" << ec <<"]");
+        LOG_DEBUG("Ignoring timer cancelled event, code[" << ec << "]");
     } else {
         timeoutHandler();
     }
@@ -35,18 +35,17 @@ void UnAckedMessageTrackerEnabled::timeoutHandler() {
     ExecutorServicePtr executorService = client_->getIOExecutorProvider()->get();
     timer_ = executorService->createDeadlineTimer();
     timer_->expires_from_now(boost::posix_time::milliseconds(timeoutMs_));
-    timer_->async_wait(
-            boost::bind(&pulsar::UnAckedMessageTrackerEnabled::timeoutHandler, this,
-                        boost::asio::placeholders::error));
+    timer_->async_wait(boost::bind(&pulsar::UnAckedMessageTrackerEnabled::timeoutHandler, this,
+                                   boost::asio::placeholders::error));
 }
 
 void UnAckedMessageTrackerEnabled::timeoutHandlerHelper() {
     boost::unique_lock<boost::mutex> acquire(lock_);
-    LOG_DEBUG(
-            "UnAckedMessageTrackerEnabled::timeoutHandlerHelper invoked for consumerPtr_ " << consumerReference_.getName().c_str());
+    LOG_DEBUG("UnAckedMessageTrackerEnabled::timeoutHandlerHelper invoked for consumerPtr_ "
+              << consumerReference_.getName().c_str());
     if (!oldSet_.empty()) {
-        LOG_INFO(
-                consumerReference_.getName().c_str() << ": " << oldSet_.size() << " Messages were not acked within "<< timeoutMs_ <<" time");
+        LOG_INFO(consumerReference_.getName().c_str()
+                 << ": " << oldSet_.size() << " Messages were not acked within " << timeoutMs_ << " time");
         oldSet_.clear();
         currentSet_.clear();
         consumerReference_.redeliverUnacknowledgedMessages();
@@ -54,10 +53,9 @@ void UnAckedMessageTrackerEnabled::timeoutHandlerHelper() {
     oldSet_.swap(currentSet_);
 }
 
-UnAckedMessageTrackerEnabled::UnAckedMessageTrackerEnabled(long timeoutMs,
-                                                           const ClientImplPtr client,
+UnAckedMessageTrackerEnabled::UnAckedMessageTrackerEnabled(long timeoutMs, const ClientImplPtr client,
                                                            ConsumerImplBase& consumer)
-        : consumerReference_(consumer) {
+    : consumerReference_(consumer) {
     timeoutMs_ = timeoutMs;
     client_ = client;
     timeoutHandler();
diff --git a/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.h b/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.h
index 7c6fa8a90..671bc1d7b 100644
--- a/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.h
+++ b/pulsar-client-cpp/lib/UnAckedMessageTrackerEnabled.h
@@ -22,7 +22,7 @@
 namespace pulsar {
 
 class UnAckedMessageTrackerEnabled : public UnAckedMessageTrackerInterface {
- public:
+   public:
     ~UnAckedMessageTrackerEnabled();
     UnAckedMessageTrackerEnabled(long timeoutMs, const ClientImplPtr, ConsumerImplBase&);
     bool add(const MessageId& m);
@@ -31,7 +31,8 @@ class UnAckedMessageTrackerEnabled : public UnAckedMessageTrackerInterface {
     void timeoutHandler();
 
     void clear();
- private:
+
+   private:
     void timeoutHandler(const boost::system::error_code& ec);
     void timeoutHandlerHelper();
     bool isEmpty();
diff --git a/pulsar-client-cpp/lib/UnAckedMessageTrackerInterface.h b/pulsar-client-cpp/lib/UnAckedMessageTrackerInterface.h
index 4bebd2b6d..537c13165 100644
--- a/pulsar-client-cpp/lib/UnAckedMessageTrackerInterface.h
+++ b/pulsar-client-cpp/lib/UnAckedMessageTrackerInterface.h
@@ -37,18 +37,15 @@
 namespace pulsar {
 
 class UnAckedMessageTrackerInterface {
- public:
-    virtual ~UnAckedMessageTrackerInterface() {
-    }
-    UnAckedMessageTrackerInterface() {
-    }
+   public:
+    virtual ~UnAckedMessageTrackerInterface() {}
+    UnAckedMessageTrackerInterface() {}
     virtual bool add(const MessageId& m) = 0;
     virtual bool remove(const MessageId& m) = 0;
     virtual void removeMessagesTill(const MessageId& msgId) = 0;
     virtual void clear() = 0;
 };
 
-
 typedef boost::scoped_ptr<UnAckedMessageTrackerInterface> UnAckedMessageTrackerScopedPtr;
 }
 #endif /* LIB_UNACKEDMESSAGETRACKERINTERFACE_H_ */
diff --git a/pulsar-client-cpp/lib/UnboundedBlockingQueue.h b/pulsar-client-cpp/lib/UnboundedBlockingQueue.h
index 78e10a7fd..69325f027 100644
--- a/pulsar-client-cpp/lib/UnboundedBlockingQueue.h
+++ b/pulsar-client-cpp/lib/UnboundedBlockingQueue.h
@@ -25,17 +25,14 @@
 // For struct QueueNotEmpty
 #include "BlockingQueue.h"
 
-template<typename T>
+template <typename T>
 class UnboundedBlockingQueue {
- public:
+   public:
     typedef typename boost::circular_buffer<T> Container;
     typedef typename Container::iterator iterator;
     typedef typename Container::const_iterator const_iterator;
 
-    UnboundedBlockingQueue(size_t maxSize)
-            : mutex_(),
-              queue_(maxSize) {
-    }
+    UnboundedBlockingQueue(size_t maxSize) : mutex_(), queue_(maxSize) {}
 
     ~UnboundedBlockingQueue() {
         Lock lock(mutex_);
@@ -78,7 +75,7 @@ class UnboundedBlockingQueue {
     bool pop(T& value, const boost::posix_time::time_duration& timeout) {
         Lock lock(mutex_);
         if (!queueEmptyCondition_.timed_wait(lock, timeout,
-                                            QueueNotEmpty<UnboundedBlockingQueue<T> >(*this))) {
+                                             QueueNotEmpty<UnboundedBlockingQueue<T> >(*this))) {
             return false;
         }
 
@@ -128,34 +125,23 @@ class UnboundedBlockingQueue {
         return isEmptyNoMutex();
     }
 
-    const_iterator begin() const {
-        return queue_.begin();
-    }
+    const_iterator begin() const { return queue_.begin(); }
 
-    const_iterator end() const {
-        return queue_.end();
-    }
+    const_iterator end() const { return queue_.end(); }
 
-    iterator begin() {
-        return queue_.begin();
-    }
+    iterator begin() { return queue_.begin(); }
 
-    iterator end() {
-        return queue_.end();
-    }
-
- private:
+    iterator end() { return queue_.end(); }
 
-    bool isEmptyNoMutex() const {
-        return queue_.empty();
-    }
+   private:
+    bool isEmptyNoMutex() const { return queue_.empty(); }
 
     mutable boost::mutex mutex_;
     boost::condition_variable queueEmptyCondition_;
     Container queue_;
 
     typedef boost::unique_lock<boost::mutex> Lock;
-    friend struct QueueNotEmpty<UnboundedBlockingQueue<T> > ;
+    friend struct QueueNotEmpty<UnboundedBlockingQueue<T> >;
 };
 
 #endif /* LIB_BLOCKINGQUEUE_H_ */
diff --git a/pulsar-client-cpp/lib/Url.cc b/pulsar-client-cpp/lib/Url.cc
index 7c662723c..cde9db7a6 100644
--- a/pulsar-client-cpp/lib/Url.cc
+++ b/pulsar-client-cpp/lib/Url.cc
@@ -40,10 +40,10 @@ static const std::map<std::string, int>& defaultPortsMap() {
 bool Url::parse(const std::string& urlStr, Url& url) {
     std::vector<std::string> values;
     static const boost::regex expression(
-    //       proto                 host               port
-            "^(\?:([^:/\?#]+)://)\?(\\w+[^/\?#:]*)(\?::(\\d+))\?"
-            //       path                  file       parameters
-                    "(/\?(\?:[^\?#/]*/)*)\?([^\?#]*)\?(\\\?(.*))\?");
+        //       proto                 host               port
+        "^(\?:([^:/\?#]+)://)\?(\\w+[^/\?#:]*)(\?::(\\d+))\?"
+        //       path                  file       parameters
+        "(/\?(\?:[^\?#/]*/)*)\?([^\?#]*)\?(\\\?(.*))\?");
 
     boost::cmatch groups;
     if (!boost::regex_match(urlStr.c_str(), groups, expression)) {
@@ -74,38 +74,24 @@ bool Url::parse(const std::string& urlStr, Url& url) {
     return true;
 }
 
-const std::string& Url::protocol() const {
-    return protocol_;
-}
+const std::string& Url::protocol() const { return protocol_; }
 
-const std::string& Url::host() const {
-    return host_;
-}
+const std::string& Url::host() const { return host_; }
 
-const int Url::port() const {
-    return port_;
-}
+const int Url::port() const { return port_; }
 
-const std::string& Url::path() const {
-    return path_;
-}
+const std::string& Url::path() const { return path_; }
 
-const std::string& Url::pathWithoutFile() const {
-    return pathWithoutFile_;
-}
+const std::string& Url::pathWithoutFile() const { return pathWithoutFile_; }
 
-const std::string& Url::file() const {
-    return file_;
-}
+const std::string& Url::file() const { return file_; }
 
-const std::string& Url::parameter() const {
-    return parameter_;
-}
+const std::string& Url::parameter() const { return parameter_; }
 
-std::ostream & operator<<(std::ostream &os, const Url& obj) {
-    os << "Url [Host = " << obj.host() << ", Protocol = " << obj.protocol()
-       << ", Port = " << obj.port() << "]";
+std::ostream& operator<<(std::ostream& os, const Url& obj) {
+    os << "Url [Host = " << obj.host() << ", Protocol = " << obj.protocol() << ", Port = " << obj.port()
+       << "]";
     return os;
 }
 
-} // pulsar
+}  // pulsar
diff --git a/pulsar-client-cpp/lib/Url.h b/pulsar-client-cpp/lib/Url.h
index 676681c8f..5a310a218 100644
--- a/pulsar-client-cpp/lib/Url.h
+++ b/pulsar-client-cpp/lib/Url.h
@@ -29,7 +29,7 @@ namespace pulsar {
  * URL parsing utility
  */
 class Url {
-public:
+   public:
     static bool parse(const std::string& urlStr, Url& url);
 
     const std::string& protocol() const;
@@ -39,8 +39,9 @@ class Url {
     const std::string& pathWithoutFile() const;
     const std::string& file() const;
     const std::string& parameter() const;
-    friend std::ostream& operator<<(std::ostream &os, const Url& obj);
-private:
+    friend std::ostream& operator<<(std::ostream& os, const Url& obj);
+
+   private:
     std::string protocol_;
     std::string host_;
     int port_;
@@ -50,7 +51,7 @@ class Url {
     std::string parameter_;
 };
 
-} // pulsar
+}  // pulsar
 
 #pragma GCC visibility pop
 
diff --git a/pulsar-client-cpp/lib/UtilAllocator.h b/pulsar-client-cpp/lib/UtilAllocator.h
index 706b6f193..acd1414b9 100644
--- a/pulsar-client-cpp/lib/UtilAllocator.h
+++ b/pulsar-client-cpp/lib/UtilAllocator.h
@@ -22,10 +22,8 @@
 #include <boost/aligned_storage.hpp>
 
 class HandlerAllocator : private boost::noncopyable {
- public:
-    HandlerAllocator()
-            : inUse_(false) {
-    }
+   public:
+    HandlerAllocator() : inUse_(false) {}
 
     void* allocate(std::size_t size) {
         if (!inUse_ && size < storage_.size) {
@@ -44,26 +42,23 @@ class HandlerAllocator : private boost::noncopyable {
         }
     }
 
- private:
+   private:
     // Storage space used for handler-based custom memory allocation.
     boost::aligned_storage<1024> storage_;
     bool inUse_;
 };
 
-template<typename Handler>
+template <typename Handler>
 class AllocHandler {
- public:
-    AllocHandler(HandlerAllocator& a, Handler h)
-            : allocator_(a),
-              handler_(h) {
-    }
+   public:
+    AllocHandler(HandlerAllocator& a, Handler h) : allocator_(a), handler_(h) {}
 
-    template<typename Arg1>
+    template <typename Arg1>
     void operator()(Arg1 arg1) {
         handler_(arg1);
     }
 
-    template<typename Arg1, typename Arg2>
+    template <typename Arg1, typename Arg2>
     void operator()(Arg1 arg1, Arg2 arg2) {
         handler_(arg1, arg2);
     }
@@ -72,12 +67,11 @@ class AllocHandler {
         return thisHandler->allocator_.allocate(size);
     }
 
-    friend void asio_handler_deallocate(void* ptr, std::size_t,
-                                        AllocHandler<Handler>* thisHandler) {
+    friend void asio_handler_deallocate(void* ptr, std::size_t, AllocHandler<Handler>* thisHandler) {
         thisHandler->allocator_.deallocate(ptr);
     }
 
- private:
+   private:
     HandlerAllocator& allocator_;
     Handler handler_;
 };
diff --git a/pulsar-client-cpp/lib/Utils.h b/pulsar-client-cpp/lib/Utils.h
index e4399024c..fd278dc06 100644
--- a/pulsar-client-cpp/lib/Utils.h
+++ b/pulsar-client-cpp/lib/Utils.h
@@ -28,22 +28,16 @@ namespace pulsar {
 struct WaitForCallback {
     Promise<bool, Result>& m_promise;
 
-    WaitForCallback(Promise<bool, Result>& promise)
-            : m_promise(promise) {
-    }
+    WaitForCallback(Promise<bool, Result>& promise) : m_promise(promise) {}
 
-    void operator()(Result result) {
-        m_promise.setValue(result);
-    }
+    void operator()(Result result) { m_promise.setValue(result); }
 };
 
-template<typename T>
+template <typename T>
 struct WaitForCallbackValue {
-    Promise<Result, T> & m_promise;
+    Promise<Result, T>& m_promise;
 
-    WaitForCallbackValue(Promise<Result, T>& promise)
-            : m_promise(promise) {
-    }
+    WaitForCallbackValue(Promise<Result, T>& promise) : m_promise(promise) {}
 
     void operator()(Result result, const T& value) {
         if (result == ResultOk) {
@@ -54,20 +48,15 @@ struct WaitForCallbackValue {
     }
 };
 
-template<typename T>
+template <typename T>
 struct WaitForCallbackType {
     Promise<Result, T>& m_promise;
 
-    WaitForCallbackType(Promise<Result, T>& promise)
-            : m_promise(promise) {
-    }
+    WaitForCallbackType(Promise<Result, T>& promise) : m_promise(promise) {}
 
-    void operator()(T result) {
-        m_promise.setValue(result);
-    }
+    void operator()(T result) { m_promise.setValue(result); }
 };
 
-
 static std::ostream& operator<<(std::ostream& os, const std::map<Result, unsigned long>& m) {
     os << "{";
     for (std::map<Result, unsigned long>::const_iterator it = m.begin(); it != m.end(); it++) {
@@ -80,48 +69,33 @@ static std::ostream& operator<<(std::ostream& os, const std::map<Result, unsigne
 /**
  * Utility class that encloses an optional value
  */
-template<typename T>
+template <typename T>
 class Optional {
-public:
-    const T& value() const {
-        return value_;
-    }
+   public:
+    const T& value() const { return value_; }
 
-    bool is_present() const {
-        return present_;
-    }
+    bool is_present() const { return present_; }
 
-    bool is_empty() const {
-        return !present_;
-    }
+    bool is_empty() const { return !present_; }
 
     /**
      * Create an Optional with the bound value
      */
-    static Optional<T> of(const T& value) {
-        return Optional<T>(value);
-    }
+    static Optional<T> of(const T& value) { return Optional<T>(value); }
 
     /**
      * Create an empty optional
      */
-    static Optional<T> empty() {
-        return Optional<T>();
-    }
+    static Optional<T> empty() { return Optional<T>(); }
 
-    Optional() :
-            value_(), present_(false) {
-    }
+    Optional() : value_(), present_(false) {}
 
-private:
-    Optional(const T& value) :
-            value_(value), present_(true) {
-    }
+   private:
+    Optional(const T& value) : value_(value), present_(true) {}
 
     T value_;
     bool present_;
 };
-
 }
 
 #endif /* UTILS_HPP_ */
diff --git a/pulsar-client-cpp/lib/auth/AuthAthenz.cc b/pulsar-client-cpp/lib/auth/AuthAthenz.cc
index dd05a6597..77ff00146 100644
--- a/pulsar-client-cpp/lib/auth/AuthAthenz.cc
+++ b/pulsar-client-cpp/lib/auth/AuthAthenz.cc
@@ -38,84 +38,70 @@
 DECLARE_LOG_OBJECT()
 
 namespace pulsar {
-    AuthDataAthenz::AuthDataAthenz(ParamMap& params) {
-        ztsClient_ = boost::make_shared<ZTSClient>(boost::ref(params));
-        LOG_DEBUG("AuthDataAthenz is construted.")
-    }
-    
-    bool AuthDataAthenz::hasDataForHttp() {
-        return true;
-    }
-    
-    std::string AuthDataAthenz::getHttpHeaders() {
-        return ztsClient_->getHeader() + ": " + ztsClient_->getRoleToken();
-    }
-    
-    bool AuthDataAthenz::hasDataFromCommand() {
-        return true;
-    }
+AuthDataAthenz::AuthDataAthenz(ParamMap& params) {
+    ztsClient_ = boost::make_shared<ZTSClient>(boost::ref(params));
+    LOG_DEBUG("AuthDataAthenz is construted.")
+}
 
-    
-    std::string AuthDataAthenz::getCommandData() {
-        return ztsClient_->getRoleToken();
-    }
+bool AuthDataAthenz::hasDataForHttp() { return true; }
+
+std::string AuthDataAthenz::getHttpHeaders() {
+    return ztsClient_->getHeader() + ": " + ztsClient_->getRoleToken();
+}
 
-    AuthDataAthenz::~AuthDataAthenz() {
+bool AuthDataAthenz::hasDataFromCommand() { return true; }
 
-    }
+std::string AuthDataAthenz::getCommandData() { return ztsClient_->getRoleToken(); }
 
-    AuthAthenz::AuthAthenz(AuthenticationDataPtr& authDataAthenz) {
-        authDataAthenz_ = authDataAthenz;
-    }
+AuthDataAthenz::~AuthDataAthenz() {}
 
-    AuthAthenz::~AuthAthenz() {
-    }
-    
-    ParamMap parseAuthParamsString(const std::string& authParamsString) {
-        ParamMap params;
-        if(!authParamsString.empty()) {
-            Json::Value root;
-            Json::Reader reader;
-            if (reader.parse(authParamsString, root, false)) {
-                Json::Value::Members members = root.getMemberNames();
-                for (Json::Value::Members::iterator iter = members.begin(); iter != members.end(); iter++) {
-                    params[*iter] = root[*iter].asString();
-                }
-            } else {
-                LOG_ERROR("Invalid String Error: " << reader.getFormatedErrorMessages());
+AuthAthenz::AuthAthenz(AuthenticationDataPtr& authDataAthenz) { authDataAthenz_ = authDataAthenz; }
+
+AuthAthenz::~AuthAthenz() {}
+
+ParamMap parseAuthParamsString(const std::string& authParamsString) {
+    ParamMap params;
+    if (!authParamsString.empty()) {
+        Json::Value root;
+        Json::Reader reader;
+        if (reader.parse(authParamsString, root, false)) {
+            Json::Value::Members members = root.getMemberNames();
+            for (Json::Value::Members::iterator iter = members.begin(); iter != members.end(); iter++) {
+                params[*iter] = root[*iter].asString();
             }
+        } else {
+            LOG_ERROR("Invalid String Error: " << reader.getFormatedErrorMessages());
         }
-        return params;
-    }
-    
-    AuthenticationPtr AuthAthenz::create(const std::string& authParamsString) {
-        ParamMap params = parseAuthParamsString(authParamsString);
-        AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
-        return AuthenticationPtr(new AuthAthenz(authDataAthenz));
-    }
-    
-    AuthenticationPtr AuthAthenz::create(ParamMap& params) {
-        AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
-        return AuthenticationPtr(new AuthAthenz(authDataAthenz));
     }
+    return params;
+}
 
-    const std::string AuthAthenz::getAuthMethodName() const {
-        return "athenz";
-    }
+AuthenticationPtr AuthAthenz::create(const std::string& authParamsString) {
+    ParamMap params = parseAuthParamsString(authParamsString);
+    AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
+    return AuthenticationPtr(new AuthAthenz(authDataAthenz));
+}
 
-    Result AuthAthenz::getAuthData(AuthenticationDataPtr& authDataContent) const {
-        authDataContent = authDataAthenz_;
-        return ResultOk;
-    }
-    
-    extern "C" Authentication* create(const std::string& authParamsString) {
-        ParamMap params = parseAuthParamsString(authParamsString);
-        AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
-        return new AuthAthenz(authDataAthenz);
-    }
+AuthenticationPtr AuthAthenz::create(ParamMap& params) {
+    AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
+    return AuthenticationPtr(new AuthAthenz(authDataAthenz));
+}
 
-    extern "C" Authentication* createFromMap(ParamMap& params) {
-        AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
-        return new AuthAthenz(authDataAthenz);
-    }
+const std::string AuthAthenz::getAuthMethodName() const { return "athenz"; }
+
+Result AuthAthenz::getAuthData(AuthenticationDataPtr& authDataContent) const {
+    authDataContent = authDataAthenz_;
+    return ResultOk;
+}
+
+extern "C" Authentication* create(const std::string& authParamsString) {
+    ParamMap params = parseAuthParamsString(authParamsString);
+    AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
+    return new AuthAthenz(authDataAthenz);
+}
+
+extern "C" Authentication* createFromMap(ParamMap& params) {
+    AuthenticationDataPtr authDataAthenz = AuthenticationDataPtr(new AuthDataAthenz(params));
+    return new AuthAthenz(authDataAthenz);
+}
 }
diff --git a/pulsar-client-cpp/lib/auth/AuthAthenz.h b/pulsar-client-cpp/lib/auth/AuthAthenz.h
index dc983a2ce..b183f050b 100644
--- a/pulsar-client-cpp/lib/auth/AuthAthenz.h
+++ b/pulsar-client-cpp/lib/auth/AuthAthenz.h
@@ -26,32 +26,31 @@
 #include <string>
 
 namespace pulsar {
-    
-    class AuthDataAthenz : public AuthenticationDataProvider {
-        
-    public:
-        AuthDataAthenz(ParamMap& params);
-        bool hasDataForHttp();
-        std::string getHttpHeaders();
-        bool hasDataFromCommand();
-        std::string getCommandData();
-        ~AuthDataAthenz();
-    private:
-        boost::shared_ptr<ZTSClient> ztsClient_;
-    };
-    
-    class AuthAthenz : public Authentication {
-        
-    public:
-        AuthAthenz(AuthenticationDataPtr&);
-        ~AuthAthenz();
-        static AuthenticationPtr create(ParamMap& params);
-        static AuthenticationPtr create(const std::string& authParamsString);
-        const std::string getAuthMethodName() const;
-        Result getAuthData(AuthenticationDataPtr& authDataAthenz) const;
-    private:
-        AuthenticationDataPtr authDataAthenz_;
-    };
-    
+
+class AuthDataAthenz : public AuthenticationDataProvider {
+   public:
+    AuthDataAthenz(ParamMap& params);
+    bool hasDataForHttp();
+    std::string getHttpHeaders();
+    bool hasDataFromCommand();
+    std::string getCommandData();
+    ~AuthDataAthenz();
+
+   private:
+    boost::shared_ptr<ZTSClient> ztsClient_;
+};
+
+class AuthAthenz : public Authentication {
+   public:
+    AuthAthenz(AuthenticationDataPtr&);
+    ~AuthAthenz();
+    static AuthenticationPtr create(ParamMap& params);
+    static AuthenticationPtr create(const std::string& authParamsString);
+    const std::string getAuthMethodName() const;
+    Result getAuthData(AuthenticationDataPtr& authDataAthenz) const;
+
+   private:
+    AuthenticationDataPtr authDataAthenz_;
+};
 }
 #endif /* PULSAR_AUTH_ATHENZ_H_ */
diff --git a/pulsar-client-cpp/lib/auth/AuthTls.cc b/pulsar-client-cpp/lib/auth/AuthTls.cc
index 34ca7a3c6..8665872c6 100644
--- a/pulsar-client-cpp/lib/auth/AuthTls.cc
+++ b/pulsar-client-cpp/lib/auth/AuthTls.cc
@@ -19,50 +19,37 @@
 #include <lib/auth/AuthTls.h>
 
 namespace pulsar {
-    AuthDataTls::AuthDataTls(ParamMap& params) {
-        tlsCertificates_ = params["tlsCertFile"];
-        tlsPrivateKey_ = params["tlsKeyFile"];
-    }
-
-    AuthDataTls::~AuthDataTls() {
+AuthDataTls::AuthDataTls(ParamMap& params) {
+    tlsCertificates_ = params["tlsCertFile"];
+    tlsPrivateKey_ = params["tlsKeyFile"];
+}
 
-    }
+AuthDataTls::~AuthDataTls() {}
 
-    bool AuthDataTls::hasDataForTls() {
-        return true;
-    }
+bool AuthDataTls::hasDataForTls() { return true; }
 
-    std::string AuthDataTls::getTlsCertificates() {
-        return tlsCertificates_;
-    }
+std::string AuthDataTls::getTlsCertificates() { return tlsCertificates_; }
 
-    std::string AuthDataTls::getTlsPrivateKey() {
-        return tlsPrivateKey_;
-    }
+std::string AuthDataTls::getTlsPrivateKey() { return tlsPrivateKey_; }
 
-    AuthTls::AuthTls(AuthenticationDataPtr& authDataTls) {
-        authDataTls_ = authDataTls;
-    }
+AuthTls::AuthTls(AuthenticationDataPtr& authDataTls) { authDataTls_ = authDataTls; }
 
-    AuthTls::~AuthTls() {
-    }
+AuthTls::~AuthTls() {}
 
-    AuthenticationPtr AuthTls::create(ParamMap& params) {
-        AuthenticationDataPtr authDataTls = AuthenticationDataPtr(new AuthDataTls(params));
-        return AuthenticationPtr(new AuthTls(authDataTls));
-    }
+AuthenticationPtr AuthTls::create(ParamMap& params) {
+    AuthenticationDataPtr authDataTls = AuthenticationDataPtr(new AuthDataTls(params));
+    return AuthenticationPtr(new AuthTls(authDataTls));
+}
 
-    const std::string AuthTls::getAuthMethodName() const {
-        return "tls";
-    }
+const std::string AuthTls::getAuthMethodName() const { return "tls"; }
 
-    Result AuthTls::getAuthData(AuthenticationDataPtr& authDataContent) const {
-        authDataContent = authDataTls_;
-        return ResultOk;
-    }
+Result AuthTls::getAuthData(AuthenticationDataPtr& authDataContent) const {
+    authDataContent = authDataTls_;
+    return ResultOk;
+}
 
-    extern "C" Authentication* createFromMap(ParamMap& params) {
-        AuthenticationDataPtr authDataTls = AuthenticationDataPtr(new AuthDataTls(params));
-        return new AuthTls(authDataTls);
-    }
+extern "C" Authentication* createFromMap(ParamMap& params) {
+    AuthenticationDataPtr authDataTls = AuthenticationDataPtr(new AuthDataTls(params));
+    return new AuthTls(authDataTls);
+}
 }
diff --git a/pulsar-client-cpp/lib/auth/AuthTls.h b/pulsar-client-cpp/lib/auth/AuthTls.h
index 58ffb9fdb..d2cac1076 100644
--- a/pulsar-client-cpp/lib/auth/AuthTls.h
+++ b/pulsar-client-cpp/lib/auth/AuthTls.h
@@ -25,31 +25,30 @@
 #include <string>
 
 namespace pulsar {
-    
-    class AuthDataTls : public AuthenticationDataProvider {
-        
-    public:
-        AuthDataTls(ParamMap& params);
-        ~AuthDataTls();
-        bool hasDataForTls();
-        std::string getTlsCertificates();
-        std::string getTlsPrivateKey();
-    private:
-        std::string tlsCertificates_;
-        std::string tlsPrivateKey_;
-    };
-    
-    class AuthTls : public Authentication {
-        
-    public:
-        AuthTls(AuthenticationDataPtr&);
-        ~AuthTls();
-        static AuthenticationPtr create(ParamMap& params);
-        const std::string getAuthMethodName() const;
-        Result getAuthData(AuthenticationDataPtr& authDataTls) const;
-    private:
-        AuthenticationDataPtr authDataTls_;
-    };
-    
+
+class AuthDataTls : public AuthenticationDataProvider {
+   public:
+    AuthDataTls(ParamMap& params);
+    ~AuthDataTls();
+    bool hasDataForTls();
+    std::string getTlsCertificates();
+    std::string getTlsPrivateKey();
+
+   private:
+    std::string tlsCertificates_;
+    std::string tlsPrivateKey_;
+};
+
+class AuthTls : public Authentication {
+   public:
+    AuthTls(AuthenticationDataPtr&);
+    ~AuthTls();
+    static AuthenticationPtr create(ParamMap& params);
+    const std::string getAuthMethodName() const;
+    Result getAuthData(AuthenticationDataPtr& authDataTls) const;
+
+   private:
+    AuthenticationDataPtr authDataTls_;
+};
 }
 #endif /* PULSAR_AUTH_TLS_H_ */
diff --git a/pulsar-client-cpp/lib/auth/athenz/ZTSClient.cc b/pulsar-client-cpp/lib/auth/athenz/ZTSClient.cc
index da32baab7..843c2087f 100644
--- a/pulsar-client-cpp/lib/auth/athenz/ZTSClient.cc
+++ b/pulsar-client-cpp/lib/auth/athenz/ZTSClient.cc
@@ -39,303 +39,304 @@
 #include <boost/archive/iterators/base64_from_binary.hpp>
 #include <boost/archive/iterators/transform_width.hpp>
 
-
 DECLARE_LOG_OBJECT()
 
 namespace pulsar {
 
-    const static std::string DEFAULT_PRINCIPAL_HEADER = "Athenz-Principal-Auth";
-    const static std::string DEFAULT_ROLE_HEADER = "Athenz-Role-Auth";
-    const static int REQUEST_TIMEOUT = 10000;
-    const static int DEFAULT_TOKEN_EXPIRATION_TIME_SEC = 3600;
-    const static int MIN_TOKEN_EXPIRATION_TIME_SEC = 900;
-    const static int MAX_HTTP_REDIRECTS = 20;
-    const static long long FETCH_EPSILON = 60; // if cache expires in 60 seconds, get it from ZTS
-    const static std::string requiredParams[] = {"tenantDomain", "tenantService", "providerDomain", "privateKey", "ztsUrl"};
-
-    std::map<std::string, RoleToken> ZTSClient::roleTokenCache_;
-
-    ZTSClient::ZTSClient (std::map<std::string, std::string>& params) {
-        // required parameter check
-        bool valid = true;
-        for (int i = 0; i < sizeof(requiredParams) / sizeof(std::string) ; i++) {
-            if (params.find(requiredParams[i]) == params.end()) {
-                valid = false;
-                LOG_ERROR(requiredParams[i] << " parameter is required");
-            }
-        }
-
-        if (!valid) {
-            LOG_ERROR("Some parameters are missing")
-            return;
+const static std::string DEFAULT_PRINCIPAL_HEADER = "Athenz-Principal-Auth";
+const static std::string DEFAULT_ROLE_HEADER = "Athenz-Role-Auth";
+const static int REQUEST_TIMEOUT = 10000;
+const static int DEFAULT_TOKEN_EXPIRATION_TIME_SEC = 3600;
+const static int MIN_TOKEN_EXPIRATION_TIME_SEC = 900;
+const static int MAX_HTTP_REDIRECTS = 20;
+const static long long FETCH_EPSILON = 60;  // if cache expires in 60 seconds, get it from ZTS
+const static std::string requiredParams[] = {"tenantDomain", "tenantService", "providerDomain", "privateKey",
+                                             "ztsUrl"};
+
+std::map<std::string, RoleToken> ZTSClient::roleTokenCache_;
+
+ZTSClient::ZTSClient(std::map<std::string, std::string> &params) {
+    // required parameter check
+    bool valid = true;
+    for (int i = 0; i < sizeof(requiredParams) / sizeof(std::string); i++) {
+        if (params.find(requiredParams[i]) == params.end()) {
+            valid = false;
+            LOG_ERROR(requiredParams[i] << " parameter is required");
         }
+    }
 
-        // set required value
-        tenantDomain_   = params[requiredParams[0]];
-        tenantService_  = params[requiredParams[1]];
-        providerDomain_ = params[requiredParams[2]];
-        privateKeyUri_  = parseUri(params[requiredParams[3]].c_str());
-        ztsUrl_         = params[requiredParams[4]];
-
-        // set optional value
-        keyId_ = params.find("keyId") == params.end() ? "0" : params["keyId"];
-        principalHeader_ = params.find("principalHeader") == params.end() ? DEFAULT_PRINCIPAL_HEADER : params["principalHeader"];
-        roleHeader_ = params.find("roleHeader") == params.end() ? DEFAULT_ROLE_HEADER : params["roleHeader"];
-        tokenExpirationTime_ = DEFAULT_TOKEN_EXPIRATION_TIME_SEC;
-        if (params.find("tokenExpirationTime") != params.end()) {
-            tokenExpirationTime_ = boost::lexical_cast<int>(params["tokenExpirationTime"]);
-            if (tokenExpirationTime_ < MIN_TOKEN_EXPIRATION_TIME_SEC) {
-                LOG_WARN(tokenExpirationTime_ << " is too small as a token expiration time. " << MIN_TOKEN_EXPIRATION_TIME_SEC << " is set instead of it.");
-                tokenExpirationTime_ = MIN_TOKEN_EXPIRATION_TIME_SEC;
-            }
-        }
+    if (!valid) {
+        LOG_ERROR("Some parameters are missing")
+        return;
+    }
 
-        if (*(--ztsUrl_.end()) == '/') {
-            ztsUrl_.erase(--ztsUrl_.end());
+    // set required value
+    tenantDomain_ = params[requiredParams[0]];
+    tenantService_ = params[requiredParams[1]];
+    providerDomain_ = params[requiredParams[2]];
+    privateKeyUri_ = parseUri(params[requiredParams[3]].c_str());
+    ztsUrl_ = params[requiredParams[4]];
+
+    // set optional value
+    keyId_ = params.find("keyId") == params.end() ? "0" : params["keyId"];
+    principalHeader_ =
+        params.find("principalHeader") == params.end() ? DEFAULT_PRINCIPAL_HEADER : params["principalHeader"];
+    roleHeader_ = params.find("roleHeader") == params.end() ? DEFAULT_ROLE_HEADER : params["roleHeader"];
+    tokenExpirationTime_ = DEFAULT_TOKEN_EXPIRATION_TIME_SEC;
+    if (params.find("tokenExpirationTime") != params.end()) {
+        tokenExpirationTime_ = boost::lexical_cast<int>(params["tokenExpirationTime"]);
+        if (tokenExpirationTime_ < MIN_TOKEN_EXPIRATION_TIME_SEC) {
+            LOG_WARN(tokenExpirationTime_ << " is too small as a token expiration time. "
+                                          << MIN_TOKEN_EXPIRATION_TIME_SEC << " is set instead of it.");
+            tokenExpirationTime_ = MIN_TOKEN_EXPIRATION_TIME_SEC;
         }
+    }
 
-        LOG_DEBUG("ZTSClient is constructed properly")
+    if (*(--ztsUrl_.end()) == '/') {
+        ztsUrl_.erase(--ztsUrl_.end());
     }
 
-    ZTSClient::~ZTSClient() {
-        LOG_DEBUG("ZTSClient is destructed")
+    LOG_DEBUG("ZTSClient is constructed properly")
+}
+
+ZTSClient::~ZTSClient(){LOG_DEBUG("ZTSClient is destructed")}
+
+std::string ZTSClient::getSalt() {
+    unsigned long long salt = 0;
+    for (int i = 0; i < 8; i++) {
+        salt += ((unsigned long long)rand() % (1 << 8)) << 8 * i;
     }
+    std::stringstream ss;
+    ss << std::hex << salt;
+    return ss.str();
+}
 
-    std::string ZTSClient::getSalt() {
-        unsigned long long salt = 0;
-        for (int i = 0; i < 8; i++) {
-            salt += ( (unsigned long long) rand() % (1 << 8) ) << 8 * i;
+std::string ZTSClient::ybase64Encode(const unsigned char *input, int length) {
+    // base64 encode
+    typedef boost::archive::iterators::base64_from_binary<
+        boost::archive::iterators::transform_width<const unsigned char *, 6, 8> >
+        base64;
+    std::string ret = std::string(base64(input), base64(input + length));
+
+    // replace '+', '/' to '.', '_' for ybase64
+    for (std::string::iterator itr = ret.begin(); itr != ret.end(); itr++) {
+        switch (*itr) {
+            case '+':
+                ret.replace(itr, itr + 1, ".");
+                break;
+            case '/':
+                ret.replace(itr, itr + 1, "_");
+                break;
+            default:
+                break;
         }
-        std::stringstream ss;
-        ss << std::hex << salt;
-        return ss.str();
     }
 
-    std::string ZTSClient::ybase64Encode(const unsigned char *input, int length) {
-        // base64 encode
-        typedef boost::archive::iterators::base64_from_binary<boost::archive::iterators::transform_width<const unsigned char*, 6, 8> > base64;
-        std::string ret = std::string(base64(input), base64(input + length));
+    // padding by '-'
+    for (int i = 4 - ret.size() % 4; i; i--) {
+        ret.push_back('-');
+    }
+
+    return ret;
+}
 
-        // replace '+', '/' to '.', '_' for ybase64
-        for(std::string::iterator itr = ret.begin(); itr != ret.end(); itr++) {
-            switch (*itr) {
-                case '+':
-                    ret.replace(itr, itr+1, ".");
-                    break;
-                case '/':
-                    ret.replace(itr, itr+1, "_");
-                    break;
-                default:
-                    break;
-            }
-        }
+char *ZTSClient::base64Decode(const char *input) {
+    BIO *bio, *b64;
+    size_t length = strlen(input);
+    char *result = (char *)malloc(length);
 
-        // padding by '-'
-        for (int i = 4 - ret.size() % 4; i; i--) {
-            ret.push_back('-');
-        }
+    bio = BIO_new_mem_buf((void *)input, -1);
+    b64 = BIO_new(BIO_f_base64());
+    bio = BIO_push(b64, bio);
 
-        return ret;
-    }
+    BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
+    BIO_read(bio, result, length);
+    BIO_free_all(bio);
 
-    char* ZTSClient::base64Decode(const char* input) {
-        BIO *bio, *b64;
-        size_t length = strlen(input);
-        char *result = (char*)malloc(length);
+    return result;
+}
 
-        bio = BIO_new_mem_buf((void *)input, -1);
-        b64 = BIO_new(BIO_f_base64());
-        bio = BIO_push(b64, bio);
+const std::string ZTSClient::getPrincipalToken() const {
+    // construct unsigned principal token
+    std::string unsignedTokenString = "v=S1";
+    char host[BUFSIZ];
+    long long t = (long long)time(NULL);
+
+    gethostname(host, sizeof(host));
+
+    unsignedTokenString += ";d=" + tenantDomain_;
+    unsignedTokenString += ";n=" + tenantService_;
+    unsignedTokenString += ";h=" + std::string(host);
+    unsignedTokenString += ";a=" + getSalt();
+    unsignedTokenString += ";t=" + boost::lexical_cast<std::string>(t);
+    unsignedTokenString += ";e=" + boost::lexical_cast<std::string>(t + tokenExpirationTime_);
+    unsignedTokenString += ";k=" + keyId_;
+
+    LOG_DEBUG("Created unsigned principal token: " << unsignedTokenString);
+
+    // signing
+    const char *unsignedToken = unsignedTokenString.c_str();
+    unsigned char signature[BUFSIZ];
+    unsigned char hash[SHA256_DIGEST_LENGTH];
+    unsigned int siglen;
+    FILE *fp;
+    RSA *privateKey;
+
+    if (privateKeyUri_.scheme == "data") {
+        if (privateKeyUri_.mediaTypeAndEncodingType != "application/x-pem-file;base64") {
+            LOG_ERROR("Unsupported mediaType or encodingType: " << privateKeyUri_.mediaTypeAndEncodingType);
+            return "";
+        }
+        char *decodeStr = base64Decode(privateKeyUri_.data.c_str());
 
+        BIO *bio = BIO_new_mem_buf((void *)decodeStr, -1);
         BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
-        BIO_read(bio, result, length);
-        BIO_free_all(bio);
+        if (bio == NULL) {
+            LOG_ERROR("Failed to create key BIO");
+            return "";
+        }
+        privateKey = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL);
+        BIO_free(bio);
+        if (privateKey == NULL) {
+            LOG_ERROR("Failed to load privateKey");
+            return "";
+        }
+    } else if (privateKeyUri_.scheme == "file") {
+        fp = fopen(privateKeyUri_.path.c_str(), "r");
+        if (fp == NULL) {
+            LOG_ERROR("Failed to open athenz private key file: " << privateKeyUri_.path);
+            return "";
+        }
 
-        return result;
+        privateKey = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL);
+        fclose(fp);
+        if (privateKey == NULL) {
+            LOG_ERROR("Failed to read private key: " << privateKeyUri_.path);
+            return "";
+        }
+    } else {
+        LOG_ERROR("Unsupported URI Scheme: " << privateKeyUri_.scheme);
+        return "";
     }
 
-    const std::string ZTSClient::getPrincipalToken() const {
-        // construct unsigned principal token
-        std::string unsignedTokenString = "v=S1";
-        char host[BUFSIZ];
-        long long t = (long long) time(NULL);
-
-        gethostname(host, sizeof(host));
-
-        unsignedTokenString += ";d=" + tenantDomain_;
-        unsignedTokenString += ";n=" + tenantService_;
-        unsignedTokenString += ";h=" + std::string(host);
-        unsignedTokenString += ";a=" + getSalt();
-        unsignedTokenString += ";t=" + boost::lexical_cast<std::string>(t);
-        unsignedTokenString += ";e=" + boost::lexical_cast<std::string>(t + tokenExpirationTime_);
-        unsignedTokenString += ";k=" + keyId_;
-
-        LOG_DEBUG("Created unsigned principal token: " << unsignedTokenString);
-
-        // signing
-        const char* unsignedToken = unsignedTokenString.c_str();
-        unsigned char signature[BUFSIZ];
-        unsigned char hash[SHA256_DIGEST_LENGTH];
-        unsigned int siglen;
-        FILE *fp;
-        RSA *privateKey;
-
-        if (privateKeyUri_.scheme == "data") {
-            if(privateKeyUri_.mediaTypeAndEncodingType != "application/x-pem-file;base64") {
-                LOG_ERROR("Unsupported mediaType or encodingType: " << privateKeyUri_.mediaTypeAndEncodingType);
-                return "";
-            }
-            char* decodeStr = base64Decode(privateKeyUri_.data.c_str());
+    SHA256((unsigned char *)unsignedToken, unsignedTokenString.length(), hash);
+    RSA_sign(NID_sha256, hash, SHA256_DIGEST_LENGTH, signature, &siglen, privateKey);
 
-            BIO *bio = BIO_new_mem_buf( (void*)decodeStr, -1 );
-            BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
-            if (bio == NULL) {
-                LOG_ERROR("Failed to create key BIO");
-                return "";
-            }
-            privateKey = PEM_read_bio_RSAPrivateKey( bio, NULL, NULL, NULL ) ;
-            BIO_free(bio);
-            if (privateKey == NULL) {
-                LOG_ERROR("Failed to load privateKey");
-                return "";
-            }
-        } else if (privateKeyUri_.scheme == "file") {
-            fp = fopen(privateKeyUri_.path.c_str(), "r");
-            if (fp == NULL) {
-                LOG_ERROR("Failed to open athenz private key file: " << privateKeyUri_.path);
-                return "";
-            }
+    std::string principalToken = unsignedTokenString + ";s=" + ybase64Encode(signature, siglen);
+    LOG_DEBUG("Created signed principal token: " << principalToken);
 
-            privateKey = PEM_read_RSAPrivateKey(fp, NULL, NULL, NULL);
-            fclose(fp);
-            if (privateKey == NULL) {
-                LOG_ERROR("Failed to read private key: " << privateKeyUri_.path);
-                return "";
-            }
-        } else {
-            LOG_ERROR("Unsupported URI Scheme: " << privateKeyUri_.scheme);
-            return "";
-        }
+    return principalToken;
+}
 
-        SHA256( (unsigned char *)unsignedToken, unsignedTokenString.length(), hash );
-        RSA_sign(NID_sha256, hash, SHA256_DIGEST_LENGTH, signature, &siglen, privateKey);
+static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb, void *responseDataPtr) {
+    ((std::string *)responseDataPtr)->append((char *)contents, size * nmemb);
+    return size * nmemb;
+}
 
-        std::string principalToken = unsignedTokenString + ";s=" + ybase64Encode(signature, siglen);
-        LOG_DEBUG("Created signed principal token: " << principalToken);
+static boost::mutex cacheMtx_;
+const std::string ZTSClient::getRoleToken() const {
+    RoleToken roleToken;
+    std::string cacheKey = "p=" + tenantDomain_ + "." + tenantService_ + ";d=" + providerDomain_;
 
-        return principalToken;
+    // locked block
+    {
+        boost::lock_guard<boost::mutex> lock(cacheMtx_);
+        roleToken = roleTokenCache_[cacheKey];
     }
 
-    static size_t curlWriteCallback(void *contents, size_t size, size_t nmemb, void *responseDataPtr) {
-        ((std::string*)responseDataPtr)->append((char*)contents, size * nmemb);
-        return size * nmemb;
+    if (!roleToken.token.empty() && roleToken.expiryTime > (long long)time(NULL) + FETCH_EPSILON) {
+        LOG_DEBUG("Got cached role token " << roleToken.token);
+        return roleToken.token;
     }
 
-    static boost::mutex cacheMtx_;
-    const std::string ZTSClient::getRoleToken() const {
-        RoleToken roleToken;
-        std::string cacheKey = "p=" + tenantDomain_ + "." + tenantService_ + ";d=" + providerDomain_;
+    std::string completeUrl = ztsUrl_ + "/zts/v1/domain/" + providerDomain_ + "/token";
 
-        // locked block
-        {
-            boost::lock_guard<boost::mutex> lock(cacheMtx_);
-            roleToken = roleTokenCache_[cacheKey];
-        }
+    CURL *handle;
+    CURLcode res;
+    std::string responseData;
 
-        if (!roleToken.token.empty() && roleToken.expiryTime > (long long) time(NULL) + FETCH_EPSILON) {
-            LOG_DEBUG("Got cached role token " << roleToken.token);
-            return roleToken.token;
-        }
+    handle = curl_easy_init();
 
-        std::string completeUrl = ztsUrl_ + "/zts/v1/domain/" + providerDomain_ + "/token";
-
-        CURL *handle;
-        CURLcode res;
-        std::string responseData;
-
-        handle = curl_easy_init();
-
-        // set URL
-        curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
-
-        // Write callback
-        curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
-        curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
-
-        // New connection is made for each call
-        curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
-        curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
-
-        // Skipping signal handling - results in timeouts not honored during the DNS lookup
-        curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
-
-        // Timer
-        curl_easy_setopt(handle, CURLOPT_TIMEOUT, REQUEST_TIMEOUT);
-
-        // Redirects
-        curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
-        curl_easy_setopt(handle, CURLOPT_MAXREDIRS, MAX_HTTP_REDIRECTS);
-
-        // Fail if HTTP return code >= 400
-        curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
-
-        struct curl_slist *list = NULL;
-        std::string httpHeader = principalHeader_ + ": " + getPrincipalToken();
-        list = curl_slist_append(list, httpHeader.c_str());
-        curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
-
-        // Make get call to server
-        res = curl_easy_perform(handle);
-
-        // Free header list
-        curl_slist_free_all(list);
-
-        switch(res) {
-            case CURLE_OK:
-                long response_code;
-                curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response_code);
-                LOG_DEBUG("Response received for url " << completeUrl << " code " << response_code);
-                if (response_code == 200) {
-                    Json::Reader reader;
-                    Json::Value root;
-                    if (!reader.parse(responseData, root)) {
-                        LOG_ERROR("Failed to parse json of ZTS response: " << reader.getFormatedErrorMessages()
-                                  << "\nInput Json = " << responseData);
-                        break;
-                    }
-                    roleToken.token = root["token"].asString();
-                    roleToken.expiryTime = root["expiryTime"].asUInt();
-                    boost::lock_guard<boost::mutex> lock(cacheMtx_);
-                    roleTokenCache_[cacheKey] = roleToken;
-                    LOG_DEBUG("Got role token " << roleToken.token)
-                } else {
-                    LOG_ERROR("Response failed for url " << completeUrl << ". response Code " << response_code)
-                }
-                break;
-            default:
-                LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
-                break;
-        }
-        curl_easy_cleanup(handle);
+    // set URL
+    curl_easy_setopt(handle, CURLOPT_URL, completeUrl.c_str());
 
-        return roleToken.token;
-    }
+    // Write callback
+    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, curlWriteCallback);
+    curl_easy_setopt(handle, CURLOPT_WRITEDATA, &responseData);
+
+    // New connection is made for each call
+    curl_easy_setopt(handle, CURLOPT_FRESH_CONNECT, 1L);
+    curl_easy_setopt(handle, CURLOPT_FORBID_REUSE, 1L);
+
+    // Skipping signal handling - results in timeouts not honored during the DNS lookup
+    curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1L);
+
+    // Timer
+    curl_easy_setopt(handle, CURLOPT_TIMEOUT, REQUEST_TIMEOUT);
+
+    // Redirects
+    curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1L);
+    curl_easy_setopt(handle, CURLOPT_MAXREDIRS, MAX_HTTP_REDIRECTS);
+
+    // Fail if HTTP return code >= 400
+    curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1L);
+
+    struct curl_slist *list = NULL;
+    std::string httpHeader = principalHeader_ + ": " + getPrincipalToken();
+    list = curl_slist_append(list, httpHeader.c_str());
+    curl_easy_setopt(handle, CURLOPT_HTTPHEADER, list);
 
-    const std::string ZTSClient::getHeader() const {
-        return roleHeader_;
+    // Make get call to server
+    res = curl_easy_perform(handle);
+
+    // Free header list
+    curl_slist_free_all(list);
+
+    switch (res) {
+        case CURLE_OK:
+            long response_code;
+            curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &response_code);
+            LOG_DEBUG("Response received for url " << completeUrl << " code " << response_code);
+            if (response_code == 200) {
+                Json::Reader reader;
+                Json::Value root;
+                if (!reader.parse(responseData, root)) {
+                    LOG_ERROR("Failed to parse json of ZTS response: " << reader.getFormatedErrorMessages()
+                                                                       << "\nInput Json = " << responseData);
+                    break;
+                }
+                roleToken.token = root["token"].asString();
+                roleToken.expiryTime = root["expiryTime"].asUInt();
+                boost::lock_guard<boost::mutex> lock(cacheMtx_);
+                roleTokenCache_[cacheKey] = roleToken;
+                LOG_DEBUG("Got role token " << roleToken.token)
+            } else {
+                LOG_ERROR("Response failed for url " << completeUrl << ". response Code " << response_code)
+            }
+            break;
+        default:
+            LOG_ERROR("Response failed for url " << completeUrl << ". Error Code " << res);
+            break;
     }
+    curl_easy_cleanup(handle);
 
-    PrivateKeyUri ZTSClient::parseUri(const char* uri) {
-        PrivateKeyUri uriSt;
-        // scheme mediatype[;base64] path file
-        static const boost::regex expression("^(\?:([^:/\?#]+):)(\?:([;/\\-\\w]*),)\?(/\?(\?:[^\?#/]*/)*)\?([^\?#]*)");
-        boost::cmatch groups;
-        if (boost::regex_match(uri, groups, expression)) {
-           uriSt.scheme = groups.str(1);
-           uriSt.mediaTypeAndEncodingType = groups.str(2);
-           uriSt.data = groups.str(4);
-           uriSt.path = groups.str(3) + groups.str(4);
-        }
-        return uriSt;
+    return roleToken.token;
+}
+
+const std::string ZTSClient::getHeader() const { return roleHeader_; }
+
+PrivateKeyUri ZTSClient::parseUri(const char *uri) {
+    PrivateKeyUri uriSt;
+    // scheme mediatype[;base64] path file
+    static const boost::regex expression(
+        "^(\?:([^:/\?#]+):)(\?:([;/\\-\\w]*),)\?(/\?(\?:[^\?#/]*/)*)\?([^\?#]*)");
+    boost::cmatch groups;
+    if (boost::regex_match(uri, groups, expression)) {
+        uriSt.scheme = groups.str(1);
+        uriSt.mediaTypeAndEncodingType = groups.str(2);
+        uriSt.data = groups.str(4);
+        uriSt.path = groups.str(3) + groups.str(4);
     }
+    return uriSt;
+}
 }
diff --git a/pulsar-client-cpp/lib/auth/athenz/ZTSClient.h b/pulsar-client-cpp/lib/auth/athenz/ZTSClient.h
index c27dbb580..9d394e608 100644
--- a/pulsar-client-cpp/lib/auth/athenz/ZTSClient.h
+++ b/pulsar-client-cpp/lib/auth/athenz/ZTSClient.h
@@ -24,42 +24,43 @@
 
 namespace pulsar {
 
-    struct RoleToken {
-        std::string token;
-        long long expiryTime;
-    };
+struct RoleToken {
+    std::string token;
+    long long expiryTime;
+};
 
-    struct PrivateKeyUri {
-        std::string scheme;
-        std::string mediaTypeAndEncodingType;
-        std::string data;
-        std::string path;
-    };
+struct PrivateKeyUri {
+    std::string scheme;
+    std::string mediaTypeAndEncodingType;
+    std::string data;
+    std::string path;
+};
 
-    class ZTSClient {
-    public:
-        ZTSClient(std::map<std::string, std::string>& params);
-        const std::string getRoleToken() const;
-        const std::string getHeader() const;
-        ~ZTSClient();
-    private:
-        std::string tenantDomain_;
-        std::string tenantService_;
-        std::string providerDomain_;
-        PrivateKeyUri privateKeyUri_;
-        std::string ztsUrl_;
-        std::string keyId_;
-        std::string principalHeader_;
-        std::string roleHeader_;
-        int tokenExpirationTime_;
-        static std::map<std::string, RoleToken> roleTokenCache_;
-        static std::string getSalt();
-        static std::string ybase64Encode(const unsigned char *input, int length);
-        static char* base64Decode(const char *input);
-        const std::string getPrincipalToken() const;
-        static PrivateKeyUri parseUri(const char* uri);
+class ZTSClient {
+   public:
+    ZTSClient(std::map<std::string, std::string>& params);
+    const std::string getRoleToken() const;
+    const std::string getHeader() const;
+    ~ZTSClient();
 
-        friend class ZTSClientWrapper;
-    };
+   private:
+    std::string tenantDomain_;
+    std::string tenantService_;
+    std::string providerDomain_;
+    PrivateKeyUri privateKeyUri_;
+    std::string ztsUrl_;
+    std::string keyId_;
+    std::string principalHeader_;
+    std::string roleHeader_;
+    int tokenExpirationTime_;
+    static std::map<std::string, RoleToken> roleTokenCache_;
+    static std::string getSalt();
+    static std::string ybase64Encode(const unsigned char* input, int length);
+    static char* base64Decode(const char* input);
+    const std::string getPrincipalToken() const;
+    static PrivateKeyUri parseUri(const char* uri);
+
+    friend class ZTSClientWrapper;
+};
 }
 #pragma GCC visibility pop
diff --git a/pulsar-client-cpp/lib/checksum/ChecksumProvider.cc b/pulsar-client-cpp/lib/checksum/ChecksumProvider.cc
index 1e588bd13..fe94930d0 100644
--- a/pulsar-client-cpp/lib/checksum/ChecksumProvider.cc
+++ b/pulsar-client-cpp/lib/checksum/ChecksumProvider.cc
@@ -25,18 +25,18 @@
 namespace pulsar {
 bool isCrc32cSupported = crc32cSupported();
 
-bool crc32cSupported() {
-    return crc32c_initialize();
-}
+bool crc32cSupported() { return crc32c_initialize(); }
 
 /**
- *  computes crc32c checksum: uses sse4.2 hardware-instruction to compute crc32c if machine supports else it computes using sw algo
+ *  computes crc32c checksum: uses sse4.2 hardware-instruction to compute crc32c if machine supports else it
+ * computes using sw algo
  *  @param
- *  previousChecksum = in case of incremental-checksum-computation pass previous computed else pass 0 in other case.
+ *  previousChecksum = in case of incremental-checksum-computation pass previous computed else pass 0 in other
+ * case.
  *  data = for which checksum will be computed
  *  length = length of data from offset
  */
-uint32_t computeChecksum(uint32_t previousChecksum, const void * data, int length) {
+uint32_t computeChecksum(uint32_t previousChecksum, const void* data, int length) {
     if (isCrc32cSupported) {
         return crc32cHw(previousChecksum, data, length);
     } else {
@@ -47,7 +47,7 @@ uint32_t computeChecksum(uint32_t previousChecksum, const void * data, int lengt
 /**
  * Computes crc32c using hardware sse4.2 instruction
  */
-uint32_t crc32cHw(uint32_t previousChecksum, const void * data, int length) {
+uint32_t crc32cHw(uint32_t previousChecksum, const void* data, int length) {
     assert(isCrc32cSupported);
     return crc32c(previousChecksum, data, length, 0);
 }
@@ -55,8 +55,7 @@ uint32_t crc32cHw(uint32_t previousChecksum, const void * data, int length) {
 /**
  * Computes crc32c using sw crc-table algo
  */
-uint32_t crc32cSw(uint32_t previousChecksum, const void * data, int length) {
+uint32_t crc32cSw(uint32_t previousChecksum, const void* data, int length) {
     return crc32c_sw(previousChecksum, data, length);
 }
-
 }
diff --git a/pulsar-client-cpp/lib/checksum/ChecksumProvider.h b/pulsar-client-cpp/lib/checksum/ChecksumProvider.h
index ce59598c8..3a848e4a7 100644
--- a/pulsar-client-cpp/lib/checksum/ChecksumProvider.h
+++ b/pulsar-client-cpp/lib/checksum/ChecksumProvider.h
@@ -27,10 +27,10 @@ namespace pulsar {
 
 bool crc32cSupported();
 uint32_t computeChecksum(uint32_t previousChecksum, const void *data, int length);
-uint32_t crc32cHw(uint32_t previousChecksum, const void * data, int length);
-uint32_t crc32cSw(uint32_t previousChecksum, const void * data, int length);
+uint32_t crc32cHw(uint32_t previousChecksum, const void *data, int length);
+uint32_t crc32cSw(uint32_t previousChecksum, const void *data, int length);
 }
 
 #pragma GCC visibility pop
 
-#endif // _CHECKSUM_PROVIDER_H_
+#endif  // _CHECKSUM_PROVIDER_H_
diff --git a/pulsar-client-cpp/lib/checksum/crc32c_sse42.cc b/pulsar-client-cpp/lib/checksum/crc32c_sse42.cc
index 1185acc51..f20eb6c1b 100644
--- a/pulsar-client-cpp/lib/checksum/crc32c_sse42.cc
+++ b/pulsar-client-cpp/lib/checksum/crc32c_sse42.cc
@@ -1,12 +1,12 @@
 /*******************************************************************************
  * Copyright 2014 Trevor Robinson
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,29 +16,29 @@
 #include "crc32c_sse42.h"
 
 #include <assert.h>
-#include <nmmintrin.h> // SSE4.2
-#include <wmmintrin.h> // PCLMUL
+#include <nmmintrin.h>  // SSE4.2
+#include <wmmintrin.h>  // PCLMUL
 
 #ifdef _MSC_VER
-# include <intrin.h>
+#include <intrin.h>
 #else
-# include <cpuid.h>
+#include <cpuid.h>
 #endif
 
 //#define CRC32C_DEBUG
 #define CRC32C_PCLMULQDQ
 
 #ifdef CRC32C_DEBUG
-# include <stdio.h>
-# define DEBUG_PRINTF1(fmt, v1) printf(fmt, v1)
-# define DEBUG_PRINTF2(fmt, v1, v2) printf(fmt, v1, v2)
-# define DEBUG_PRINTF3(fmt, v1, v2, v3) printf(fmt, v1, v2, v3)
-# define DEBUG_PRINTF4(fmt, v1, v2, v3, v4) printf(fmt, v1, v2, v3, v4)
+#include <stdio.h>
+#define DEBUG_PRINTF1(fmt, v1) printf(fmt, v1)
+#define DEBUG_PRINTF2(fmt, v1, v2) printf(fmt, v1, v2)
+#define DEBUG_PRINTF3(fmt, v1, v2, v3) printf(fmt, v1, v2, v3)
+#define DEBUG_PRINTF4(fmt, v1, v2, v3, v4) printf(fmt, v1, v2, v3, v4)
 #else
-# define DEBUG_PRINTF1(fmt, v1)
-# define DEBUG_PRINTF2(fmt, v1, v2)
-# define DEBUG_PRINTF3(fmt, v1, v2, v3)
-# define DEBUG_PRINTF4(fmt, v1, v2, v3, v4)
+#define DEBUG_PRINTF1(fmt, v1)
+#define DEBUG_PRINTF2(fmt, v1, v2)
+#define DEBUG_PRINTF3(fmt, v1, v2, v3)
+#define DEBUG_PRINTF4(fmt, v1, v2, v3, v4)
 #endif
 
 static bool initialized = false;
@@ -62,7 +62,8 @@ bool crc32c_initialize() {
             has_pclmulqdq = (ecx & cpuid_ecx_pclmulqdq) != 0;
         }
 #endif
-        DEBUG_PRINTF1("has_sse42 = %d\n", has_sse42);DEBUG_PRINTF1("has_pclmulqdq = %d\n", has_pclmulqdq);
+        DEBUG_PRINTF1("has_sse42 = %d\n", has_sse42);
+        DEBUG_PRINTF1("has_pclmulqdq = %d\n", has_pclmulqdq);
         initialized = true;
     }
     return has_sse42;
@@ -70,9 +71,7 @@ bool crc32c_initialize() {
 
 #include "gf2.hpp"
 
-chunk_config::chunk_config(size_t words, const chunk_config* next)
-        : words(words),
-          next(next) {
+chunk_config::chunk_config(size_t words, const chunk_config *next) : words(words), next(next) {
     assert(words > 0);
     assert(!next || next->words < words);
     const size_t loop_bytes = loops() * 8;
@@ -86,14 +85,14 @@ void chunk_config::make_shift_table(size_t bytes, uint32_t table[256]) {
     op[0] = 0x82f63b78;  // reversed CRC-32C polynomial
     bitmatrix<32, 32> m;
     pow(m, op, bytes * 8);
-    for (unsigned int i = 0; i < 256; ++i)
-        table[i] = (const bitvector<32> ) mul(m, bitvector<32>(i));
+    for (unsigned int i = 0; i < 256; ++i) table[i] = (const bitvector<32>)mul(m, bitvector<32>(i));
 }
 
-static uint32_t crc32c_chunk(uint32_t crc, const void *buf, const chunk_config& config) {
-    DEBUG_PRINTF3("  crc32c_chunk(crc = 0x%08x, buf = %p, config.words = " SIZE_T_FORMAT ")", crc, buf, config.words);
+static uint32_t crc32c_chunk(uint32_t crc, const void *buf, const chunk_config &config) {
+    DEBUG_PRINTF3("  crc32c_chunk(crc = 0x%08x, buf = %p, config.words = " SIZE_T_FORMAT ")", crc, buf,
+                  config.words);
 
-    const uint64_t *pq = (const uint64_t*) buf;
+    const uint64_t *pq = (const uint64_t *)buf;
     uint64_t crc0 = config.extra() > 1 ? _mm_crc32_u64(crc, *pq++) : crc;
     uint64_t crc1 = 0;
     uint64_t crc2 = 0;
@@ -105,30 +104,30 @@ static uint32_t crc32c_chunk(uint32_t crc, const void *buf, const chunk_config&
     }
     pq += 2 * loops;
     uint64_t tmp = *pq++;
-# ifdef CRC32C_PCLMULQDQ
+#ifdef CRC32C_PCLMULQDQ
     if (has_pclmulqdq) {
         __m128i k = _mm_set_epi64x(config.shift1[1], config.shift2[1]);
-        __m128i mul1 = _mm_clmulepi64_si128(_mm_cvtsi64_si128((int64_t ) crc1), k, 0x10);
-        __m128i mul0 = _mm_clmulepi64_si128(_mm_cvtsi64_si128((int64_t ) crc0), k, 0x00);
-        tmp ^= (uint64_t) _mm_cvtsi128_si64(mul1);
-        tmp ^= (uint64_t) _mm_cvtsi128_si64(mul0);
+        __m128i mul1 = _mm_clmulepi64_si128(_mm_cvtsi64_si128((int64_t)crc1), k, 0x10);
+        __m128i mul0 = _mm_clmulepi64_si128(_mm_cvtsi64_si128((int64_t)crc0), k, 0x00);
+        tmp ^= (uint64_t)_mm_cvtsi128_si64(mul1);
+        tmp ^= (uint64_t)_mm_cvtsi128_si64(mul0);
     } else
-# endif
+#endif
     {
         tmp ^= config.shift1[crc1 & 0xff];
-        tmp ^= ((uint64_t) config.shift1[(crc1 >> 8) & 0xff]) << 8;
-        tmp ^= ((uint64_t) config.shift1[(crc1 >> 16) & 0xff]) << 16;
-        tmp ^= ((uint64_t) config.shift1[(crc1 >> 24) & 0xff]) << 24;
+        tmp ^= ((uint64_t)config.shift1[(crc1 >> 8) & 0xff]) << 8;
+        tmp ^= ((uint64_t)config.shift1[(crc1 >> 16) & 0xff]) << 16;
+        tmp ^= ((uint64_t)config.shift1[(crc1 >> 24) & 0xff]) << 24;
 
         tmp ^= config.shift2[crc0 & 0xff];
-        tmp ^= ((uint64_t) config.shift2[(crc0 >> 8) & 0xff]) << 8;
-        tmp ^= ((uint64_t) config.shift2[(crc0 >> 16) & 0xff]) << 16;
-        tmp ^= ((uint64_t) config.shift2[(crc0 >> 24) & 0xff]) << 24;
+        tmp ^= ((uint64_t)config.shift2[(crc0 >> 8) & 0xff]) << 8;
+        tmp ^= ((uint64_t)config.shift2[(crc0 >> 16) & 0xff]) << 16;
+        tmp ^= ((uint64_t)config.shift2[(crc0 >> 24) & 0xff]) << 24;
     }
     crc2 = _mm_crc32_u64(crc2, tmp);
     if (config.extra() > 2)  // only if words is divisible by 3
         crc2 = _mm_crc32_u64(crc2, *pq);
-    crc = (uint32_t) crc2;
+    crc = (uint32_t)crc2;
 
     DEBUG_PRINTF1(" = 0x%08x\n", crc);
     return crc;
@@ -137,27 +136,27 @@ static uint32_t crc32c_chunk(uint32_t crc, const void *buf, const chunk_config&
 static uint32_t crc32c_words(uint32_t crc, const void *buf, size_t count) {
     DEBUG_PRINTF3("  crc32c_words(crc = 0x%08x, buf = %p, count = " SIZE_T_FORMAT ")", crc, buf, count);
 
-    const uint64_t *pq = (const uint64_t*) buf;
+    const uint64_t *pq = (const uint64_t *)buf;
     size_t loops = (count + 7) / 8;
     assert(loops > 0);
     switch (count & 7) {
         case 0:
             do {
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 7:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 6:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 5:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 4:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 3:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 2:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
                 case 1:
-                crc = (uint32_t) _mm_crc32_u64(crc, *pq++);
+                    crc = (uint32_t)_mm_crc32_u64(crc, *pq++);
             } while (--loops > 0);
     }
 
@@ -168,27 +167,27 @@ static uint32_t crc32c_words(uint32_t crc, const void *buf, size_t count) {
 static uint32_t crc32c_bytes(uint32_t crc, const void *buf, size_t count) {
     DEBUG_PRINTF3("  crc32c_bytes(crc = 0x%08x, buf = %p, count = " SIZE_T_FORMAT ")", crc, buf, count);
 
-    const uint8_t *pc = (const uint8_t*) buf;
+    const uint8_t *pc = (const uint8_t *)buf;
     size_t loops = (count + 7) / 8;
     assert(loops > 0);
     switch (count & 7) {
         case 0:
             do {
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 7:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 6:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 5:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 4:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 3:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 2:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
                 case 1:
-                crc = (uint32_t) _mm_crc32_u8(crc, *pc++);
+                    crc = (uint32_t)_mm_crc32_u8(crc, *pc++);
             } while (--loops > 0);
     }
 
@@ -196,14 +195,14 @@ static uint32_t crc32c_bytes(uint32_t crc, const void *buf, size_t count) {
     return crc;
 }
 
-uint32_t crc32c(uint32_t init, const void *buf, size_t len, const chunk_config* config) {
+uint32_t crc32c(uint32_t init, const void *buf, size_t len, const chunk_config *config) {
     DEBUG_PRINTF3("crc32c(init = 0x%08x, buf = %p, len = " SIZE_T_FORMAT ")\n", init, buf, len);
 
     uint32_t crc = ~init;
-    const char *pc = (const char*) buf;
+    const char *pc = (const char *)buf;
     if (len >= 24) {
-        if ((uintptr_t) pc & 7) {
-            size_t unaligned = 8 - ((uintptr_t) pc & 7);
+        if ((uintptr_t)pc & 7) {
+            size_t unaligned = 8 - ((uintptr_t)pc & 7);
             crc = crc32c_bytes(crc, pc, unaligned);
             pc += unaligned;
             len -= unaligned;
@@ -223,8 +222,7 @@ uint32_t crc32c(uint32_t init, const void *buf, size_t len, const chunk_config*
         }
         len &= 7;
     }
-    if (len)
-        crc = crc32c_bytes(crc, pc, len);
+    if (len) crc = crc32c_bytes(crc, pc, len);
     crc = ~crc;
 
     DEBUG_PRINTF1("crc = 0x%08x\n", crc);
diff --git a/pulsar-client-cpp/lib/checksum/crc32c_sse42.h b/pulsar-client-cpp/lib/checksum/crc32c_sse42.h
index 6cd2298cb..d8e923dc7 100644
--- a/pulsar-client-cpp/lib/checksum/crc32c_sse42.h
+++ b/pulsar-client-cpp/lib/checksum/crc32c_sse42.h
@@ -1,12 +1,12 @@
 /*******************************************************************************
  * Copyright 2014 Trevor Robinson
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,8 +18,9 @@
 bool crc32c_initialize();
 
 class chunk_config {
- public:
-    enum {
+   public:
+    enum
+    {
         min_words = 4
     };
 
@@ -30,17 +31,13 @@ class chunk_config {
 
     chunk_config(size_t words, const chunk_config* next = 0);
 
-    size_t loops() const {
-        return (words - 1) / 3;
-    }
-    size_t extra() const {
-        return (words - 1) % 3 + 1;
-    }
+    size_t loops() const { return (words - 1) / 3; }
+    size_t extra() const { return (words - 1) % 3 + 1; }
 
- private:
+   private:
     chunk_config& operator=(const chunk_config&);
 
     static void make_shift_table(size_t bytes, uint32_t table[256]);
 };
 
-uint32_t crc32c(uint32_t init, const void *buf, size_t len, const chunk_config* config);
+uint32_t crc32c(uint32_t init, const void* buf, size_t len, const chunk_config* config);
diff --git a/pulsar-client-cpp/lib/checksum/crc32c_sw.cc b/pulsar-client-cpp/lib/checksum/crc32c_sw.cc
index d900808c0..e005069d7 100644
--- a/pulsar-client-cpp/lib/checksum/crc32c_sw.cc
+++ b/pulsar-client-cpp/lib/checksum/crc32c_sw.cc
@@ -76,21 +76,21 @@ static void crc32c_init_sw(void) {
  than using the hardware instructions.  This assumes little-endian integers,
  as is the case on Intel processors that the assembler code here is for. */
 uint32_t crc32c_sw(uint32_t crci, const void *buf, int len) {
-    const char* next = (const char*) buf;
+    const char *next = (const char *)buf;
     uint64_t crc;
 
     pthread_once(&crc32c_once_sw, crc32c_init_sw);
     crc = crci ^ 0xffffffff;
-    while (len && ((uintptr_t) next & 7) != 0) {
+    while (len && ((uintptr_t)next & 7) != 0) {
         crc = crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
         len--;
     }
     while (len >= 8) {
-        crc ^= *(uint64_t *) next;
-        crc = crc32c_table[7][crc & 0xff] ^ crc32c_table[6][(crc >> 8) & 0xff]
-                ^ crc32c_table[5][(crc >> 16) & 0xff] ^ crc32c_table[4][(crc >> 24) & 0xff]
-                ^ crc32c_table[3][(crc >> 32) & 0xff] ^ crc32c_table[2][(crc >> 40) & 0xff]
-                ^ crc32c_table[1][(crc >> 48) & 0xff] ^ crc32c_table[0][crc >> 56];
+        crc ^= *(uint64_t *)next;
+        crc = crc32c_table[7][crc & 0xff] ^ crc32c_table[6][(crc >> 8) & 0xff] ^
+              crc32c_table[5][(crc >> 16) & 0xff] ^ crc32c_table[4][(crc >> 24) & 0xff] ^
+              crc32c_table[3][(crc >> 32) & 0xff] ^ crc32c_table[2][(crc >> 40) & 0xff] ^
+              crc32c_table[1][(crc >> 48) & 0xff] ^ crc32c_table[0][crc >> 56];
         next += 8;
         len -= 8;
     }
@@ -98,5 +98,5 @@ uint32_t crc32c_sw(uint32_t crci, const void *buf, int len) {
         crc = crc32c_table[0][(crc ^ *next++) & 0xff] ^ (crc >> 8);
         len--;
     }
-    return (uint32_t) crc ^ 0xffffffff;
+    return (uint32_t)crc ^ 0xffffffff;
 }
diff --git a/pulsar-client-cpp/lib/checksum/int_types.h b/pulsar-client-cpp/lib/checksum/int_types.h
index 16c5c8548..6623bd026 100644
--- a/pulsar-client-cpp/lib/checksum/int_types.h
+++ b/pulsar-client-cpp/lib/checksum/int_types.h
@@ -13,9 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  ******************************************************************************/
-#include <stddef.h> // size_t
+#include <stddef.h>  // size_t
 
-#if defined(_MSC_VER) && _MSC_VER < 1600 // stdint.h added in MSVC 2010
+#if defined(_MSC_VER) && _MSC_VER < 1600  // stdint.h added in MSVC 2010
 
 typedef __int8 int8_t;
 typedef __int16 int16_t;
@@ -28,16 +28,16 @@ typedef unsigned __int64 uint64_t;
 
 #else
 
-# include <stdint.h>
+#include <stdint.h>
 
 #endif
 
-#if defined(_MSC_VER) && _MSC_VER < 1900 // MSVC 2015
+#if defined(_MSC_VER) && _MSC_VER < 1900  // MSVC 2015
 
-# define SIZE_T_FORMAT "%Iu"
+#define SIZE_T_FORMAT "%Iu"
 
 #else
 
-# define SIZE_T_FORMAT "%zu"
+#define SIZE_T_FORMAT "%zu"
 
 #endif
diff --git a/pulsar-client-cpp/lib/lz4/lz4.h b/pulsar-client-cpp/lib/lz4/lz4.h
index 3e7400225..578b4baa8 100644
--- a/pulsar-client-cpp/lib/lz4/lz4.h
+++ b/pulsar-client-cpp/lib/lz4/lz4.h
@@ -34,7 +34,7 @@
 */
 #pragma once
 
-#if defined (__cplusplus)
+#if defined(__cplusplus)
 extern "C" {
 #endif
 
@@ -47,11 +47,11 @@ extern "C" {
 /**************************************
 *  Version
 **************************************/
-#define LZ4_VERSION_MAJOR    1    /* for breaking interface changes  */
-#define LZ4_VERSION_MINOR    7    /* for new (non-breaking) interface capabilities */
-#define LZ4_VERSION_RELEASE  1    /* for tweaks, bug-fixes, or development */
-#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR *100*100 + LZ4_VERSION_MINOR *100 + LZ4_VERSION_RELEASE)
-int LZ4_versionNumber (void);
+#define LZ4_VERSION_MAJOR 1   /* for breaking interface changes  */
+#define LZ4_VERSION_MINOR 7   /* for new (non-breaking) interface capabilities */
+#define LZ4_VERSION_RELEASE 1 /* for tweaks, bug-fixes, or development */
+#define LZ4_VERSION_NUMBER (LZ4_VERSION_MAJOR * 100 * 100 + LZ4_VERSION_MINOR * 100 + LZ4_VERSION_RELEASE)
+int LZ4_versionNumber(void);
 
 /**************************************
 *  Tuning parameter
@@ -65,13 +65,12 @@ int LZ4_versionNumber (void);
  */
 #define LZ4_MEMORY_USAGE 14
 
-
 /**************************************
 *  Simple Functions
 **************************************/
 
 int LZ4_compress_default(const char* source, char* dest, int sourceSize, int maxDestSize);
-int LZ4_decompress_safe (const char* source, char* dest, int compressedSize, int maxDecompressedSize);
+int LZ4_decompress_safe(const char* source, char* dest, int compressedSize, int maxDecompressedSize);
 
 /*
 LZ4_compress_default() :
@@ -93,23 +92,26 @@ LZ4_decompress_safe() :
     maxDecompressedSize : is the size of destination buffer, which must be already allocated.
     return : the number of bytes decompressed into destination buffer (necessarily <= maxDecompressedSize)
              If destination buffer is not large enough, decoding will stop and output an error code (<0).
-             If the source stream is detected malformed, the function will stop decoding and return a negative result.
+             If the source stream is detected malformed, the function will stop decoding and return a negative
+result.
              This function is protected against buffer overflow exploits, including malicious data packets.
              It never writes outside output buffer, nor reads outside input buffer.
 */
 
-
 /**************************************
 *  Advanced Functions
 **************************************/
-#define LZ4_MAX_INPUT_SIZE        0x7E000000   /* 2 113 929 216 bytes */
-#define LZ4_COMPRESSBOUND(isize)  ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize)/255) + 16)
+#define LZ4_MAX_INPUT_SIZE 0x7E000000 /* 2 113 929 216 bytes */
+#define LZ4_COMPRESSBOUND(isize) \
+    ((unsigned)(isize) > (unsigned)LZ4_MAX_INPUT_SIZE ? 0 : (isize) + ((isize) / 255) + 16)
 
 /*
 LZ4_compressBound() :
-    Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not compressible)
+    Provides the maximum size that LZ4 compression may output in a "worst case" scenario (input data not
+compressible)
     This function is primarily useful for memory allocation purposes (destination buffer size).
-    Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for example).
+    Macro LZ4_COMPRESSBOUND() is also provided for compilation-time evaluation (stack memory allocation for
+example).
     Note that LZ4_compress_default() compress faster when dest buffer size is >= LZ4_compressBound(srcSize)
         inputSize  : max supported value is LZ4_MAX_INPUT_SIZE
         return : maximum output size in a "worst case" scenario
@@ -125,8 +127,7 @@ LZ4_compress_fast() :
     An acceleration value of "1" is the same as regular LZ4_compress_default()
     Values <= 0 will be replaced by ACCELERATION_DEFAULT (see lz4.c), which is 1.
 */
-int LZ4_compress_fast (const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration);
-
+int LZ4_compress_fast(const char* source, char* dest, int sourceSize, int maxDestSize, int acceleration);
 
 /*
 LZ4_compress_fast_extState() :
@@ -136,8 +137,8 @@ LZ4_compress_fast_extState() :
     Then, provide it as 'void* state' to compression function.
 */
 int LZ4_sizeofState(void);
-int LZ4_compress_fast_extState (void* state, const char* source, char* dest, int inputSize, int maxDestSize, int acceleration);
-
+int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxDestSize,
+                               int acceleration);
 
 /*
 LZ4_compress_destSize() :
@@ -150,21 +151,22 @@ LZ4_compress_destSize() :
         return : Nb bytes written into 'dest' (necessarily <= targetDestSize)
               or 0 if compression fails
 */
-int LZ4_compress_destSize (const char* source, char* dest, int* sourceSizePtr, int targetDestSize);
-
+int LZ4_compress_destSize(const char* source, char* dest, int* sourceSizePtr, int targetDestSize);
 
 /*
 LZ4_decompress_fast() :
     originalSize : is the original and therefore uncompressed size
     return : the number of bytes read from the source buffer (in other words, the compressed size)
-             If the source stream is detected malformed, the function will stop decoding and return a negative result.
+             If the source stream is detected malformed, the function will stop decoding and return a negative
+result.
              Destination buffer must be already allocated. Its size must be a minimum of 'originalSize' bytes.
     note : This function fully respect memory boundaries for properly formed compressed data.
            It is a bit faster than LZ4_decompress_safe().
-           However, it does not provide any protection against intentionally modified data stream (malicious input).
+           However, it does not provide any protection against intentionally modified data stream (malicious
+input).
            Use this function in trusted environment only (data to decode comes from a trusted source).
 */
-int LZ4_decompress_fast (const char* source, char* dest, int originalSize);
+int LZ4_decompress_fast(const char* source, char* dest, int originalSize);
 
 /*
 LZ4_decompress_safe_partial() :
@@ -175,17 +177,19 @@ LZ4_decompress_safe_partial() :
     return : the number of bytes decoded in the destination buffer (necessarily <= maxDecompressedSize)
        Note : this number can be < 'targetOutputSize' should the compressed block to decode be smaller.
              Always control how many bytes were decoded.
-             If the source stream is detected malformed, the function will stop decoding and return a negative result.
-             This function never writes outside of output buffer, and never reads outside of input buffer. It is therefore protected against malicious data packets
+             If the source stream is detected malformed, the function will stop decoding and return a negative
+result.
+             This function never writes outside of output buffer, and never reads outside of input buffer. It
+is therefore protected against malicious data packets
 */
-int LZ4_decompress_safe_partial (const char* source, char* dest, int compressedSize, int targetOutputSize, int maxDecompressedSize);
-
+int LZ4_decompress_safe_partial(const char* source, char* dest, int compressedSize, int targetOutputSize,
+                                int maxDecompressedSize);
 
 /***********************************************
 *  Streaming Compression Functions
 ***********************************************/
-#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE-3)) + 4)
-#define LZ4_STREAMSIZE     (LZ4_STREAMSIZE_U64 * sizeof(long long))
+#define LZ4_STREAMSIZE_U64 ((1 << (LZ4_MEMORY_USAGE - 3)) + 4)
+#define LZ4_STREAMSIZE (LZ4_STREAMSIZE_U64 * sizeof(long long))
 /*
  * LZ4_stream_t
  * information structure to track an LZ4 stream.
@@ -199,7 +203,7 @@ typedef struct { long long table[LZ4_STREAMSIZE_U64]; } LZ4_stream_t;
  * LZ4_resetStream
  * Use this function to init an allocated LZ4_stream_t structure
  */
-void LZ4_resetStream (LZ4_stream_t* streamPtr);
+void LZ4_resetStream(LZ4_stream_t* streamPtr);
 
 /*
  * LZ4_createStream will allocate and initialize an LZ4_stream_t structure
@@ -208,7 +212,7 @@ void LZ4_resetStream (LZ4_stream_t* streamPtr);
  * They are more future proof, in case of a change of LZ4_stream_t size.
  */
 LZ4_stream_t* LZ4_createStream(void);
-int           LZ4_freeStream (LZ4_stream_t* streamPtr);
+int LZ4_freeStream(LZ4_stream_t* streamPtr);
 
 /*
  * LZ4_loadDict
@@ -217,17 +221,20 @@ int           LZ4_freeStream (LZ4_stream_t* streamPtr);
  * Loading a size of 0 is allowed.
  * Return : dictionary size, in bytes (necessarily <= 64 KB)
  */
-int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
+int LZ4_loadDict(LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
 
 /*
  * LZ4_compress_fast_continue
- * Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve compression ratio.
+ * Compress buffer content 'src', using data from previously compressed blocks as dictionary to improve
+ * compression ratio.
  * Important : Previous data blocks are assumed to still be present and unmodified !
  * 'dst' buffer must be already allocated.
  * If maxDstSize >= LZ4_compressBound(srcSize), compression is guaranteed to succeed, and runs faster.
- * If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a zero.
+ * If not, and if compressed data cannot fit into 'dst' buffer size, compression stops, and function returns a
+ * zero.
  */
-int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int maxDstSize, int acceleration);
+int LZ4_compress_fast_continue(LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize,
+                               int maxDstSize, int acceleration);
 
 /*
  * LZ4_saveDict
@@ -237,15 +244,14 @@ int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char*
  *        dictionary is immediately usable, you can therefore call LZ4_compress_fast_continue()
  * Return : saved dictionary size in bytes (necessarily <= dictSize), or 0 if error
  */
-int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize);
-
+int LZ4_saveDict(LZ4_stream_t* streamPtr, char* safeBuffer, int dictSize);
 
 /************************************************
 *  Streaming Decompression Functions
 ************************************************/
 
-#define LZ4_STREAMDECODESIZE_U64  4
-#define LZ4_STREAMDECODESIZE     (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
+#define LZ4_STREAMDECODESIZE_U64 4
+#define LZ4_STREAMDECODESIZE (LZ4_STREAMDECODESIZE_U64 * sizeof(unsigned long long))
 typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_streamDecode_t;
 /*
  * LZ4_streamDecode_t
@@ -258,7 +264,7 @@ typedef struct { unsigned long long table[LZ4_STREAMDECODESIZE_U64]; } LZ4_strea
  * LZ4_freeStreamDecode releases its memory.
  */
 LZ4_streamDecode_t* LZ4_createStreamDecode(void);
-int                 LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
+int LZ4_freeStreamDecode(LZ4_streamDecode_t* LZ4_stream);
 
 /*
  * LZ4_setStreamDecode
@@ -266,17 +272,20 @@ int                 LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream);
  * Setting a size of 0 is allowed (same effect as reset).
  * Return : 1 if OK, 0 if error
  */
-int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
+int LZ4_setStreamDecode(LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize);
 
 /*
 *_continue() :
     These decoding functions allow decompression of multiple blocks in "streaming" mode.
-    Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64 KB)
+    Previously decoded blocks *must* remain available at the memory position where they were decoded (up to 64
+KB)
     In the case of a ring buffers, decoding buffer must be either :
     - Exactly same size as encoding buffer, with same update rule (block boundaries at same positions)
-      In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64 KB).
+      In which case, the decoding & encoding ring buffer can have any size, including very small ones ( < 64
+KB).
     - Larger than encoding buffer, by a minimum of maxBlockSize more bytes.
-      maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single block.
+      maxBlockSize is implementation dependent. It's the maximum size you intend to compress into a single
+block.
       In which case, encoding and decoding buffers do not need to be synchronized,
       and encoding ring buffer can have any size, including small ones ( < 64 KB).
     - _At least_ 64 KB + 8 bytes + maxBlockSize.
@@ -285,9 +294,10 @@ int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dicti
     Whenever these conditions are not possible, save the last 64KB of decoded data into a safe buffer,
     and indicate where it is saved using LZ4_setStreamDecode()
 */
-int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int compressedSize, int maxDecompressedSize);
-int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest, int originalSize);
-
+int LZ4_decompress_safe_continue(LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest,
+                                 int compressedSize, int maxDecompressedSize);
+int LZ4_decompress_fast_continue(LZ4_streamDecode_t* LZ4_streamDecode, const char* source, char* dest,
+                                 int originalSize);
 
 /*
 Advanced decoding functions :
@@ -296,10 +306,10 @@ Advanced decoding functions :
     a combination of LZ4_setStreamDecode() followed by LZ4_decompress_x_continue()
     They are stand-alone. They don't need nor update an LZ4_streamDecode_t structure.
 */
-int LZ4_decompress_safe_usingDict (const char* source, char* dest, int compressedSize, int maxDecompressedSize, const char* dictStart, int dictSize);
-int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalSize, const char* dictStart, int dictSize);
-
-
+int LZ4_decompress_safe_usingDict(const char* source, char* dest, int compressedSize, int maxDecompressedSize,
+                                  const char* dictStart, int dictSize);
+int LZ4_decompress_fast_usingDict(const char* source, char* dest, int originalSize, const char* dictStart,
+                                  int dictSize);
 
 /**************************************
 *  Obsolete Functions
@@ -311,28 +321,30 @@ int LZ4_decompress_fast_usingDict (const char* source, char* dest, int originalS
    or _CRT_SECURE_NO_WARNINGS in Visual for example.
    You can also define LZ4_DEPRECATE_WARNING_DEFBLOCK. */
 #ifndef LZ4_DEPRECATE_WARNING_DEFBLOCK
-#  define LZ4_DEPRECATE_WARNING_DEFBLOCK
-#  define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
-#  if (LZ4_GCC_VERSION >= 405) || defined(__clang__)
-#    define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
-#  elif (LZ4_GCC_VERSION >= 301)
-#    define LZ4_DEPRECATED(message) __attribute__((deprecated))
-#  elif defined(_MSC_VER)
-#    define LZ4_DEPRECATED(message) __declspec(deprecated(message))
-#  else
-#    pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
-#    define LZ4_DEPRECATED(message)
-#  endif
+#define LZ4_DEPRECATE_WARNING_DEFBLOCK
+#define LZ4_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+#if (LZ4_GCC_VERSION >= 405) || defined(__clang__)
+#define LZ4_DEPRECATED(message) __attribute__((deprecated(message)))
+#elif (LZ4_GCC_VERSION >= 301)
+#define LZ4_DEPRECATED(message) __attribute__((deprecated))
+#elif defined(_MSC_VER)
+#define LZ4_DEPRECATED(message) __declspec(deprecated(message))
+#else
+#pragma message("WARNING: You need to implement LZ4_DEPRECATED for this compiler")
+#define LZ4_DEPRECATED(message)
+#endif
 #endif /* LZ4_DEPRECATE_WARNING_DEFBLOCK */
 
 /* Obsolete compression functions */
 /* These functions are planned to start generate warnings by r131 approximately */
-int LZ4_compress               (const char* source, char* dest, int sourceSize);
-int LZ4_compress_limitedOutput (const char* source, char* dest, int sourceSize, int maxOutputSize);
-int LZ4_compress_withState               (void* state, const char* source, char* dest, int inputSize);
-int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
-int LZ4_compress_continue                (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
-int LZ4_compress_limitedOutput_continue  (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
+int LZ4_compress(const char* source, char* dest, int sourceSize);
+int LZ4_compress_limitedOutput(const char* source, char* dest, int sourceSize, int maxOutputSize);
+int LZ4_compress_withState(void* state, const char* source, char* dest, int inputSize);
+int LZ4_compress_limitedOutput_withState(void* state, const char* source, char* dest, int inputSize,
+                                         int maxOutputSize);
+int LZ4_compress_continue(LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize);
+int LZ4_compress_limitedOutput_continue(LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest,
+                                        int inputSize, int maxOutputSize);
 
 /* Obsolete decompression functions */
 /* These function names are completely deprecated and must no longer be used.
@@ -345,16 +357,17 @@ int LZ4_compress_limitedOutput_continue  (LZ4_stream_t* LZ4_streamPtr, const cha
 /* int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); */
 
 /* Obsolete streaming functions; use new streaming interface whenever possible */
-LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create (char* inputBuffer);
-LZ4_DEPRECATED("use LZ4_createStream() instead") int   LZ4_sizeofStreamState(void);
-LZ4_DEPRECATED("use LZ4_resetStream() instead")  int   LZ4_resetStreamState(void* state, char* inputBuffer);
-LZ4_DEPRECATED("use LZ4_saveDict() instead")     char* LZ4_slideInputBuffer (void* state);
+LZ4_DEPRECATED("use LZ4_createStream() instead") void* LZ4_create(char* inputBuffer);
+LZ4_DEPRECATED("use LZ4_createStream() instead") int LZ4_sizeofStreamState(void);
+LZ4_DEPRECATED("use LZ4_resetStream() instead") int LZ4_resetStreamState(void* state, char* inputBuffer);
+LZ4_DEPRECATED("use LZ4_saveDict() instead") char* LZ4_slideInputBuffer(void* state);
 
 /* Obsolete streaming decoding functions */
-LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize);
-LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize);
-
+LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead")
+int LZ4_decompress_safe_withPrefix64k(const char* src, char* dst, int compressedSize, int maxDstSize);
+LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead")
+int LZ4_decompress_fast_withPrefix64k(const char* src, char* dst, int originalSize);
 
-#if defined (__cplusplus)
+#if defined(__cplusplus)
 }
 #endif
diff --git a/pulsar-client-cpp/lib/stats/ConsumerStatsBase.h b/pulsar-client-cpp/lib/stats/ConsumerStatsBase.h
index b8b8fc959..4b957106f 100644
--- a/pulsar-client-cpp/lib/stats/ConsumerStatsBase.h
+++ b/pulsar-client-cpp/lib/stats/ConsumerStatsBase.h
@@ -26,7 +26,7 @@
 
 namespace pulsar {
 class ConsumerStatsBase {
- public:
+   public:
     virtual void receivedMessage(Message&, Result) = 0;
     virtual void messageAcknowledged(Result, proto::CommandAck_AckType) = 0;
     virtual ~ConsumerStatsBase() {}
@@ -35,4 +35,4 @@ class ConsumerStatsBase {
 typedef boost::shared_ptr<ConsumerStatsBase> ConsumerStatsBasePtr;
 }
 
-#endif // PULSAR_CONSUMER_STATS_BASE_HEADER
+#endif  // PULSAR_CONSUMER_STATS_BASE_HEADER
diff --git a/pulsar-client-cpp/lib/stats/ConsumerStatsDisabled.h b/pulsar-client-cpp/lib/stats/ConsumerStatsDisabled.h
index 8f3e80c7b..e2233d55c 100644
--- a/pulsar-client-cpp/lib/stats/ConsumerStatsDisabled.h
+++ b/pulsar-client-cpp/lib/stats/ConsumerStatsDisabled.h
@@ -25,7 +25,7 @@
 namespace pulsar {
 
 class ConsumerStatsDisabled : public ConsumerStatsBase {
- public:
+   public:
     virtual void receivedMessage(Message&, Result) {}
     virtual void messageAcknowledged(Result, proto::CommandAck_AckType) {}
 };
diff --git a/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.cc b/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.cc
index 1632d39fb..2bb5e63e1 100644
--- a/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.cc
+++ b/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.cc
@@ -25,31 +25,29 @@ DECLARE_LOG_OBJECT();
 
 ConsumerStatsImpl::ConsumerStatsImpl(std::string consumerStr, DeadlineTimerPtr timer,
                                      unsigned int statsIntervalInSeconds)
-        : consumerStr_(consumerStr),
-          timer_(timer),
-          statsIntervalInSeconds_(statsIntervalInSeconds),
-          totalNumBytesRecieved_(0),
-          numBytesRecieved_(0) {
+    : consumerStr_(consumerStr),
+      timer_(timer),
+      statsIntervalInSeconds_(statsIntervalInSeconds),
+      totalNumBytesRecieved_(0),
+      numBytesRecieved_(0) {
     timer_->expires_from_now(boost::posix_time::seconds(statsIntervalInSeconds_));
     timer_->async_wait(
-            boost::bind(&pulsar::ConsumerStatsImpl::flushAndReset, this,
-                        boost::asio::placeholders::error));
+        boost::bind(&pulsar::ConsumerStatsImpl::flushAndReset, this, boost::asio::placeholders::error));
 }
 
 ConsumerStatsImpl::ConsumerStatsImpl(const ConsumerStatsImpl& stats)
-        : consumerStr_(stats.consumerStr_),
-          totalNumBytesRecieved_(stats.totalNumBytesRecieved_),
-          numBytesRecieved_(stats.numBytesRecieved_),
-          receivedMsgMap_(stats.receivedMsgMap_),
-          ackedMsgMap_(stats.ackedMsgMap_),
-          totalReceivedMsgMap_(stats.totalReceivedMsgMap_),
-          totalAckedMsgMap_(stats.totalAckedMsgMap_),
-          statsIntervalInSeconds_(stats.statsIntervalInSeconds_) {
-}
+    : consumerStr_(stats.consumerStr_),
+      totalNumBytesRecieved_(stats.totalNumBytesRecieved_),
+      numBytesRecieved_(stats.numBytesRecieved_),
+      receivedMsgMap_(stats.receivedMsgMap_),
+      ackedMsgMap_(stats.ackedMsgMap_),
+      totalReceivedMsgMap_(stats.totalReceivedMsgMap_),
+      totalAckedMsgMap_(stats.totalAckedMsgMap_),
+      statsIntervalInSeconds_(stats.statsIntervalInSeconds_) {}
 
 void ConsumerStatsImpl::flushAndReset(const boost::system::error_code& ec) {
     if (ec) {
-        LOG_DEBUG("Ignoring timer cancelled event, code[" << ec <<"]");
+        LOG_DEBUG("Ignoring timer cancelled event, code[" << ec << "]");
         return;
     }
 
@@ -62,8 +60,7 @@ void ConsumerStatsImpl::flushAndReset(const boost::system::error_code& ec) {
 
     timer_->expires_from_now(boost::posix_time::seconds(statsIntervalInSeconds_));
     timer_->async_wait(
-            boost::bind(&pulsar::ConsumerStatsImpl::flushAndReset, this,
-                        boost::asio::placeholders::error));
+        boost::bind(&pulsar::ConsumerStatsImpl::flushAndReset, this, boost::asio::placeholders::error));
     LOG_INFO(tmp);
 }
 
@@ -90,24 +87,26 @@ void ConsumerStatsImpl::messageAcknowledged(Result res, proto::CommandAck_AckTyp
     totalAckedMsgMap_[std::make_pair(res, ackType)] += 1;
 }
 
-std::ostream& operator<<(
-        std::ostream& os,
-        const std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>& m) {
+std::ostream& operator<<(std::ostream& os,
+                         const std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>& m) {
     os << "{";
-    for (std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>::const_iterator it = m.begin(); it != m.end(); it++) {
-        os << "[Key: {" << "Result: " << strResult((it->first).first) << ", ackType: "
-                << (it->first).second << "}, Value: " << it->second << "], ";
+    for (std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>::const_iterator it = m.begin();
+         it != m.end(); it++) {
+        os << "[Key: {"
+           << "Result: " << strResult((it->first).first) << ", ackType: " << (it->first).second
+           << "}, Value: " << it->second << "], ";
     }
     os << "}";
     return os;
 }
 
 std::ostream& operator<<(std::ostream& os, const ConsumerStatsImpl& obj) {
-    os << "Consumer " << obj.consumerStr_ << ", ConsumerStatsImpl (" << "numBytesRecieved_ = "
-       << obj.numBytesRecieved_ << ", totalNumBytesRecieved_ = " << obj.totalNumBytesRecieved_
+    os << "Consumer " << obj.consumerStr_ << ", ConsumerStatsImpl ("
+       << "numBytesRecieved_ = " << obj.numBytesRecieved_
+       << ", totalNumBytesRecieved_ = " << obj.totalNumBytesRecieved_
        << ", receivedMsgMap_ = " << obj.receivedMsgMap_ << ", ackedMsgMap_ = " << obj.ackedMsgMap_
-       << ", totalReceivedMsgMap_ = " << obj.totalReceivedMsgMap_ << ", totalAckedMsgMap_ = "
-       << obj.totalAckedMsgMap_ << ")";
+       << ", totalReceivedMsgMap_ = " << obj.totalReceivedMsgMap_
+       << ", totalAckedMsgMap_ = " << obj.totalAckedMsgMap_ << ")";
     return os;
 }
 } /* namespace pulsar */
diff --git a/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.h b/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.h
index 98f278518..f220b0885 100644
--- a/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.h
+++ b/pulsar-client-cpp/lib/stats/ConsumerStatsImpl.h
@@ -28,7 +28,7 @@
 namespace pulsar {
 
 class ConsumerStatsImpl : public ConsumerStatsBase {
- private:
+   private:
     unsigned long numBytesRecieved_;
     std::map<Result, unsigned long> receivedMsgMap_;
     std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long> ackedMsgMap_;
@@ -45,7 +45,8 @@ class ConsumerStatsImpl : public ConsumerStatsBase {
     friend std::ostream& operator<<(std::ostream&, const ConsumerStatsImpl&);
     friend std::ostream& operator<<(std::ostream&, const std::map<Result, unsigned long>&);
     friend class PulsarFriend;
- public:
+
+   public:
     ConsumerStatsImpl(std::string, DeadlineTimerPtr, unsigned int);
     ConsumerStatsImpl(const ConsumerStatsImpl& stats);
     void flushAndReset(const boost::system::error_code&);
@@ -53,25 +54,21 @@ class ConsumerStatsImpl : public ConsumerStatsBase {
     virtual void messageAcknowledged(Result, proto::CommandAck_AckType);
     virtual ~ConsumerStatsImpl();
 
-    const inline std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>& getAckedMsgMap() const {
+    const inline std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>& getAckedMsgMap()
+        const {
         return ackedMsgMap_;
     }
 
-    inline unsigned long getNumBytesRecieved() const {
-        return numBytesRecieved_;
-    }
+    inline unsigned long getNumBytesRecieved() const { return numBytesRecieved_; }
 
-    const inline std::map<Result, unsigned long>& getReceivedMsgMap() const {
-        return receivedMsgMap_;
-    }
+    const inline std::map<Result, unsigned long>& getReceivedMsgMap() const { return receivedMsgMap_; }
 
-    inline const std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>& getTotalAckedMsgMap() const {
+    inline const std::map<std::pair<Result, proto::CommandAck_AckType>, unsigned long>& getTotalAckedMsgMap()
+        const {
         return totalAckedMsgMap_;
     }
 
-    inline unsigned long getTotalNumBytesRecieved() const {
-        return totalNumBytesRecieved_;
-    }
+    inline unsigned long getTotalNumBytesRecieved() const { return totalNumBytesRecieved_; }
 
     const inline std::map<Result, unsigned long>& getTotalReceivedMsgMap() const {
         return totalReceivedMsgMap_;
diff --git a/pulsar-client-cpp/lib/stats/ProducerStatsBase.h b/pulsar-client-cpp/lib/stats/ProducerStatsBase.h
index 314fe3123..2e6211a8e 100644
--- a/pulsar-client-cpp/lib/stats/ProducerStatsBase.h
+++ b/pulsar-client-cpp/lib/stats/ProducerStatsBase.h
@@ -25,13 +25,13 @@
 
 namespace pulsar {
 class ProducerStatsBase {
- public:
+   public:
     virtual void messageSent(const Message& msg) = 0;
     virtual void messageReceived(Result&, boost::posix_time::ptime&) = 0;
-    virtual ~ProducerStatsBase() {};
+    virtual ~ProducerStatsBase(){};
 };
 
 typedef boost::shared_ptr<ProducerStatsBase> ProducerStatsBasePtr;
 }
 
-#endif // PULSAR_PRODUCER_STATS_BASE_HEADER
+#endif  // PULSAR_PRODUCER_STATS_BASE_HEADER
diff --git a/pulsar-client-cpp/lib/stats/ProducerStatsDisabled.h b/pulsar-client-cpp/lib/stats/ProducerStatsDisabled.h
index 0b4c3504b..83c273edc 100644
--- a/pulsar-client-cpp/lib/stats/ProducerStatsDisabled.h
+++ b/pulsar-client-cpp/lib/stats/ProducerStatsDisabled.h
@@ -23,10 +23,9 @@
 
 namespace pulsar {
 class ProducerStatsDisabled : public ProducerStatsBase {
- public:
-    virtual void messageSent(const Message& msg) {};
-    virtual void messageReceived(Result&, boost::posix_time::ptime&) {};
+   public:
+    virtual void messageSent(const Message& msg){};
+    virtual void messageReceived(Result&, boost::posix_time::ptime&){};
 };
-
 }
-#endif // PULSAR_PRODUCER_STATS_DISABLED_HEADER
+#endif  // PULSAR_PRODUCER_STATS_DISABLED_HEADER
diff --git a/pulsar-client-cpp/lib/stats/ProducerStatsImpl.cc b/pulsar-client-cpp/lib/stats/ProducerStatsImpl.cc
index fcdf5724a..6d15d682b 100644
--- a/pulsar-client-cpp/lib/stats/ProducerStatsImpl.cc
+++ b/pulsar-client-cpp/lib/stats/ProducerStatsImpl.cc
@@ -24,56 +24,55 @@
 namespace pulsar {
 DECLARE_LOG_OBJECT();
 
-static const boost::array<double, 4> probs = { 0.5, 0.9, 0.99, 0.999 };
+static const boost::array<double, 4> probs = {0.5, 0.9, 0.99, 0.999};
 
 std::string ProducerStatsImpl::latencyToString(const LatencyAccumulator& obj) {
-    boost::accumulators::detail::extractor_result<LatencyAccumulator,
-            boost::accumulators::tag::extended_p_square>::type latencies =
-            boost::accumulators::extended_p_square(obj);
+    boost::accumulators::detail::extractor_result<
+        LatencyAccumulator, boost::accumulators::tag::extended_p_square>::type latencies =
+        boost::accumulators::extended_p_square(obj);
     std::stringstream os;
-    os << "Latencies [ 50pct: " << latencies[0] / 1e3 << "ms" << ", 90pct: " << latencies[1] / 1e3
-            << "ms" << ", 99pct: " << latencies[2] / 1e3 << "ms" << ", 99.9pct: "
-            << latencies[3] / 1e3 << "ms" << "]";
+    os << "Latencies [ 50pct: " << latencies[0] / 1e3 << "ms"
+       << ", 90pct: " << latencies[1] / 1e3 << "ms"
+       << ", 99pct: " << latencies[2] / 1e3 << "ms"
+       << ", 99.9pct: " << latencies[3] / 1e3 << "ms"
+       << "]";
     return os.str();
 }
 
 ProducerStatsImpl::ProducerStatsImpl(std::string producerStr, DeadlineTimerPtr timer,
-                                       unsigned int statsIntervalInSeconds)
-        : numMsgsSent_(0),
-          numBytesSent_(0),
-          totalMsgsSent_(0),
-          totalBytesSent_(0),
-          timer_(timer),
-          producerStr_(producerStr),
-          statsIntervalInSeconds_(statsIntervalInSeconds),
-          mutex_(),
-          latencyAccumulator_(boost::accumulators::tag::extended_p_square::probabilities = probs),
-          totalLatencyAccumulator_(boost::accumulators::tag::extended_p_square::probabilities =
-                  probs) {
+                                     unsigned int statsIntervalInSeconds)
+    : numMsgsSent_(0),
+      numBytesSent_(0),
+      totalMsgsSent_(0),
+      totalBytesSent_(0),
+      timer_(timer),
+      producerStr_(producerStr),
+      statsIntervalInSeconds_(statsIntervalInSeconds),
+      mutex_(),
+      latencyAccumulator_(boost::accumulators::tag::extended_p_square::probabilities = probs),
+      totalLatencyAccumulator_(boost::accumulators::tag::extended_p_square::probabilities = probs) {
     timer_->expires_from_now(boost::posix_time::seconds(statsIntervalInSeconds_));
     timer_->async_wait(
-            boost::bind(&pulsar::ProducerStatsImpl::flushAndReset, this,
-                        boost::asio::placeholders::error));
+        boost::bind(&pulsar::ProducerStatsImpl::flushAndReset, this, boost::asio::placeholders::error));
 }
 
 ProducerStatsImpl::ProducerStatsImpl(const ProducerStatsImpl& stats)
-        : numMsgsSent_(stats.numMsgsSent_),
-          numBytesSent_(stats.numBytesSent_),
-          totalMsgsSent_(stats.totalMsgsSent_),
-          totalBytesSent_(stats.totalBytesSent_),
-          sendMap_(stats.sendMap_),
-          totalSendMap_(stats.totalSendMap_),
-          timer_(),
-          producerStr_(stats.producerStr_),
-          statsIntervalInSeconds_(stats.statsIntervalInSeconds_),
-          mutex_(),
-          latencyAccumulator_(stats.latencyAccumulator_),
-          totalLatencyAccumulator_(stats.totalLatencyAccumulator_) {
-}
+    : numMsgsSent_(stats.numMsgsSent_),
+      numBytesSent_(stats.numBytesSent_),
+      totalMsgsSent_(stats.totalMsgsSent_),
+      totalBytesSent_(stats.totalBytesSent_),
+      sendMap_(stats.sendMap_),
+      totalSendMap_(stats.totalSendMap_),
+      timer_(),
+      producerStr_(stats.producerStr_),
+      statsIntervalInSeconds_(stats.statsIntervalInSeconds_),
+      mutex_(),
+      latencyAccumulator_(stats.latencyAccumulator_),
+      totalLatencyAccumulator_(stats.totalLatencyAccumulator_) {}
 
 void ProducerStatsImpl::flushAndReset(const boost::system::error_code& ec) {
     if (ec) {
-        LOG_DEBUG("Ignoring timer cancelled event, code[" << ec <<"]");
+        LOG_DEBUG("Ignoring timer cancelled event, code[" << ec << "]");
         return;
     }
 
@@ -82,14 +81,13 @@ void ProducerStatsImpl::flushAndReset(const boost::system::error_code& ec) {
     numMsgsSent_ = 0;
     numBytesSent_ = 0;
     sendMap_.clear();
-    latencyAccumulator_ = LatencyAccumulator(
-            boost::accumulators::tag::extended_p_square::probabilities = probs);
+    latencyAccumulator_ =
+        LatencyAccumulator(boost::accumulators::tag::extended_p_square::probabilities = probs);
     lock.unlock();
 
     timer_->expires_from_now(boost::posix_time::seconds(statsIntervalInSeconds_));
     timer_->async_wait(
-            boost::bind(&pulsar::ProducerStatsImpl::flushAndReset, this,
-                        boost::asio::placeholders::error));
+        boost::bind(&pulsar::ProducerStatsImpl::flushAndReset, this, boost::asio::placeholders::error));
     LOG_INFO(tmp);
 }
 
@@ -107,7 +105,7 @@ void ProducerStatsImpl::messageReceived(Result& res, boost::posix_time::ptime& p
     Lock lock(mutex_);
     totalLatencyAccumulator_(diffInMicros);
     latencyAccumulator_(diffInMicros);
-    sendMap_[res] += 1;  // Value will automatically be initialized to 0 in the constructor
+    sendMap_[res] += 1;       // Value will automatically be initialized to 0 in the constructor
     totalSendMap_[res] += 1;  // Value will automatically be initialized to 0 in the constructor
 }
 
@@ -119,14 +117,15 @@ ProducerStatsImpl::~ProducerStatsImpl() {
 }
 
 std::ostream& operator<<(std::ostream& os, const ProducerStatsImpl& obj) {
-    os << "Producer " << obj.producerStr_ << ", ProducerStatsImpl (" << "numMsgsSent_ = "
-       << obj.numMsgsSent_ << ", numBytesSent_ = " << obj.numBytesSent_ << ", sendMap_ = "
-       << obj.sendMap_ << ", latencyAccumulator_ = "
-       << ProducerStatsImpl::latencyToString(obj.latencyAccumulator_) << ", totalMsgsSent_ = "
-       << obj.totalMsgsSent_ << ", totalBytesSent_ = " << obj.totalBytesSent_
-       << ", totalAcksReceived_ = " << ", totalSendMap_ = " << obj.totalSendMap_
-       << ", totalLatencyAccumulator_ = "
-       << ProducerStatsImpl::latencyToString(obj.totalLatencyAccumulator_) << ")";
+    os << "Producer " << obj.producerStr_ << ", ProducerStatsImpl ("
+       << "numMsgsSent_ = " << obj.numMsgsSent_ << ", numBytesSent_ = " << obj.numBytesSent_
+       << ", sendMap_ = " << obj.sendMap_
+       << ", latencyAccumulator_ = " << ProducerStatsImpl::latencyToString(obj.latencyAccumulator_)
+       << ", totalMsgsSent_ = " << obj.totalMsgsSent_ << ", totalBytesSent_ = " << obj.totalBytesSent_
+       << ", totalAcksReceived_ = "
+       << ", totalSendMap_ = " << obj.totalSendMap_
+       << ", totalLatencyAccumulator_ = " << ProducerStatsImpl::latencyToString(obj.totalLatencyAccumulator_)
+       << ")";
     return os;
 }
 }
diff --git a/pulsar-client-cpp/lib/stats/ProducerStatsImpl.h b/pulsar-client-cpp/lib/stats/ProducerStatsImpl.h
index 29c49afc6..a9653a216 100644
--- a/pulsar-client-cpp/lib/stats/ProducerStatsImpl.h
+++ b/pulsar-client-cpp/lib/stats/ProducerStatsImpl.h
@@ -25,7 +25,7 @@
 #include <lib/ExecutorService.h>
 
 #if BOOST_VERSION >= 106400
-  #include <boost/serialization/array_wrapper.hpp>
+#include <boost/serialization/array_wrapper.hpp>
 #endif
 #include <boost/accumulators/framework/features.hpp>
 
@@ -44,13 +44,13 @@
 #include <lib/stats/ProducerStatsBase.h>
 
 namespace pulsar {
-typedef boost::accumulators::accumulator_set<double,
-        boost::accumulators::stats<boost::accumulators::tag::mean,
-                boost::accumulators::tag::extended_p_square> > LatencyAccumulator;
+typedef boost::accumulators::accumulator_set<
+    double,
+    boost::accumulators::stats<boost::accumulators::tag::mean, boost::accumulators::tag::extended_p_square> >
+    LatencyAccumulator;
 
-class ProducerStatsImpl : public boost::enable_shared_from_this<ProducerStatsImpl>,
-        public ProducerStatsBase {
- private:
+class ProducerStatsImpl : public boost::enable_shared_from_this<ProducerStatsImpl>, public ProducerStatsBase {
+   private:
     unsigned long numMsgsSent_;
     unsigned long numBytesSent_;
     std::map<Result, unsigned long> sendMap_;
@@ -71,7 +71,8 @@ class ProducerStatsImpl : public boost::enable_shared_from_this<ProducerStatsImp
     friend class PulsarFriend;
 
     static std::string latencyToString(const LatencyAccumulator&);
- public:
+
+   public:
     ProducerStatsImpl(std::string, DeadlineTimerPtr, unsigned int);
 
     ProducerStatsImpl(const ProducerStatsImpl& stats);
@@ -84,39 +85,23 @@ class ProducerStatsImpl : public boost::enable_shared_from_this<ProducerStatsImp
 
     ~ProducerStatsImpl();
 
-    inline unsigned long getNumMsgsSent() {
-        return numMsgsSent_;
-    }
+    inline unsigned long getNumMsgsSent() { return numMsgsSent_; }
 
-    inline unsigned long getNumBytesSent() {
-        return numBytesSent_;
-    }
+    inline unsigned long getNumBytesSent() { return numBytesSent_; }
 
-    inline std::map<Result, unsigned long> getSendMap() {
-        return sendMap_;
-    }
+    inline std::map<Result, unsigned long> getSendMap() { return sendMap_; }
 
-    inline unsigned long getTotalMsgsSent() {
-        return totalMsgsSent_;
-    }
+    inline unsigned long getTotalMsgsSent() { return totalMsgsSent_; }
 
-    inline unsigned long getTotalBytesSent() {
-        return totalBytesSent_;
-    }
+    inline unsigned long getTotalBytesSent() { return totalBytesSent_; }
 
-    inline std::map<Result, unsigned long> getTotalSendMap() {
-        return totalSendMap_;
-    }
+    inline std::map<Result, unsigned long> getTotalSendMap() { return totalSendMap_; }
 
-    inline LatencyAccumulator getLatencyAccumulator() {
-        return latencyAccumulator_;
-    }
+    inline LatencyAccumulator getLatencyAccumulator() { return latencyAccumulator_; }
 
-    inline LatencyAccumulator getTotalLatencyAccumulator() {
-        return totalLatencyAccumulator_;
-    }
+    inline LatencyAccumulator getTotalLatencyAccumulator() { return totalLatencyAccumulator_; }
 };
 typedef boost::shared_ptr<ProducerStatsImpl> ProducerStatsImplPtr;
 }
 
-#endif // PULSAR_PRODUCER_STATS_IMPL_HEADER
+#endif  // PULSAR_PRODUCER_STATS_IMPL_HEADER
diff --git a/pulsar-client-cpp/tests/AuthPluginTest.cc b/pulsar-client-cpp/tests/AuthPluginTest.cc
index a2147b983..8871cb9d5 100644
--- a/pulsar-client-cpp/tests/AuthPluginTest.cc
+++ b/pulsar-client-cpp/tests/AuthPluginTest.cc
@@ -58,12 +58,14 @@ TEST(AuthPluginTest, testTls) {
     ClientConfiguration config = ClientConfiguration();
     config.setUseTls(true);
     std::string certfile = "../../pulsar-broker/src/test/resources/authentication/tls/cacert.pem";
-    std::string params =  "tlsCertFile:../../pulsar-broker/src/test/resources/authentication/tls/client-cert.pem,tlsKeyFile:../../pulsar-broker/src/test/resources/authentication/tls/client-key.pem";
+    std::string params =
+        "tlsCertFile:../../pulsar-broker/src/test/resources/authentication/tls/client-cert.pem,tlsKeyFile:../"
+        "../pulsar-broker/src/test/resources/authentication/tls/client-key.pem";
     config.setTlsTrustCertsFilePath(certfile);
     config.setTlsAllowInsecureConnection(false);
     AuthenticationPtr auth = pulsar::AuthFactory::create("../lib/auth/libauthtls.so", params);
     config.setAuth(auth);
-    Client client(lookupUrlTls,config);
+    Client client(lookupUrlTls, config);
 
     std::string topicName = "persistent://property/cluster/namespace/test-tls";
     std::string subName = "subscription-name";
@@ -95,9 +97,12 @@ TEST(AuthPluginTest, testTls) {
 
     // Send Asynchronously
     std::string prefix = "test-tls-message-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty("msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBackTls);
         LOG_INFO("sending message " << messageContent);
     }
@@ -106,7 +111,8 @@ TEST(AuthPluginTest, testTls) {
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
         std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
-        LOG_INFO("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
+        LOG_INFO("Received Message with [ content - "
+                 << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
         ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
@@ -119,33 +125,34 @@ TEST(AuthPluginTest, testTls) {
 }
 
 namespace testAthenz {
-    std::string principalToken;
-    void mockZTS() {
-        boost::asio::io_service io;
-        boost::asio::ip::tcp::iostream stream;
-        boost::asio::ip::tcp::acceptor acceptor(io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 9999));
-        acceptor.accept(*stream.rdbuf());
-        std::string headerLine;
-        while(getline(stream, headerLine)){
-            std::vector<std::string> kv;
-            boost::algorithm::split(kv, headerLine, boost::is_any_of(" "));
-            if (kv[0]=="Athenz-Principal-Auth:") {
-                principalToken = kv[1];
-            }
-
-            if (headerLine == "\r" || headerLine == "\n" || headerLine == "\r\n") {
-                std::string mockToken = "{\"token\":\"mockToken\",\"expiryTime\":4133980800}";
-                stream << "HTTP/1.1 200 OK" << std::endl;
-                stream << "Host: localhost" << std::endl;
-                stream << "Content-Type: application/json" << std::endl;
-                stream << "Content-Length: " << mockToken.size() << std::endl;
-                stream << std::endl;
-                stream << mockToken << std::endl;
-                break;
-            }
+std::string principalToken;
+void mockZTS() {
+    boost::asio::io_service io;
+    boost::asio::ip::tcp::iostream stream;
+    boost::asio::ip::tcp::acceptor acceptor(io,
+                                            boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), 9999));
+    acceptor.accept(*stream.rdbuf());
+    std::string headerLine;
+    while (getline(stream, headerLine)) {
+        std::vector<std::string> kv;
+        boost::algorithm::split(kv, headerLine, boost::is_any_of(" "));
+        if (kv[0] == "Athenz-Principal-Auth:") {
+            principalToken = kv[1];
+        }
+
+        if (headerLine == "\r" || headerLine == "\n" || headerLine == "\r\n") {
+            std::string mockToken = "{\"token\":\"mockToken\",\"expiryTime\":4133980800}";
+            stream << "HTTP/1.1 200 OK" << std::endl;
+            stream << "Host: localhost" << std::endl;
+            stream << "Content-Type: application/json" << std::endl;
+            stream << "Content-Length: " << mockToken.size() << std::endl;
+            stream << std::endl;
+            stream << mockToken << std::endl;
+            break;
         }
     }
 }
+}
 
 TEST(AuthPluginTest, testAthenz) {
     boost::thread zts(&testAthenz::mockZTS);
@@ -167,7 +174,7 @@ TEST(AuthPluginTest, testAthenz) {
     zts.join();
     std::vector<std::string> kvs;
     boost::algorithm::split(kvs, testAthenz::principalToken, boost::is_any_of(";"));
-    for(std::vector<std::string>::iterator itr = kvs.begin(); itr != kvs.end(); itr++) {
+    for (std::vector<std::string>::iterator itr = kvs.begin(); itr != kvs.end(); itr++) {
         std::vector<std::string> kv;
         boost::algorithm::split(kv, *itr, boost::is_any_of("="));
         if (kv[0] == "d") {
@@ -186,5 +193,5 @@ TEST(AuthPluginTest, testDisable) {
     ASSERT_EQ(auth->getAuthMethodName(), "none");
     ASSERT_EQ(auth->getAuthData(data), pulsar::ResultOk);
     ASSERT_EQ(data->getCommandData(), "none");
-	ASSERT_EQ(auth.use_count(), 1);
+    ASSERT_EQ(auth.use_count(), 1);
 }
diff --git a/pulsar-client-cpp/tests/BackoffTest.cc b/pulsar-client-cpp/tests/BackoffTest.cc
index a0b89603f..066d1266c 100644
--- a/pulsar-client-cpp/tests/BackoffTest.cc
+++ b/pulsar-client-cpp/tests/BackoffTest.cc
@@ -41,9 +41,9 @@ static bool withinTenPercentAndDecrementTimer(Backoff& backoff, const unsigned i
 TEST(BackoffTest, mandatoryStopTestNegativeTest) {
     Backoff backoff(milliseconds(100), seconds(60), milliseconds(1900));
     ASSERT_EQ(backoff.next().total_milliseconds(), 100);
-    backoff.next().total_milliseconds(); // 200
-    backoff.next().total_milliseconds(); // 400
-    backoff.next().total_milliseconds(); // 800
+    backoff.next().total_milliseconds();  // 200
+    backoff.next().total_milliseconds();  // 400
+    backoff.next().total_milliseconds();  // 800
     ASSERT_FALSE(withinTenPercentAndDecrementTimer(backoff, 400));
 }
 
@@ -53,7 +53,7 @@ TEST(BackoffTest, firstBackoffTimerTest) {
     boost::posix_time::ptime firstBackOffTime = PulsarFriend::getFirstBackoffTime(backoff);
     usleep(300 * 1000);
     TimeDuration diffBackOffTime = PulsarFriend::getFirstBackoffTime(backoff) - firstBackOffTime;
-    ASSERT_EQ(diffBackOffTime, milliseconds(0)); // no change since reset not called
+    ASSERT_EQ(diffBackOffTime, milliseconds(0));  // no change since reset not called
 
     backoff.reset();
     ASSERT_EQ(backoff.next().total_milliseconds(), 100);
@@ -61,7 +61,6 @@ TEST(BackoffTest, firstBackoffTimerTest) {
     ASSERT_TRUE(diffBackOffTime >= milliseconds(300) && diffBackOffTime < milliseconds(310));
 }
 
-
 TEST(BackoffTest, basicTest) {
     Backoff backoff(milliseconds(5), seconds(60), seconds(60));
     ASSERT_TRUE(checkExactAndDecrementTimer(backoff, 5));
@@ -145,4 +144,3 @@ TEST(BackoffTest, ignoringMandatoryStopTest) {
     ASSERT_TRUE(withinTenPercentAndDecrementTimer(backoff, 60000));
     ASSERT_TRUE(withinTenPercentAndDecrementTimer(backoff, 60000));
 }
-
diff --git a/pulsar-client-cpp/tests/BasicEndToEndTest.cc b/pulsar-client-cpp/tests/BasicEndToEndTest.cc
index b17b3f5e0..8191d99f4 100644
--- a/pulsar-client-cpp/tests/BasicEndToEndTest.cc
+++ b/pulsar-client-cpp/tests/BasicEndToEndTest.cc
@@ -57,15 +57,15 @@ static void sendCallBack(Result r, const Message& msg, std::string prefix) {
     LOG_DEBUG("Received publish acknowledgement for " << msg.getDataAsString());
 }
 
-static void sendCallBack(Result r, const Message& msg, std::string prefix, double percentage, uint64_t delayInMicros) {
+static void sendCallBack(Result r, const Message& msg, std::string prefix, double percentage,
+                         uint64_t delayInMicros) {
     if ((rand() % 100) <= percentage) {
         usleep(delayInMicros);
     }
     sendCallBack(r, msg, prefix);
 }
 
-TEST(BasicEndToEndTest, testBatchMessages)
-{
+TEST(BasicEndToEndTest, testBatchMessages) {
     ClientConfiguration config;
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/test-batch-messages";
@@ -107,9 +107,12 @@ TEST(BasicEndToEndTest, testBatchMessages)
 
     // Send Asynchronously
     std::string prefix = "msg-batch-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty("msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, boost::bind(&sendCallBack, _1, _2, prefix));
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -118,7 +121,8 @@ TEST(BasicEndToEndTest, testBatchMessages)
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
         std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
-        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
         ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
@@ -128,24 +132,21 @@ TEST(BasicEndToEndTest, testBatchMessages)
     globalTestBatchMessagesCounter = 0;
     // Number of messages consumed
     ASSERT_EQ(i, numOfMessages);
-
 }
 
 void resendMessage(Result r, const Message msg, Producer producer) {
-	Lock lock(mutex_);
+    Lock lock(mutex_);
     if (r != ResultOk) {
         LOG_DEBUG("globalResendMessageCount" << globalResendMessageCount);
-		if (++globalResendMessageCount >= 3) {
-			return;
-		}
+        if (++globalResendMessageCount >= 3) {
+            return;
+        }
     }
     lock.unlock();
-    producer.sendAsync(MessageBuilder().build(),
-                               boost::bind(resendMessage, _1, _2, producer));
+    producer.sendAsync(MessageBuilder().build(), boost::bind(resendMessage, _1, _2, producer));
 }
 
-    TEST(BasicEndToEndTest, testProduceConsume)
-{
+TEST(BasicEndToEndTest, testProduceConsume) {
     ClientConfiguration config;
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns1/my-topic";
@@ -185,8 +186,7 @@ void resendMessage(Result r, const Message msg, Producer producer) {
     ASSERT_EQ(ResultOk, client.close());
 }
 
-TEST(BasicEndToEndTest, testLookupThrottling)
-{
+TEST(BasicEndToEndTest, testLookupThrottling) {
     std::string topicName = "persistent://prop/unit/ns1/testLookupThrottling";
     ClientConfiguration config;
     config.setConcurrentLookupRequest(0);
@@ -199,11 +199,9 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     Consumer consumer1;
     result = client.subscribe(topicName, "my-sub-name", consumer1);
     ASSERT_EQ(ResultTooManyLookupRequestException, result);
-
 }
 
-    TEST(BasicEndToEndTest, testNonExistingTopic)
-{
+TEST(BasicEndToEndTest, testNonExistingTopic) {
     Client client(lookupUrl);
     Producer producer;
     Result result = client.createProducer("persistent://prop/unit/ns1", producer);
@@ -214,8 +212,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultInvalidTopicName, result);
 }
 
-    TEST(BasicEndToEndTest, testNonPersistentTopic)
-{
+TEST(BasicEndToEndTest, testNonPersistentTopic) {
     std::string topicName = "non-persistent://prop/unit/ns1/testNonPersistentTopic";
     Client client(lookupUrl);
     Producer producer;
@@ -227,8 +224,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultInvalidTopicName, result);
 }
 
-    TEST(BasicEndToEndTest, testSingleClientMultipleSubscriptions)
-{
+TEST(BasicEndToEndTest, testSingleClientMultipleSubscriptions) {
     std::string topicName = "persistent://prop/unit/ns1/testSingleClientMultipleSubscriptions";
 
     Client client(lookupUrl);
@@ -244,11 +240,10 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     Consumer consumer2;
     result = client.subscribe(topicName, "my-sub-name", consumer2);
     ASSERT_EQ(ResultConsumerBusy, result);
-    //at this point connection gets destroyed because this consumer creation fails
+    // at this point connection gets destroyed because this consumer creation fails
 }
 
-    TEST(BasicEndToEndTest, testMultipleClientsMultipleSubscriptions)
-{
+TEST(BasicEndToEndTest, testMultipleClientsMultipleSubscriptions) {
     std::string topicName = "persistent://prop/unit/ns1/testMultipleClientsMultipleSubscriptions";
     Client client1(lookupUrl);
     Client client2(lookupUrl);
@@ -277,8 +272,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultOk, client2.close());
 }
 
-    TEST(BasicEndToEndTest, testProduceAndConsumeAfterClientClose)
-{
+TEST(BasicEndToEndTest, testProduceAndConsumeAfterClientClose) {
     std::string topicName = "persistent://prop/unit/ns1/testProduceAndConsumeAfterClientClose";
     Client client(lookupUrl);
 
@@ -300,8 +294,10 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     LOG_INFO("Publishing 10 messages synchronously");
     int numMsg = 0;
     for (; numMsg < 10; numMsg++) {
-        Message msg = MessageBuilder().setContent(msgContent).setProperty(
-                                                                          "msgIndex", boost::lexical_cast<std::string>(numMsg)).build();
+        Message msg = MessageBuilder()
+                          .setContent(msgContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(numMsg))
+                          .build();
         ASSERT_EQ(ResultOk, producer.send(msg));
     }
 
@@ -319,8 +315,10 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultOk, client.close());
 
     LOG_INFO("Trying to publish a message after closing the client");
-    Message msg = MessageBuilder().setContent(msgContent).setProperty(
-                                                                      "msgIndex", boost::lexical_cast<std::string>(numMsg)).build();
+    Message msg = MessageBuilder()
+                      .setContent(msgContent)
+                      .setProperty("msgIndex", boost::lexical_cast<std::string>(numMsg))
+                      .build();
 
     ASSERT_EQ(ResultAlreadyClosed, producer.send(msg));
 
@@ -328,8 +326,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultAlreadyClosed, consumer.receive(msgReceived));
 }
 
-    TEST(BasicEndToEndTest, testIamSoFancyCharactersInTopicName)
-{
+TEST(BasicEndToEndTest, testIamSoFancyCharactersInTopicName) {
     Client client(lookupUrl);
     Producer producer;
     Result result = client.createProducer("persistent://prop/unit/ns1/topic@%*)(&!%$#@#$><?", producer);
@@ -340,8 +337,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultOk, result);
 }
 
-    TEST(BasicEndToEndTest, testSubscribeCloseUnsubscribeSherpaScenario)
-{
+TEST(BasicEndToEndTest, testSubscribeCloseUnsubscribeSherpaScenario) {
     ClientConfiguration config;
     Client client(lookupUrl, config);
     std::string topicName = "persistent://prop/unit/ns1/::,::bf11";
@@ -355,7 +351,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultOk, result);
 
     result = consumer.close();
-    ASSERT_EQ(ResultOk,result);
+    ASSERT_EQ(ResultOk, result);
 
     Consumer consumer1;
     result = client.subscribe(topicName, subName, consumer1);
@@ -363,8 +359,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultOk, result);
 }
 
-    TEST(BasicEndToEndTest, testInvalidUrlPassed)
-{
+TEST(BasicEndToEndTest, testInvalidUrlPassed) {
     Client client("localhost:4080");
     std::string topicName = "persistent://prop/unit/ns1/testInvalidUrlPassed";
     std::string subName = "test-sub";
@@ -389,8 +384,7 @@ TEST(BasicEndToEndTest, testLookupThrottling)
     ASSERT_EQ(ResultConnectError, result);
 }
 
-TEST(BasicEndToEndTest, testPartitionedProducerConsumer)
-{
+TEST(BasicEndToEndTest, testPartitionedProducerConsumer) {
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns/testPartitionedProducerConsumer";
 
@@ -398,7 +392,7 @@ TEST(BasicEndToEndTest, testPartitionedProducerConsumer)
     std::string url = adminUrl + "admin/persistent/prop/unit/ns/testPartitionedProducerConsumer/partitions";
     int res = makePutRequest(url, "3");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     Producer producer;
@@ -409,7 +403,7 @@ TEST(BasicEndToEndTest, testPartitionedProducerConsumer)
     result = client.subscribe(topicName, "subscription-A", consumer);
     ASSERT_EQ(ResultOk, result);
 
-    for (int i = 0; i < 10; i++ ) {
+    for (int i = 0; i < 10; i++) {
         boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
         long nanoSeconds = t.time_of_day().total_nanoseconds();
         std::stringstream ss;
@@ -429,16 +423,16 @@ TEST(BasicEndToEndTest, testPartitionedProducerConsumer)
     client.shutdown();
 }
 
-TEST(BasicEndToEndTest, testPartitionedProducerConsumerSubscriptionName)
-{
+TEST(BasicEndToEndTest, testPartitionedProducerConsumerSubscriptionName) {
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns/testPartitionedProducerConsumerSubscriptionName";
 
     // call admin api to make it partitioned
-    std::string url = adminUrl + "admin/persistent/prop/unit/ns/testPartitionedProducerConsumerSubscriptionName/partitions";
+    std::string url =
+        adminUrl + "admin/persistent/prop/unit/ns/testPartitionedProducerConsumerSubscriptionName/partitions";
     int res = makePutRequest(url, "3");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     Consumer partitionedConsumer;
@@ -453,8 +447,7 @@ TEST(BasicEndToEndTest, testPartitionedProducerConsumerSubscriptionName)
     client.shutdown();
 }
 
-TEST(BasicEndToEndTest, testMessageTooBig)
-{
+TEST(BasicEndToEndTest, testMessageTooBig) {
     ClientConfiguration config;
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns1/testMessageTooBig";
@@ -477,8 +470,7 @@ TEST(BasicEndToEndTest, testMessageTooBig)
     delete[] content;
 }
 
-    TEST(BasicEndToEndTest, testCompressionLZ4)
-{
+TEST(BasicEndToEndTest, testCompressionLZ4) {
     ClientConfiguration config;
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/namespace1/testCompressionLZ4";
@@ -516,8 +508,7 @@ TEST(BasicEndToEndTest, testMessageTooBig)
     ASSERT_EQ(ResultOk, client.close());
 }
 
-    TEST(BasicEndToEndTest, testCompressionZLib)
-{
+TEST(BasicEndToEndTest, testCompressionZLib) {
     ClientConfiguration config;
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns1/testCompressionZLib";
@@ -555,8 +546,7 @@ TEST(BasicEndToEndTest, testMessageTooBig)
     ASSERT_EQ(ResultOk, client.close());
 }
 
-    TEST(BasicEndToEndTest, testConfigurationFile)
-{
+TEST(BasicEndToEndTest, testConfigurationFile) {
     ClientConfiguration config1;
     config1.setOperationTimeoutSeconds(100);
     config1.setIOThreads(10);
@@ -570,19 +560,18 @@ TEST(BasicEndToEndTest, testMessageTooBig)
     ASSERT_EQ(10, config2.getIOThreads());
     ASSERT_EQ(1, config2.getMessageListenerThreads());
     ASSERT_EQ(config2.getLogConfFilePath().compare("/tmp/"), 0);
-
 }
 
-TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
-{
+TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy) {
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns/partition-testSinglePartitionRoutingPolicy";
 
     // call admin api to make it partitioned
-    std::string url = adminUrl + "admin/persistent/prop/unit/ns/partition-testSinglePartitionRoutingPolicy/partitions";
+    std::string url =
+        adminUrl + "admin/persistent/prop/unit/ns/partition-testSinglePartitionRoutingPolicy/partitions";
     int res = makePutRequest(url, "5");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     Producer producer;
@@ -595,7 +584,7 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
     ASSERT_EQ(ResultOk, result);
 
     ASSERT_EQ(ResultOk, result);
-    for (int i = 0; i < 10; i++ ) {
+    for (int i = 0; i < 10; i++) {
         boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
         long nanoSeconds = t.time_of_day().total_nanoseconds();
         std::stringstream ss;
@@ -615,16 +604,14 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
     client.close();
 }
 
-    TEST(BasicEndToEndTest, testNamespaceName)
-{
+TEST(BasicEndToEndTest, testNamespaceName) {
     boost::shared_ptr<NamespaceName> nameSpaceName = NamespaceName::get("property", "bf1", "nameSpace");
     ASSERT_STREQ(nameSpaceName->getCluster().c_str(), "bf1");
     ASSERT_STREQ(nameSpaceName->getLocalName().c_str(), "nameSpace");
     ASSERT_STREQ(nameSpaceName->getProperty().c_str(), "property");
 }
 
-    TEST(BasicEndToEndTest, testConsumerClose)
-{
+TEST(BasicEndToEndTest, testConsumerClose) {
     ClientConfiguration config;
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns1/testConsumerClose";
@@ -635,16 +622,17 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
     ASSERT_EQ(consumer.close(), ResultAlreadyClosed);
 }
 
-    TEST(BasicEndToEndTest, testDuplicateConsumerCreationOnPartitionedTopic)
-{
+TEST(BasicEndToEndTest, testDuplicateConsumerCreationOnPartitionedTopic) {
     Client client(lookupUrl);
-    std::string topicName = "persistent://prop/unit/ns/partition-testDuplicateConsumerCreationOnPartitionedTopic";
+    std::string topicName =
+        "persistent://prop/unit/ns/partition-testDuplicateConsumerCreationOnPartitionedTopic";
 
     // call admin api to make it partitioned
-    std::string url = adminUrl + "admin/persistent/prop/unit/ns/testDuplicateConsumerCreationOnPartitionedTopic/partitions";
+    std::string url =
+        adminUrl + "admin/persistent/prop/unit/ns/testDuplicateConsumerCreationOnPartitionedTopic/partitions";
     int res = makePutRequest(url, "5");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     usleep(2 * 1000 * 1000);
@@ -656,7 +644,7 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
 
     Result result = client.createProducer(topicName, producer);
     ASSERT_EQ(ResultOk, result);
-    for (int i = 0; i < 10; i++ ) {
+    for (int i = 0; i < 10; i++) {
         boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
         long nanoSeconds = t.time_of_day().total_nanoseconds();
         std::stringstream ss;
@@ -665,7 +653,6 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
         ASSERT_EQ(ResultOk, producer.send(msg));
     }
 
-
     LOG_INFO("Creating Subscriber");
     std::string consumerId = "CONSUMER";
     ConsumerConfiguration tempConsConfig;
@@ -673,29 +660,27 @@ TEST(BasicEndToEndTest, testSinglePartitionRoutingPolicy)
     ConsumerConfiguration consConfig = tempConsConfig;
     ASSERT_EQ(consConfig.getConsumerType(), ConsumerExclusive);
     Consumer consumer;
-    Result subscribeResult = client.subscribe(topicName, consumerId,
-        consConfig, consumer);
+    Result subscribeResult = client.subscribe(topicName, consumerId, consConfig, consumer);
     ASSERT_EQ(ResultOk, subscribeResult);
 
     LOG_INFO("Creating Another Subscriber");
     Consumer consumer2;
     ASSERT_EQ(consumer2.getSubscriptionName(), "");
-    subscribeResult = client.subscribe(topicName, consumerId,
-        consConfig, consumer2);
+    subscribeResult = client.subscribe(topicName, consumerId, consConfig, consumer2);
     ASSERT_EQ(ResultConsumerBusy, subscribeResult);
     consumer.close();
     producer.close();
 }
 
-TEST(BasicEndToEndTest, testRoundRobinRoutingPolicy)
-{
+TEST(BasicEndToEndTest, testRoundRobinRoutingPolicy) {
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns/partition-testRoundRobinRoutingPolicy";
     // call admin api to make it partitioned
-    std::string url = adminUrl + "admin/persistent/prop/unit/ns/partition-testRoundRobinRoutingPolicy/partitions";
+    std::string url =
+        adminUrl + "admin/persistent/prop/unit/ns/partition-testRoundRobinRoutingPolicy/partitions";
     int res = makePutRequest(url, "5");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     Producer producer;
@@ -721,13 +706,14 @@ TEST(BasicEndToEndTest, testRoundRobinRoutingPolicy)
 
         std::stringstream partitionedConsumerId;
         partitionedConsumerId << consumerId << i;
-        subscribeResult = client.subscribe(partitionedTopicName.str(), partitionedConsumerId.str(), consConfig, consumer[i]);
+        subscribeResult = client.subscribe(partitionedTopicName.str(), partitionedConsumerId.str(),
+                                           consConfig, consumer[i]);
 
         ASSERT_EQ(ResultOk, subscribeResult);
         ASSERT_EQ(consumer[i].getTopic(), partitionedTopicName.str());
     }
 
-    for (int i = 0; i < 10; i++ ) {
+    for (int i = 0; i < 10; i++) {
         boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
         long nanoSeconds = t.time_of_day().total_nanoseconds();
         std::stringstream ss;
@@ -749,18 +735,16 @@ TEST(BasicEndToEndTest, testRoundRobinRoutingPolicy)
     }
     producer.close();
     client.shutdown();
-
 }
 
-TEST(BasicEndToEndTest, testMessageListener)
-{
+TEST(BasicEndToEndTest, testMessageListener) {
     Client client(lookupUrl);
     std::string topicName = "persistent://prop/unit/ns/partition-testMessageListener";
     // call admin api to make it partitioned
     std::string url = adminUrl + "admin/persistent/prop/unit/ns/partition-testMessageListener/partitions";
     int res = makePutRequest(url, "5");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     Producer producer;
@@ -777,7 +761,7 @@ TEST(BasicEndToEndTest, testMessageListener)
     result = client.subscribe(topicName, "subscription-A", consumerConfig, consumer);
 
     ASSERT_EQ(ResultOk, result);
-    for (int i = 0; i < 10; i++ ) {
+    for (int i = 0; i < 10; i++) {
         boost::posix_time::ptime t(boost::posix_time::microsec_clock::universal_time());
         long nanoSeconds = t.time_of_day().total_nanoseconds();
         std::stringstream ss;
@@ -794,19 +778,19 @@ TEST(BasicEndToEndTest, testMessageListener)
     client.close();
 }
 
-TEST(BasicEndToEndTest, testMessageListenerPause)
-{
+TEST(BasicEndToEndTest, testMessageListenerPause) {
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/partition-testMessageListenerPause";
 
     // call admin api to make it partitioned
-    std::string url = adminUrl + "admin/persistent/property/cluster/namespace/partition-testMessageListener-pauses/partitions";
+    std::string url =
+        adminUrl +
+        "admin/persistent/property/cluster/namespace/partition-testMessageListener-pauses/partitions";
     int res = makePutRequest(url, "5");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
-
     Producer producer;
     ProducerConfiguration producerConfiguration;
     producerConfiguration.setPartitionsRoutingMode(ProducerConfiguration::UseSinglePartition);
@@ -825,8 +809,8 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     result = client.subscribe(topicName, "subscription-name", consumerConfig, consumer);
     ASSERT_EQ(ResultOk, result);
     int temp = 1000;
-    for (int i = 0; i < 10000; i++ ) {
-        if(i && i%1000 == 0) {
+    for (int i = 0; i < 10000; i++) {
+        if (i && i % 1000 == 0) {
             usleep(2 * 1000 * 1000);
             ASSERT_EQ(globalCount, temp);
             consumer.resumeMessageListener();
@@ -850,8 +834,7 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     client.close();
 }
 
-    TEST(BasicEndToEndTest, testResendViaSendCallback)
-{
+TEST(BasicEndToEndTest, testResendViaSendCallback) {
     ClientConfiguration clientConfiguration;
     clientConfiguration.setIOThreads(1);
     Client client(lookupUrl, clientConfiguration);
@@ -864,7 +847,8 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
 
     // Setting timeout of 1 ms
     producerConfiguration.setSendTimeout(1);
-    client.createProducerAsync(topicName, producerConfiguration, WaitForCallbackValue<Producer>(producerPromise));
+    client.createProducerAsync(topicName, producerConfiguration,
+                               WaitForCallbackValue<Producer>(producerPromise));
     Future<Result, Producer> producerFuture = producerPromise.getFuture();
     Result result = producerFuture.get(producer);
     ASSERT_EQ(ResultOk, result);
@@ -872,7 +856,7 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     // Send asynchronously for 3 seconds
     // Expect timeouts since we have set timeout to 1 ms
     // On receiving timeout send the message using the Pulsar client IO thread via cb function.
-    for (int i = 0; i<10000; i++) {
+    for (int i = 0; i < 10000; i++) {
         producer.sendAsync(MessageBuilder().build(), boost::bind(resendMessage, _1, _2, producer));
     }
     // 3 seconds
@@ -882,8 +866,7 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     ASSERT_GE(globalResendMessageCount, 3);
 }
 
-    TEST(BasicEndToEndTest, testStatsLatencies)
-{
+TEST(BasicEndToEndTest, testStatsLatencies) {
     ClientConfiguration config;
     config.setIOThreads(1);
     config.setMessageListenerThreads(1);
@@ -925,8 +908,10 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     std::string prefix = "msg-stats-";
     for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                "msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, boost::bind(&sendCallBack, _1, _2, prefix, 15, 20 * 1e3));
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -937,35 +922,34 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     }
 
     // Get latencies
-    LatencyAccumulator totalLatencyAccumulator =
-            producerStatsImplPtr->getTotalLatencyAccumulator();
-    boost::accumulators::detail::extractor_result<LatencyAccumulator,
-            boost::accumulators::tag::extended_p_square>::type totalLatencies =
-            boost::accumulators::extended_p_square(totalLatencyAccumulator);
+    LatencyAccumulator totalLatencyAccumulator = producerStatsImplPtr->getTotalLatencyAccumulator();
+    boost::accumulators::detail::extractor_result<
+        LatencyAccumulator, boost::accumulators::tag::extended_p_square>::type totalLatencies =
+        boost::accumulators::extended_p_square(totalLatencyAccumulator);
 
     LatencyAccumulator latencyAccumulator = producerStatsImplPtr->getLatencyAccumulator();
-    boost::accumulators::detail::extractor_result<LatencyAccumulator,
-            boost::accumulators::tag::extended_p_square>::type latencies =
-            boost::accumulators::extended_p_square(latencyAccumulator);
+    boost::accumulators::detail::extractor_result<
+        LatencyAccumulator, boost::accumulators::tag::extended_p_square>::type latencies =
+        boost::accumulators::extended_p_square(latencyAccumulator);
 
     // Since 15% of the messages have a delay of
-    ASSERT_EQ((uint64_t )latencies[1], (uint64_t )totalLatencies[1]);
-    ASSERT_EQ((uint64_t )latencies[2], (uint64_t )totalLatencies[2]);
-    ASSERT_EQ((uint64_t )latencies[3], (uint64_t )totalLatencies[3]);
+    ASSERT_EQ((uint64_t)latencies[1], (uint64_t)totalLatencies[1]);
+    ASSERT_EQ((uint64_t)latencies[2], (uint64_t)totalLatencies[2]);
+    ASSERT_EQ((uint64_t)latencies[3], (uint64_t)totalLatencies[3]);
 
-    ASSERT_GE((uint64_t )latencies[1], 20 * 1000);
-    ASSERT_GE((uint64_t )latencies[2], 20 * 1000);
-    ASSERT_GE((uint64_t )latencies[3], 20 * 1000);
+    ASSERT_GE((uint64_t)latencies[1], 20 * 1000);
+    ASSERT_GE((uint64_t)latencies[2], 20 * 1000);
+    ASSERT_GE((uint64_t)latencies[3], 20 * 1000);
 
-    ASSERT_GE((uint64_t )totalLatencies[1], 20 * 1000);
-    ASSERT_GE((uint64_t )totalLatencies[2], 20 * 1000);
-    ASSERT_GE((uint64_t )totalLatencies[3], 20 * 1000);
+    ASSERT_GE((uint64_t)totalLatencies[1], 20 * 1000);
+    ASSERT_GE((uint64_t)totalLatencies[2], 20 * 1000);
+    ASSERT_GE((uint64_t)totalLatencies[3], 20 * 1000);
 
     while (producerStatsImplPtr->getNumMsgsSent() != 0) {
-        usleep(1e6); // wait till stats flush
+        usleep(1e6);  // wait till stats flush
     }
 
-    usleep(1 * 1e6); // 1 second
+    usleep(1 * 1e6);  // 1 second
 
     latencyAccumulator = producerStatsImplPtr->getLatencyAccumulator();
     latencies = boost::accumulators::extended_p_square(latencyAccumulator);
@@ -973,17 +957,17 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
     totalLatencyAccumulator = producerStatsImplPtr->getTotalLatencyAccumulator();
     totalLatencies = boost::accumulators::extended_p_square(totalLatencyAccumulator);
 
-    ASSERT_NE((uint64_t )latencies[1], (uint64_t )totalLatencies[1]);
-    ASSERT_NE((uint64_t )latencies[2], (uint64_t )totalLatencies[2]);
-    ASSERT_NE((uint64_t )latencies[3], (uint64_t )totalLatencies[3]);
+    ASSERT_NE((uint64_t)latencies[1], (uint64_t)totalLatencies[1]);
+    ASSERT_NE((uint64_t)latencies[2], (uint64_t)totalLatencies[2]);
+    ASSERT_NE((uint64_t)latencies[3], (uint64_t)totalLatencies[3]);
 
-    ASSERT_EQ((uint64_t )latencies[1], 0);
-    ASSERT_EQ((uint64_t )latencies[2], 0);
-    ASSERT_EQ((uint64_t )latencies[3], 0);
+    ASSERT_EQ((uint64_t)latencies[1], 0);
+    ASSERT_EQ((uint64_t)latencies[2], 0);
+    ASSERT_EQ((uint64_t)latencies[3], 0);
 
-    ASSERT_GE((uint64_t )totalLatencies[1], 20 * 1000);
-    ASSERT_GE((uint64_t )totalLatencies[2], 20 * 1000);
-    ASSERT_GE((uint64_t )totalLatencies[3], 20 * 1000);
+    ASSERT_GE((uint64_t)totalLatencies[1], 20 * 1000);
+    ASSERT_GE((uint64_t)totalLatencies[2], 20 * 1000);
+    ASSERT_GE((uint64_t)totalLatencies[3], 20 * 1000);
 
     Message receivedMsg;
     int i = 0;
@@ -991,8 +975,8 @@ TEST(BasicEndToEndTest, testMessageListenerPause)
 
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
         std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
         ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(PulsarFriend::sum(consumerStatsImplPtr->getTotalReceivedMsgMap()), i);
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
@@ -1069,10 +1053,12 @@ TEST(BasicEndToEndTest, testHandlerReconnectionLogic) {
 
     int numOfMessages = 10;
     std::string propertyName = "msgIndex";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = "msg-" + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                propertyName, boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty(propertyName, boost::lexical_cast<std::string>(i))
+                          .build();
         if (i % 3 == 1) {
             ProducerImpl& pImpl = PulsarFriend::getProducerImpl(producer);
             ClientConnectionPtr clientConnectionPtr;
@@ -1080,7 +1066,7 @@ TEST(BasicEndToEndTest, testHandlerReconnectionLogic) {
                 ClientConnectionWeakPtr clientConnectionWeakPtr = PulsarFriend::getClientConnection(pImpl);
                 clientConnectionPtr = clientConnectionWeakPtr.lock();
                 usleep(1 * 1e6);
-            } while(!clientConnectionPtr);
+            } while (!clientConnectionPtr);
             oldConnections.push_back(clientConnectionPtr);
             clientConnectionPtr->close();
         }
@@ -1091,7 +1077,7 @@ TEST(BasicEndToEndTest, testHandlerReconnectionLogic) {
     std::set<std::string> receivedMsgIndex;
 
     Message msg;
-    while(consumer.receive(msg, 30000) == ResultOk) {
+    while (consumer.receive(msg, 30000) == ResultOk) {
         receivedMsgContent.insert(msg.getDataAsString());
         receivedMsgIndex.insert(msg.getProperty(propertyName));
     }
@@ -1102,7 +1088,7 @@ TEST(BasicEndToEndTest, testHandlerReconnectionLogic) {
     oldConnections.push_back(clientConnectionPtr);
     clientConnectionPtr->close();
 
-    while(consumer.receive(msg, 30000) == ResultOk) {
+    while (consumer.receive(msg, 30000) == ResultOk) {
         consumer.acknowledge(msg);
         receivedMsgContent.insert(msg.getDataAsString());
         receivedMsgIndex.insert(msg.getProperty(propertyName));
@@ -1111,8 +1097,9 @@ TEST(BasicEndToEndTest, testHandlerReconnectionLogic) {
     ASSERT_EQ(receivedMsgContent.size(), 10);
     ASSERT_EQ(receivedMsgIndex.size(), 10);
 
-    for (int i = 0; i<numOfMessages; i++) {
-        ASSERT_TRUE(receivedMsgContent.find("msg-" + boost::lexical_cast<std::string>(i)) != receivedMsgContent.end());
+    for (int i = 0; i < numOfMessages; i++) {
+        ASSERT_TRUE(receivedMsgContent.find("msg-" + boost::lexical_cast<std::string>(i)) !=
+                    receivedMsgContent.end());
         ASSERT_TRUE(receivedMsgIndex.find(boost::lexical_cast<std::string>(i)) != receivedMsgIndex.end());
     }
 }
diff --git a/pulsar-client-cpp/tests/BatchMessageTest.cc b/pulsar-client-cpp/tests/BatchMessageTest.cc
index a138e0930..7ba682f37 100644
--- a/pulsar-client-cpp/tests/BatchMessageTest.cc
+++ b/pulsar-client-cpp/tests/BatchMessageTest.cc
@@ -45,7 +45,7 @@ static std::string lookupUrl = "pulsar://localhost:8885";
 static std::string adminUrl = "http://localhost:8765/";
 
 // ecpoch time in seconds
-long epochTime=time(NULL);
+long epochTime = time(NULL);
 
 static void messageListenerFunction(Consumer consumer, const Message& msg) {
     globalCount++;
@@ -81,12 +81,11 @@ TEST(BatchMessageTest, testProducerConfig) {
 }
 
 TEST(BatchMessageTest, testProducerTimeout) {
-    std::string testName=boost::lexical_cast<std::string>(epochTime) + "testProducerTimeout";
+    std::string testName = boost::lexical_cast<std::string>(epochTime) + "testProducerTimeout";
 
     ClientConfiguration clientConf;
     clientConf.setStatsIntervalInSeconds(1);
 
-
     Client client(lookupUrl, clientConf);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
@@ -128,29 +127,34 @@ TEST(BatchMessageTest, testProducerTimeout) {
     ProducerStatsImplPtr producerStatsImplPtr = PulsarFriend::getProducerStatsPtr(producer);
     // Send Asynchronously
     std::string prefix = "msg-batch-test-produce-timeout-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty("type", "batch").setProperty("msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("type", "batch")
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         LOG_DEBUG("sending message " << messageContent);
         clock_t start, end;
         /* Start the timer */
         start = time(NULL);
-        LOG_DEBUG("start = "<<start);
+        LOG_DEBUG("start = " << start);
         producer.send(msg);
         /* End the timer */
         end = time(NULL);
-        LOG_DEBUG("end = "<<end);
+        LOG_DEBUG("end = " << end);
         // Greater than or equal to since there may be delay in sending messaging
-        ASSERT_GE((double)(end - start), timeout/1000.0);
-        ASSERT_EQ(producerStatsImplPtr->getTotalMsgsSent(), i+1);
-        ASSERT_EQ(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), i+1);
+        ASSERT_GE((double)(end - start), timeout / 1000.0);
+        ASSERT_EQ(producerStatsImplPtr->getTotalMsgsSent(), i + 1);
+        ASSERT_EQ(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), i + 1);
     }
 
     Message receivedMsg;
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
         std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
-        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
         ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(receivedMsg.getProperty("type"), "batch");
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
@@ -161,9 +165,8 @@ TEST(BatchMessageTest, testProducerTimeout) {
 }
 
 TEST(BatchMessageTest, testBatchSizeInBytes) {
-    std::string testName=boost::lexical_cast<std::string>(epochTime) + "testBatchSizeInBytes";
-    globalTestBatchMessagesCounter=0;
-
+    std::string testName = boost::lexical_cast<std::string>(epochTime) + "testBatchSizeInBytes";
+    globalTestBatchMessagesCounter = 0;
 
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
@@ -205,14 +208,17 @@ TEST(BatchMessageTest, testBatchSizeInBytes) {
     ProducerStatsImplPtr producerStatsImplPtr = PulsarFriend::getProducerStatsPtr(producer);
     // Send Asynchronously
     std::string prefix = "12345678";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty("msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
-        ASSERT_EQ(producerStatsImplPtr->getNumMsgsSent(), i+1);
-        ASSERT_LT(PulsarFriend::sum(producerStatsImplPtr->getSendMap()), i+1);
-        ASSERT_EQ(producerStatsImplPtr->getTotalMsgsSent(), i+1);
-        ASSERT_LT(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), i+1);
+        ASSERT_EQ(producerStatsImplPtr->getNumMsgsSent(), i + 1);
+        ASSERT_LT(PulsarFriend::sum(producerStatsImplPtr->getSendMap()), i + 1);
+        ASSERT_EQ(producerStatsImplPtr->getTotalMsgsSent(), i + 1);
+        ASSERT_LT(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), i + 1);
         LOG_DEBUG("sending message " << messageContent);
     }
 
@@ -220,16 +226,17 @@ TEST(BatchMessageTest, testBatchSizeInBytes) {
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
         std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
-        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_LT(pulsar::PulsarFriend::getBatchIndex((BatchMessageId&)receivedMsg.getMessageId()),2);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_LT(pulsar::PulsarFriend::getBatchIndex((BatchMessageId&)receivedMsg.getMessageId()), 2);
         ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
     }
 
     // Check stats
-    ASSERT_EQ(PulsarFriend::sum(producerStatsImplPtr->getSendMap()),numOfMessages);
-    ASSERT_EQ(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()),numOfMessages);
+    ASSERT_EQ(PulsarFriend::sum(producerStatsImplPtr->getSendMap()), numOfMessages);
+    ASSERT_EQ(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), numOfMessages);
 
     // Number of messages produced
     ASSERT_EQ(globalTestBatchMessagesCounter, numOfMessages);
@@ -239,8 +246,8 @@ TEST(BatchMessageTest, testBatchSizeInBytes) {
 }
 
 TEST(BatchMessageTest, testSmallReceiverQueueSize) {
-    std::string testName=boost::lexical_cast<std::string>(epochTime) + "testSmallReceiverQueueSize";
-    globalTestBatchMessagesCounter=0;
+    std::string testName = boost::lexical_cast<std::string>(epochTime) + "testSmallReceiverQueueSize";
+    globalTestBatchMessagesCounter = 0;
 
     ClientConfiguration clientConf;
     clientConf.setStatsIntervalInSeconds(20);
@@ -271,7 +278,8 @@ TEST(BatchMessageTest, testSmallReceiverQueueSize) {
     consumerConfig.setReceiverQueueSize(41);
 
     Promise<Result, Consumer> consumerPromise;
-    client.subscribeAsync(topicName, subName, consumerConfig, WaitForCallbackValue<Consumer>(consumerPromise));
+    client.subscribeAsync(topicName, subName, consumerConfig,
+                          WaitForCallbackValue<Consumer>(consumerPromise));
     Future<Result, Consumer> consumerFuture = consumerPromise.getFuture();
     result = consumerFuture.get(consumer);
     ASSERT_EQ(ResultOk, result);
@@ -289,12 +297,15 @@ TEST(BatchMessageTest, testSmallReceiverQueueSize) {
     ProducerStatsImplPtr producerStatsImplPtr = PulsarFriend::getProducerStatsPtr(producer);
     // Send Asynchronously
     std::string prefix = testName;
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty("msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
-        ASSERT_EQ(producerStatsImplPtr->getTotalMsgsSent(), i+1);
-        ASSERT_LE(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), i+1);
+        ASSERT_EQ(producerStatsImplPtr->getTotalMsgsSent(), i + 1);
+        ASSERT_LE(PulsarFriend::sum(producerStatsImplPtr->getTotalSendMap()), i + 1);
         LOG_DEBUG("sending message " << messageContent);
     }
 
@@ -303,14 +314,16 @@ TEST(BatchMessageTest, testSmallReceiverQueueSize) {
     for (i = 0; i < numOfMessages; i++) {
         consumer.receive(receivedMsg);
         std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
-        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
         ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
     }
 
     ConsumerStatsImplPtr consumerStatsImplPtr = PulsarFriend::getConsumerStatsPtr(consumer);
-    unsigned long t = consumerStatsImplPtr->getAckedMsgMap().at(std::make_pair<Result, proto::CommandAck_AckType>(ResultOk, proto::CommandAck_AckType_Individual));
+    unsigned long t = consumerStatsImplPtr->getAckedMsgMap().at(
+        std::make_pair<Result, proto::CommandAck_AckType>(ResultOk, proto::CommandAck_AckType_Individual));
     ASSERT_EQ(t, numOfMessages);
     ASSERT_EQ(PulsarFriend::sum(consumerStatsImplPtr->getAckedMsgMap()), numOfMessages);
     ASSERT_EQ(PulsarFriend::sum(consumerStatsImplPtr->getTotalAckedMsgMap()), numOfMessages);
@@ -349,10 +362,9 @@ TEST(BatchMessageTest, testIndividualAck) {
     conf.setBatchingMaxMessages(batchSize);
     conf.setBatchingEnabled(true);
 
-    Promise < Result, Producer > producerPromise;
-    client.createProducerAsync(topicName, conf,
-                               WaitForCallbackValue < Producer > (producerPromise));
-    Future < Result, Producer > producerFuture = producerPromise.getFuture();
+    Promise<Result, Producer> producerPromise;
+    client.createProducerAsync(topicName, conf, WaitForCallbackValue<Producer>(producerPromise));
+    Future<Result, Producer> producerFuture = producerPromise.getFuture();
     Result result = producerFuture.get(producer);
     ASSERT_EQ(ResultOk, result);
 
@@ -360,10 +372,10 @@ TEST(BatchMessageTest, testIndividualAck) {
     ConsumerConfiguration consumerConfig;
     consumerConfig.setReceiverQueueSize(1);
 
-    Promise < Result, Consumer > consumerPromise;
+    Promise<Result, Consumer> consumerPromise;
     client.subscribeAsync(topicName, subName, consumerConfig,
-                          WaitForCallbackValue < Consumer > (consumerPromise));
-    Future < Result, Consumer > consumerFuture = consumerPromise.getFuture();
+                          WaitForCallbackValue<Consumer>(consumerPromise));
+    Future<Result, Consumer> consumerFuture = consumerPromise.getFuture();
     result = consumerFuture.get(consumer);
     ASSERT_EQ(ResultOk, result);
 
@@ -380,9 +392,11 @@ TEST(BatchMessageTest, testIndividualAck) {
     // Send Asynchronously
     std::string prefix = testName;
     for (int i = 0; i < numOfMessages; i++) {
-        std::string messageContent = prefix + boost::lexical_cast < std::string > (i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                "msgIndex", boost::lexical_cast < std::string > (i)).build();
+        std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -390,10 +404,10 @@ TEST(BatchMessageTest, testIndividualAck) {
     Message receivedMsg;
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Ack every 2nd message
         if (i % 2 == 0) {
@@ -414,10 +428,10 @@ TEST(BatchMessageTest, testIndividualAck) {
 
     i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Ack every first 5 and 10th message
         if (i <= 5 || i == 10) {
@@ -436,10 +450,11 @@ TEST(BatchMessageTest, testIndividualAck) {
 
     i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i + numOfMessages/2);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++ + numOfMessages/2));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i + numOfMessages / 2);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"),
+                  boost::lexical_cast<std::string>(i++ + numOfMessages / 2));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Ack first 4 message only
         if (i <= 4) {
@@ -458,10 +473,11 @@ TEST(BatchMessageTest, testIndividualAck) {
 
     i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i + numOfMessages/2);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++ + numOfMessages/2));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i + numOfMessages / 2);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"),
+                  boost::lexical_cast<std::string>(i++ + numOfMessages / 2));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Ack all
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
@@ -494,7 +510,7 @@ TEST(BatchMessageTest, testCumulativeAck) {
     std::string subName = "subscription-name";
     Producer producer;
 
-    globalTestBatchMessagesCounter=0;
+    globalTestBatchMessagesCounter = 0;
 
     // Enable batching on producer side
     int batchSize = 5;
@@ -503,10 +519,9 @@ TEST(BatchMessageTest, testCumulativeAck) {
     conf.setBatchingMaxMessages(batchSize);
     conf.setBatchingEnabled(true);
 
-    Promise < Result, Producer > producerPromise;
-    client.createProducerAsync(topicName, conf,
-                               WaitForCallbackValue < Producer > (producerPromise));
-    Future < Result, Producer > producerFuture = producerPromise.getFuture();
+    Promise<Result, Producer> producerPromise;
+    client.createProducerAsync(topicName, conf, WaitForCallbackValue<Producer>(producerPromise));
+    Future<Result, Producer> producerFuture = producerPromise.getFuture();
     Result result = producerFuture.get(producer);
     ASSERT_EQ(ResultOk, result);
 
@@ -514,10 +529,10 @@ TEST(BatchMessageTest, testCumulativeAck) {
     ConsumerConfiguration consumerConfig;
     consumerConfig.setReceiverQueueSize(1);
 
-    Promise < Result, Consumer > consumerPromise;
+    Promise<Result, Consumer> consumerPromise;
     client.subscribeAsync(topicName, subName, consumerConfig,
-                          WaitForCallbackValue < Consumer > (consumerPromise));
-    Future < Result, Consumer > consumerFuture = consumerPromise.getFuture();
+                          WaitForCallbackValue<Consumer>(consumerPromise));
+    Future<Result, Consumer> consumerFuture = consumerPromise.getFuture();
     result = consumerFuture.get(consumer);
     ASSERT_EQ(ResultOk, result);
 
@@ -535,9 +550,11 @@ TEST(BatchMessageTest, testCumulativeAck) {
     // Send Asynchronously
     std::string prefix = testName;
     for (int i = 0; i < numOfMessages; i++) {
-        std::string messageContent = prefix + boost::lexical_cast < std::string > (i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                "msgIndex", boost::lexical_cast < std::string > (i)).build();
+        std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -546,10 +563,10 @@ TEST(BatchMessageTest, testCumulativeAck) {
     int i = 0;
     ConsumerStatsImplPtr consumerStatsImplPtr = PulsarFriend::getConsumerStatsPtr(consumer);
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Cumm. Ack 7th message
         if (i == 7) {
@@ -563,7 +580,8 @@ TEST(BatchMessageTest, testCumulativeAck) {
     ASSERT_EQ(consumerStatsImplPtr->getReceivedMsgMap().at(ResultTimeout), 1);
     ASSERT_EQ(PulsarFriend::sum(consumerStatsImplPtr->getAckedMsgMap()), 1);
     ASSERT_EQ(producerStatsImplPtr->getNumBytesSent(), consumerStatsImplPtr->getNumBytesRecieved());
-    unsigned long t = consumerStatsImplPtr->getAckedMsgMap().at(std::make_pair<Result, proto::CommandAck_AckType>(ResultOk, proto::CommandAck_AckType_Cumulative));
+    unsigned long t = consumerStatsImplPtr->getAckedMsgMap().at(
+        std::make_pair<Result, proto::CommandAck_AckType>(ResultOk, proto::CommandAck_AckType_Cumulative));
     ASSERT_EQ(t, 1);
 
     // Number of messages produced
@@ -581,10 +599,10 @@ TEST(BatchMessageTest, testCumulativeAck) {
     consumerStatsImplPtr = PulsarFriend::getConsumerStatsPtr(consumer);
     i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i + 5);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++ + 5));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i + 5);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++ + 5));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Ack 10th message
         if (i == 10) {
@@ -593,7 +611,8 @@ TEST(BatchMessageTest, testCumulativeAck) {
     }
 
     ASSERT_EQ(PulsarFriend::sum(consumerStatsImplPtr->getAckedMsgMap()), 1);
-    t = consumerStatsImplPtr->getAckedMsgMap().at(std::make_pair<Result, proto::CommandAck_AckType>(ResultOk, proto::CommandAck_AckType_Cumulative));
+    t = consumerStatsImplPtr->getAckedMsgMap().at(
+        std::make_pair<Result, proto::CommandAck_AckType>(ResultOk, proto::CommandAck_AckType_Cumulative));
     ASSERT_EQ(t, 1);
 
     // Number of messages consumed
@@ -612,13 +631,12 @@ TEST(BatchMessageTest, testCumulativeAck) {
 TEST(BatchMessageTest, testMixedAck) {
     std::string testName = boost::lexical_cast<std::string>(epochTime) + "testMixedAck";
 
-
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
     Producer producer;
 
-    globalTestBatchMessagesCounter=0;
+    globalTestBatchMessagesCounter = 0;
 
     // Enable batching on producer side
     int batchSize = 5;
@@ -627,19 +645,18 @@ TEST(BatchMessageTest, testMixedAck) {
     conf.setBatchingMaxMessages(batchSize);
     conf.setBatchingEnabled(true);
 
-    Promise < Result, Producer > producerPromise;
-    client.createProducerAsync(topicName, conf,
-                               WaitForCallbackValue < Producer > (producerPromise));
-    Future < Result, Producer > producerFuture = producerPromise.getFuture();
+    Promise<Result, Producer> producerPromise;
+    client.createProducerAsync(topicName, conf, WaitForCallbackValue<Producer>(producerPromise));
+    Future<Result, Producer> producerFuture = producerPromise.getFuture();
     Result result = producerFuture.get(producer);
     ASSERT_EQ(ResultOk, result);
 
     Consumer consumer;
     ConsumerConfiguration consumerConfig;
-    Promise < Result, Consumer > consumerPromise;
+    Promise<Result, Consumer> consumerPromise;
     client.subscribeAsync(topicName, subName, consumerConfig,
-                          WaitForCallbackValue < Consumer > (consumerPromise));
-    Future < Result, Consumer > consumerFuture = consumerPromise.getFuture();
+                          WaitForCallbackValue<Consumer>(consumerPromise));
+    Future<Result, Consumer> consumerFuture = consumerPromise.getFuture();
     result = consumerFuture.get(consumer);
     ASSERT_EQ(ResultOk, result);
 
@@ -656,9 +673,11 @@ TEST(BatchMessageTest, testMixedAck) {
     // Send Asynchronously
     std::string prefix = testName;
     for (int i = 0; i < numOfMessages; i++) {
-        std::string messageContent = prefix + boost::lexical_cast < std::string > (i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                "msgIndex", boost::lexical_cast < std::string > (i)).build();
+        std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -666,10 +685,10 @@ TEST(BatchMessageTest, testMixedAck) {
     Message receivedMsg;
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Cumm. Ack 14th message
         if (i == 14) {
@@ -690,10 +709,10 @@ TEST(BatchMessageTest, testMixedAck) {
 
     i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i + 10);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++ + 10));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i + 10);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++ + 10));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         // Cumm Ack 9th message
         if (i == 4) {
@@ -720,13 +739,12 @@ TEST(BatchMessageTest, testMixedAck) {
 TEST(BatchMessageTest, testPermits) {
     std::string testName = boost::lexical_cast<std::string>(epochTime) + "testPermits";
 
-
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
     Producer producer;
 
-    globalTestBatchMessagesCounter=0;
+    globalTestBatchMessagesCounter = 0;
 
     // Enable batching on producer side
     int batchSize = 10;
@@ -736,10 +754,9 @@ TEST(BatchMessageTest, testPermits) {
     conf.setBatchingMaxPublishDelayMs(5);
     conf.setBatchingEnabled(true);
 
-    Promise < Result, Producer > producerPromise;
-    client.createProducerAsync(topicName, conf,
-                               WaitForCallbackValue < Producer > (producerPromise));
-    Future < Result, Producer > producerFuture = producerPromise.getFuture();
+    Promise<Result, Producer> producerPromise;
+    client.createProducerAsync(topicName, conf, WaitForCallbackValue<Producer>(producerPromise));
+    Future<Result, Producer> producerFuture = producerPromise.getFuture();
     Result result = producerFuture.get(producer);
     ASSERT_EQ(ResultOk, result);
 
@@ -747,10 +764,10 @@ TEST(BatchMessageTest, testPermits) {
     ConsumerConfiguration consumerConfig;
     consumerConfig.setReceiverQueueSize(5);
 
-    Promise < Result, Consumer > consumerPromise;
+    Promise<Result, Consumer> consumerPromise;
     client.subscribeAsync(topicName, subName, consumerConfig,
-                          WaitForCallbackValue < Consumer > (consumerPromise));
-    Future < Result, Consumer > consumerFuture = consumerPromise.getFuture();
+                          WaitForCallbackValue<Consumer>(consumerPromise));
+    Future<Result, Consumer> consumerFuture = consumerPromise.getFuture();
     result = consumerFuture.get(consumer);
     ASSERT_EQ(ResultOk, result);
 
@@ -767,9 +784,11 @@ TEST(BatchMessageTest, testPermits) {
     // Send Asynchronously
     std::string prefix = testName;
     for (int i = 0; i < numOfMessages; i++) {
-        std::string messageContent = prefix + boost::lexical_cast < std::string > (i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                "msgIndex", boost::lexical_cast < std::string > (i)).build();
+        std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -779,10 +798,10 @@ TEST(BatchMessageTest, testPermits) {
     Message receivedMsg;
     int i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         ASSERT_EQ(ResultOk, consumer.acknowledgeCumulative(receivedMsg));
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
@@ -802,23 +821,25 @@ TEST(BatchMessageTest, testPermits) {
     globalTestBatchMessagesCounter = 0;
     // Send Asynchronously
     for (int i = 0; i < numOfMessages; i++) {
-        std::string messageContent = prefix + boost::lexical_cast < std::string > (i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty(
-                "msgIndex", boost::lexical_cast < std::string > (i)).build();
+        std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBack);
         LOG_DEBUG("sending message " << messageContent);
     }
     usleep(5 * 1000 * 1000);
 
     ASSERT_LE(ConsumerTest::getNumOfMessagesInQueue(consumer), consumerConfig.getReceiverQueueSize());
-    ASSERT_GE(ConsumerTest::getNumOfMessagesInQueue(consumer), consumerConfig.getReceiverQueueSize()/2);
+    ASSERT_GE(ConsumerTest::getNumOfMessagesInQueue(consumer), consumerConfig.getReceiverQueueSize() / 2);
 
     i = 0;
     while (consumer.receive(receivedMsg, 5000) == ResultOk) {
-        std::string expectedMessageContent = prefix + boost::lexical_cast < std::string > (i);
-        LOG_DEBUG(
-                "Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
-        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast < std::string > (i++));
+        std::string expectedMessageContent = prefix + boost::lexical_cast<std::string>(i);
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
+        ASSERT_EQ(receivedMsg.getProperty("msgIndex"), boost::lexical_cast<std::string>(i++));
         ASSERT_EQ(expectedMessageContent, receivedMsg.getDataAsString());
         ASSERT_EQ(ResultOk, consumer.acknowledgeCumulative(receivedMsg));
     }
@@ -831,14 +852,16 @@ TEST(BatchMessageTest, testPermits) {
 
 TEST(BatchMessageTest, testPartitionedTopics) {
     Client client(lookupUrl);
-    std::string topicName = "persistent://property/cluster/namespace/test-partitioned-batch-messages-" + boost::lexical_cast<std::string>(epochTime) ;
+    std::string topicName = "persistent://property/cluster/namespace/test-partitioned-batch-messages-" +
+                            boost::lexical_cast<std::string>(epochTime);
 
     // call admin api to make it partitioned
-    std::string url = adminUrl + "admin/persistent/property/cluster/namespace/test-partitioned-batch-messages-"
-      + boost::lexical_cast<std::string>(epochTime) + "/partitions";
+    std::string url = adminUrl +
+                      "admin/persistent/property/cluster/namespace/test-partitioned-batch-messages-" +
+                      boost::lexical_cast<std::string>(epochTime) + "/partitions";
     int res = makePutRequest(url, "7");
 
-    LOG_DEBUG("res = "<<res);
+    LOG_DEBUG("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     usleep(2 * 1000 * 1000);
@@ -881,9 +904,12 @@ TEST(BatchMessageTest, testPartitionedTopics) {
 
     // Send Asynchronously
     std::string prefix = "msg-batch-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
-        Message msg = MessageBuilder().setContent(messageContent).setProperty("msgIndex", boost::lexical_cast<std::string>(i)).build();
+        Message msg = MessageBuilder()
+                          .setContent(messageContent)
+                          .setProperty("msgIndex", boost::lexical_cast<std::string>(i))
+                          .build();
         producer.sendAsync(msg, &sendCallBackExpectingErrors);
         LOG_DEBUG("sending message " << messageContent);
     }
@@ -891,7 +917,8 @@ TEST(BatchMessageTest, testPartitionedTopics) {
     Message receivedMsg;
     int i = 0;
     while (consumer.receive(receivedMsg, 30000) == ResultOk) {
-        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = " << receivedMsg.getMessageId() << "]");
+        LOG_DEBUG("Received Message with [ content - " << receivedMsg.getDataAsString() << "] [ messageID = "
+                                                       << receivedMsg.getMessageId() << "]");
         ASSERT_EQ(ResultOk, consumer.acknowledge(receivedMsg));
         i++;
     }
diff --git a/pulsar-client-cpp/tests/BinaryLookupServiceTest.cc b/pulsar-client-cpp/tests/BinaryLookupServiceTest.cc
index ff42a38c5..b5baeb02e 100644
--- a/pulsar-client-cpp/tests/BinaryLookupServiceTest.cc
+++ b/pulsar-client-cpp/tests/BinaryLookupServiceTest.cc
@@ -48,7 +48,8 @@ TEST(BinaryLookupServiceTest, basicLookup) {
     ASSERT_TRUE(lookupData != NULL);
     ASSERT_EQ(0, lookupData->getPartitions());
 
-    Future<Result, LookupDataResultPtr> future = lookupService.lookupAsync("persistent://prop/unit/ns1/destination");
+    Future<Result, LookupDataResultPtr> future =
+        lookupService.lookupAsync("persistent://prop/unit/ns1/destination");
     result = future.get(lookupData);
 
     ASSERT_EQ(ResultOk, result);
diff --git a/pulsar-client-cpp/tests/BlockingQueueTest.cc b/pulsar-client-cpp/tests/BlockingQueueTest.cc
index 840bc785e..7073b4025 100644
--- a/pulsar-client-cpp/tests/BlockingQueueTest.cc
+++ b/pulsar-client-cpp/tests/BlockingQueueTest.cc
@@ -25,19 +25,14 @@
 using namespace boost::posix_time;
 
 class ProducerWorker {
- private:
+   private:
     boost::thread producerThread_;
     BlockingQueue<int>& queue_;
 
- public:
-    ProducerWorker(BlockingQueue<int>& queue)
-            : queue_(queue) {
+   public:
+    ProducerWorker(BlockingQueue<int>& queue) : queue_(queue) {}
 
-    }
-
-    void produce(int number) {
-        producerThread_ = boost::thread(&ProducerWorker::pushNumbers, this, number);
-    }
+    void produce(int number) { producerThread_ = boost::thread(&ProducerWorker::pushNumbers, this, number); }
 
     void pushNumbers(int number) {
         for (int i = 1; i <= number; i++) {
@@ -45,25 +40,18 @@ class ProducerWorker {
         }
     }
 
-    void join() {
-        producerThread_.join();
-    }
+    void join() { producerThread_.join(); }
 };
 
 class ConsumerWorker {
- private:
+   private:
     boost::thread consumerThread_;
     BlockingQueue<int>& queue_;
 
- public:
-    ConsumerWorker(BlockingQueue<int>& queue)
-            : queue_(queue) {
+   public:
+    ConsumerWorker(BlockingQueue<int>& queue) : queue_(queue) {}
 
-    }
-
-    void consume(int number) {
-        consumerThread_ = boost::thread(&ConsumerWorker::popNumbers, this, number);
-    }
+    void consume(int number) { consumerThread_ = boost::thread(&ConsumerWorker::popNumbers, this, number); }
 
     void popNumbers(int number) {
         for (int i = 1; i <= number; i++) {
@@ -72,9 +60,7 @@ class ConsumerWorker {
         }
     }
 
-    void join() {
-        consumerThread_.join();
-    }
+    void join() { consumerThread_.join(); }
 };
 
 TEST(BlockingQueueTest, testBasic) {
diff --git a/pulsar-client-cpp/tests/ClientDeduplicationTest.cc b/pulsar-client-cpp/tests/ClientDeduplicationTest.cc
index 71786dcab..b235040b9 100644
--- a/pulsar-client-cpp/tests/ClientDeduplicationTest.cc
+++ b/pulsar-client-cpp/tests/ClientDeduplicationTest.cc
@@ -33,8 +33,8 @@ static std::string adminUrl = "http://localhost:8765/";
 TEST(ClientDeduplicationTest, testProducerSequenceAfterReconnect) {
     Client client(serviceUrl);
 
-    std::string topicName = "persistent://sample/standalone/ns-dedup-1/testProducerSequenceAfterReconnect-"
-            + boost::lexical_cast<std::string>(time(NULL));
+    std::string topicName = "persistent://sample/standalone/ns-dedup-1/testProducerSequenceAfterReconnect-" +
+                            boost::lexical_cast<std::string>(time(NULL));
 
     // call admin api to create namespace and enable deduplication
     std::string url = adminUrl + "admin/namespaces/sample/standalone/ns-dedup-1";
@@ -81,8 +81,8 @@ TEST(ClientDeduplicationTest, testProducerSequenceAfterReconnect) {
 TEST(ClientDeduplicationTest, testProducerDeduplication) {
     Client client(serviceUrl);
 
-    std::string topicName = "persistent://sample/standalone/ns-dedup-2/testProducerDeduplication-"
-            + boost::lexical_cast<std::string>(time(NULL));
+    std::string topicName = "persistent://sample/standalone/ns-dedup-2/testProducerDeduplication-" +
+                            boost::lexical_cast<std::string>(time(NULL));
 
     // call admin api to create namespace and enable deduplication
     std::string url = adminUrl + "admin/namespaces/sample/standalone/ns-dedup-2";
@@ -107,18 +107,13 @@ TEST(ClientDeduplicationTest, testProducerDeduplication) {
     Consumer consumer;
     ASSERT_EQ(client.subscribe(topicName, "my-subscription", consumer), ResultOk);
 
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-0").setSequenceId(0).build()),
-              ResultOk);
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-1").setSequenceId(1).build()),
-              ResultOk);
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-2").setSequenceId(2).build()),
-              ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-0").setSequenceId(0).build()), ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-1").setSequenceId(1).build()), ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-2").setSequenceId(2).build()), ResultOk);
 
     // Repeat the messages and verify they're not received by consumer
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-1").setSequenceId(1).build()),
-              ResultOk);
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-2").setSequenceId(2).build()),
-              ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-1").setSequenceId(1).build()), ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-2").setSequenceId(2).build()), ResultOk);
 
     producer.close();
 
@@ -137,10 +132,8 @@ TEST(ClientDeduplicationTest, testProducerDeduplication) {
     ASSERT_EQ(producer.getLastSequenceId(), 2);
 
     // Repeat the messages and verify they're not received by consumer
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-1").setSequenceId(1).build()),
-              ResultOk);
-    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-2").setSequenceId(2).build()),
-              ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-1").setSequenceId(1).build()), ResultOk);
+    ASSERT_EQ(producer.send(MessageBuilder().setContent("my-message-2").setSequenceId(2).build()), ResultOk);
 
     // No other messages should be received
     ASSERT_EQ(consumer.receive(msg, 1000), ResultTimeout);
diff --git a/pulsar-client-cpp/tests/ClientTest.cc b/pulsar-client-cpp/tests/ClientTest.cc
index 461a8a741..5bc0246a3 100644
--- a/pulsar-client-cpp/tests/ClientTest.cc
+++ b/pulsar-client-cpp/tests/ClientTest.cc
@@ -26,54 +26,50 @@ using namespace pulsar;
 static std::string lookupUrl = "pulsar://localhost:8885";
 
 TEST(ClientTest, testChecksumComputation) {
-
     std::string data = "test";
     std::string doubleData = "testtest";
 
     // (1) compute checksum of specific chunk of string
-    int checksum1 = computeChecksum(0, (char *) data.c_str(), data.length());
-    int checksum2 = computeChecksum(0, (char *) doubleData.c_str() + 4, 4);
+    int checksum1 = computeChecksum(0, (char *)data.c_str(), data.length());
+    int checksum2 = computeChecksum(0, (char *)doubleData.c_str() + 4, 4);
     ASSERT_EQ(checksum1, checksum2);
 
     //(2) compute incremental checksum
     // (a) checksum on full data
-    int doubleChecksum = computeChecksum(0, (char *) doubleData.c_str(), doubleData.length());
+    int doubleChecksum = computeChecksum(0, (char *)doubleData.c_str(), doubleData.length());
     // (b) incremental checksum on multiple partial data
-    checksum1 = computeChecksum(0, (char *) data.c_str(), data.length());
-    int incrementalChecksum = computeChecksum(checksum1, (char *) data.c_str(), data.length());
+    checksum1 = computeChecksum(0, (char *)data.c_str(), data.length());
+    int incrementalChecksum = computeChecksum(checksum1, (char *)data.c_str(), data.length());
     ASSERT_EQ(incrementalChecksum, doubleChecksum);
-
 }
 
 TEST(ClientTest, testSwHwChecksum) {
-
     std::string data = "test";
     std::string doubleData = "testtest";
 
     // (1) compute checksum of specific chunk of string
     // (a) HW
-    uint32_t hwChecksum1 = crc32cHw(0, (char *) data.c_str(), data.length());
-    uint32_t hwChecksum2 = crc32cHw(0, (char *) doubleData.c_str() + 4, 4);
+    uint32_t hwChecksum1 = crc32cHw(0, (char *)data.c_str(), data.length());
+    uint32_t hwChecksum2 = crc32cHw(0, (char *)doubleData.c_str() + 4, 4);
     // (b) SW
-    uint32_t swChecksum1 = crc32cSw(0, (char *) data.c_str(), data.length());
-    uint32_t swChecksum2 = crc32cSw(0, (char *) doubleData.c_str() + 4, 4);
+    uint32_t swChecksum1 = crc32cSw(0, (char *)data.c_str(), data.length());
+    uint32_t swChecksum2 = crc32cSw(0, (char *)doubleData.c_str() + 4, 4);
     ASSERT_EQ(hwChecksum1, hwChecksum2);
     ASSERT_EQ(hwChecksum1, swChecksum1);
     ASSERT_EQ(hwChecksum2, swChecksum2);
 
     //(2) compute incremental checksum
     // (a.1) hw: checksum on full data
-    uint32_t hwDoubleChecksum = crc32cHw(0, (char *) doubleData.c_str(), doubleData.length());
+    uint32_t hwDoubleChecksum = crc32cHw(0, (char *)doubleData.c_str(), doubleData.length());
     // (a.2) hw: incremental checksum on multiple partial data
-    hwChecksum1 = crc32cHw(0, (char *) data.c_str(), data.length());
-    uint32_t hwIncrementalChecksum = crc32cHw(hwChecksum1, (char *) data.c_str(), data.length());
+    hwChecksum1 = crc32cHw(0, (char *)data.c_str(), data.length());
+    uint32_t hwIncrementalChecksum = crc32cHw(hwChecksum1, (char *)data.c_str(), data.length());
     // (b.1) sw: checksum on full data
-    uint32_t swDoubleChecksum = crc32cSw(0, (char *) doubleData.c_str(), doubleData.length());
+    uint32_t swDoubleChecksum = crc32cSw(0, (char *)doubleData.c_str(), doubleData.length());
     // (b.2) sw: incremental checksum on multiple partial data
-    swChecksum1 = crc32cHw(0, (char *) data.c_str(), data.length());
-    uint32_t swIncrementalChecksum = crc32cSw(swChecksum1, (char *) data.c_str(), data.length());
+    swChecksum1 = crc32cHw(0, (char *)data.c_str(), data.length());
+    uint32_t swIncrementalChecksum = crc32cSw(swChecksum1, (char *)data.c_str(), data.length());
 
     ASSERT_EQ(hwIncrementalChecksum, hwDoubleChecksum);
     ASSERT_EQ(hwIncrementalChecksum, swIncrementalChecksum);
-
 }
diff --git a/pulsar-client-cpp/tests/ConsumerStatsTest.cc b/pulsar-client-cpp/tests/ConsumerStatsTest.cc
index e173dcd22..292c47ef0 100644
--- a/pulsar-client-cpp/tests/ConsumerStatsTest.cc
+++ b/pulsar-client-cpp/tests/ConsumerStatsTest.cc
@@ -39,9 +39,11 @@ using namespace pulsar;
 static std::string lookupUrl = "http://localhost:8765";
 static std::string adminUrl = "http://localhost:8765/";
 
-void partitionedCallbackFunction(Result result, BrokerConsumerStats brokerConsumerStats, long expectedBacklog, Latch& latch, int index) {
+void partitionedCallbackFunction(Result result, BrokerConsumerStats brokerConsumerStats, long expectedBacklog,
+                                 Latch& latch, int index) {
     ASSERT_EQ(result, ResultOk);
-    PartitionedBrokerConsumerStatsImpl* statsPtr = (PartitionedBrokerConsumerStatsImpl*)(brokerConsumerStats.getImpl().get());
+    PartitionedBrokerConsumerStatsImpl* statsPtr =
+        (PartitionedBrokerConsumerStatsImpl*)(brokerConsumerStats.getImpl().get());
     LOG_DEBUG(statsPtr);
     ASSERT_EQ(expectedBacklog, statsPtr->getBrokerConsumerStats(index).getMsgBacklog());
     latch.countdown();
@@ -55,10 +57,10 @@ void simpleCallbackFunction(Result result, BrokerConsumerStats brokerConsumerSta
     ASSERT_EQ(brokerConsumerStats.getType(), expectedConsumerType);
 }
 TEST(ConsumerStatsTest, testBacklogInfo) {
-	long epochTime=time(NULL);
-	std::string testName="testBacklogInfo-" + boost::lexical_cast<std::string>(epochTime);
-	Client client(lookupUrl);
-	std::string topicName = "persistent://property/cluster/namespace/" + testName;
+    long epochTime = time(NULL);
+    std::string testName = "testBacklogInfo-" + boost::lexical_cast<std::string>(epochTime);
+    Client client(lookupUrl);
+    std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
     ConsumerConfiguration conf;
     conf.setBrokerConsumerStatsCacheTimeInMs(3 * 1000);
@@ -83,16 +85,17 @@ TEST(ConsumerStatsTest, testBacklogInfo) {
     ASSERT_EQ(ResultOk, result);
 
     std::string prefix = testName + "-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
     }
 
     LOG_DEBUG("Calling consumer.getBrokerConsumerStats");
-    consumer.getBrokerConsumerStatsAsync(boost::bind(simpleCallbackFunction, _1, _2, ResultOk, numOfMessages, ConsumerExclusive));
+    consumer.getBrokerConsumerStatsAsync(
+        boost::bind(simpleCallbackFunction, _1, _2, ResultOk, numOfMessages, ConsumerExclusive));
 
-    for (int i = numOfMessages; i<(numOfMessages*2); i++) {
+    for (int i = numOfMessages; i < (numOfMessages * 2); i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
@@ -109,8 +112,8 @@ TEST(ConsumerStatsTest, testBacklogInfo) {
 }
 
 TEST(ConsumerStatsTest, testFailure) {
-    long epochTime=time(NULL);
-    std::string testName="testFailure-" + boost::lexical_cast<std::string>(epochTime);
+    long epochTime = time(NULL);
+    std::string testName = "testFailure-" + boost::lexical_cast<std::string>(epochTime);
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
@@ -138,7 +141,7 @@ TEST(ConsumerStatsTest, testFailure) {
     ASSERT_EQ(ResultOk, result);
 
     std::string prefix = testName + "-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
@@ -154,8 +157,8 @@ TEST(ConsumerStatsTest, testFailure) {
 }
 
 TEST(ConsumerStatsTest, testCachingMechanism) {
-    long epochTime=time(NULL);
-    std::string testName="testCachingMechanism-" + boost::lexical_cast<std::string>(epochTime);
+    long epochTime = time(NULL);
+    std::string testName = "testCachingMechanism-" + boost::lexical_cast<std::string>(epochTime);
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
@@ -185,7 +188,7 @@ TEST(ConsumerStatsTest, testCachingMechanism) {
     ASSERT_EQ(ResultOk, result);
 
     std::string prefix = testName + "-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
@@ -196,7 +199,7 @@ TEST(ConsumerStatsTest, testCachingMechanism) {
     LOG_DEBUG(consumerStats);
     ASSERT_EQ(consumerStats.getMsgBacklog(), numOfMessages);
 
-    for (int i = numOfMessages; i<(numOfMessages*2); i++) {
+    for (int i = numOfMessages; i < (numOfMessages * 2); i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
@@ -228,10 +231,9 @@ TEST(ConsumerStatsTest, testCachingMechanism) {
     ASSERT_NE(ResultOk, consumer.getBrokerConsumerStats(consumerStats));
 }
 
-
 TEST(ConsumerStatsTest, testAsyncCallOnPartitionedTopic) {
-    long epochTime=time(NULL);
-    std::string testName="testAsyncCallOnPartitionedTopic-" + boost::lexical_cast<std::string>(epochTime);
+    long epochTime = time(NULL);
+    std::string testName = "testAsyncCallOnPartitionedTopic-" + boost::lexical_cast<std::string>(epochTime);
     Client client(lookupUrl);
     std::string topicName = "persistent://property/cluster/namespace/" + testName;
     std::string subName = "subscription-name";
@@ -240,7 +242,7 @@ TEST(ConsumerStatsTest, testAsyncCallOnPartitionedTopic) {
     std::string url = adminUrl + "admin/persistent/property/cluster/namespace/" + testName + "/partitions";
     int res = makePutRequest(url, "7");
 
-    LOG_INFO("res = "<<res);
+    LOG_INFO("res = " << res);
     ASSERT_FALSE(res != 204 && res != 409);
 
     ConsumerConfiguration conf;
@@ -261,7 +263,7 @@ TEST(ConsumerStatsTest, testAsyncCallOnPartitionedTopic) {
 
     // Producing messages
     Producer producer;
-    int numOfMessages = 7 * 5; // 5 message per partition
+    int numOfMessages = 7 * 5;  // 5 message per partition
     Promise<Result, Producer> producerPromise;
     ProducerConfiguration config;
     config.setPartitionsRoutingMode(ProducerConfiguration::RoundRobinDistribution);
@@ -271,7 +273,7 @@ TEST(ConsumerStatsTest, testAsyncCallOnPartitionedTopic) {
     ASSERT_EQ(ResultOk, result);
 
     std::string prefix = testName + "-";
-    for (int i = 0; i<numOfMessages; i++) {
+    for (int i = 0; i < numOfMessages; i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
@@ -282,7 +284,7 @@ TEST(ConsumerStatsTest, testAsyncCallOnPartitionedTopic) {
     consumer.getBrokerConsumerStatsAsync(boost::bind(partitionedCallbackFunction, _1, _2, 5, latch, 0));
 
     // Now we have 10 messages per partition
-    for (int i = numOfMessages; i<(numOfMessages*2); i++) {
+    for (int i = numOfMessages; i < (numOfMessages * 2); i++) {
         std::string messageContent = prefix + boost::lexical_cast<std::string>(i);
         Message msg = MessageBuilder().build();
         producer.send(msg);
diff --git a/pulsar-client-cpp/tests/ConsumerTest.h b/pulsar-client-cpp/tests/ConsumerTest.h
index b01513a85..014aa8f03 100644
--- a/pulsar-client-cpp/tests/ConsumerTest.h
+++ b/pulsar-client-cpp/tests/ConsumerTest.h
@@ -21,9 +21,9 @@
 
 using std::string;
 
-namespace pulsar{
+namespace pulsar {
 class ConsumerTest {
-    public:
+   public:
     static int getNumOfMessagesInQueue(const Consumer& consumer) {
         return consumer.impl_->getNumOfPrefetchedMessages();
     }
diff --git a/pulsar-client-cpp/tests/CustomRoutingPolicy.h b/pulsar-client-cpp/tests/CustomRoutingPolicy.h
index 1a8c3bce6..d4f935782 100644
--- a/pulsar-client-cpp/tests/CustomRoutingPolicy.h
+++ b/pulsar-client-cpp/tests/CustomRoutingPolicy.h
@@ -19,7 +19,7 @@
 #ifndef CUSTOM_ROUTER_POLICY_HEADER_
 #define CUSTOM_ROUTER_POLICY_HEADER_
 
-#include <cstdlib> // rand()
+#include <cstdlib>  // rand()
 #include <boost/algorithm/string.hpp>
 #include <pulsar/DeprecatedException.h>
 
@@ -30,10 +30,8 @@ class CustomRoutingPolicy : public MessageRoutingPolicy {
         throw DeprecatedException("Use getPartition(const Message&, const TopicMetadata&) instead.");
     }
 
-    int getPartition(const Message& msg, const TopicMetadata& topicMetadata) {
-        return 0;
-    }
+    int getPartition(const Message& msg, const TopicMetadata& topicMetadata) { return 0; }
 };
 }
 
-#endif // CUSTOM_ROUTER_POLICY_HEADER_
+#endif  // CUSTOM_ROUTER_POLICY_HEADER_
diff --git a/pulsar-client-cpp/tests/DestinationNameTest.cc b/pulsar-client-cpp/tests/DestinationNameTest.cc
index 376648079..b88a1d83e 100644
--- a/pulsar-client-cpp/tests/DestinationNameTest.cc
+++ b/pulsar-client-cpp/tests/DestinationNameTest.cc
@@ -23,16 +23,16 @@
 using namespace pulsar;
 
 TEST(DestinationNameTest, testLookup) {
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-            "persistent://pulsar/bf1/TESTNS.0/curveballapps");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent://pulsar/bf1/TESTNS.0/curveballapps");
     std::string lookup_name = dn->getLookupName();
     ASSERT_EQ(lookup_name, "persistent/pulsar/bf1/TESTNS.0/curveballapps");
 }
 
 TEST(DestinationNameTest, testDestinationName) {
     // Compare getters and setters
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-            "persistent://property/cluster/namespace/destination");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent://property/cluster/namespace/destination");
     ASSERT_EQ("property", dn->getProperty());
     ASSERT_EQ("cluster", dn->getCluster());
     ASSERT_EQ("namespace", dn->getNamespacePortion());
@@ -47,8 +47,8 @@ TEST(DestinationNameTest, testDestinationName) {
 
 TEST(DestinationNameTest, testDestinationNameWithSlashes) {
     // Compare getters and setters
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-            "persistent://property/cluster/namespace/destination/name/with/slash");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent://property/cluster/namespace/destination/name/with/slash");
     ASSERT_EQ("property", dn->getProperty());
     ASSERT_EQ("cluster", dn->getCluster());
     ASSERT_EQ("namespace", dn->getNamespacePortion());
@@ -61,7 +61,8 @@ TEST(DestinationNameTest, testDestinationNameWithSlashes) {
 
     dn = DestinationName::get("persistent://property/cluster/namespace/`~!@#$%^&*()-_+=[]{}|\\;:'\"<>,./?");
     ASSERT_TRUE(dn != NULL);
-    ASSERT_EQ(DestinationName::getEncodedName("`~!@#$%^&*()-_+=[]{}|\\;:'\"<>,./?"), dn->getEncodedLocalName());
+    ASSERT_EQ(DestinationName::getEncodedName("`~!@#$%^&*()-_+=[]{}|\\;:'\"<>,./?"),
+              dn->getEncodedLocalName());
 
     dn = DestinationName::get("persistent://property/cluster/namespace/topic@%*)(&!%$#@#$><?");
     ASSERT_TRUE(dn != NULL);
@@ -69,49 +70,48 @@ TEST(DestinationNameTest, testDestinationNameWithSlashes) {
 
     dn = DestinationName::get("persistent://property/cluster/namespace/destination//with//double//slash//");
     ASSERT_TRUE(dn != NULL);
-    ASSERT_EQ(DestinationName::getEncodedName("destination//with//double//slash//"), dn->getEncodedLocalName());
+    ASSERT_EQ(DestinationName::getEncodedName("destination//with//double//slash//"),
+              dn->getEncodedLocalName());
 
     dn = DestinationName::get("persistent://property/cluster/namespace//destination/starts/with/slash/");
     ASSERT_TRUE(dn != NULL);
     ASSERT_EQ(DestinationName::getEncodedName("/destination/starts/with/slash/"), dn->getEncodedLocalName());
-
 }
 TEST(DestinationNameTest, testEmptyClusterName) {
     // Compare getters and setters
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-            "persistent://property//namespace/destination");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent://property//namespace/destination");
 
-   ASSERT_FALSE(dn);
+    ASSERT_FALSE(dn);
 }
 
 TEST(DestinationNameTest, testExtraSlashes) {
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-            "persistent://property/cluster//namespace/destination");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent://property/cluster//namespace/destination");
     ASSERT_FALSE(dn);
     dn = DestinationName::get("persistent://property//cluster//namespace//destination");
     ASSERT_FALSE(dn);
 }
 
 TEST(DestinationNameTest, testIllegalCharacters) {
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-               "persistent://prop!!!erty/cluster&)&Name/name%%%space/destination");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent://prop!!!erty/cluster&)&Name/name%%%space/destination");
     ASSERT_FALSE(dn);
 }
 
 TEST(DestinationNameTest, testIllegalUrl) {
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-               "persistent:::/property/cluster/namespace/destination");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent:::/property/cluster/namespace/destination");
     ASSERT_FALSE(dn);
 }
 
 TEST(DestinationNameTest, testEmptyString) {
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-               "");
+    boost::shared_ptr<DestinationName> dn = DestinationName::get("");
     ASSERT_FALSE(dn);
 }
 
 TEST(DestinationNameTest, testExtraArguments) {
-    boost::shared_ptr<DestinationName> dn = DestinationName::get(
-               "persistent:::/property/cluster/namespace/destination/some/extra/args");
+    boost::shared_ptr<DestinationName> dn =
+        DestinationName::get("persistent:::/property/cluster/namespace/destination/some/extra/args");
     ASSERT_FALSE(dn);
 }
diff --git a/pulsar-client-cpp/tests/HttpHelper.cc b/pulsar-client-cpp/tests/HttpHelper.cc
index 0cb3493e2..c3d733310 100644
--- a/pulsar-client-cpp/tests/HttpHelper.cc
+++ b/pulsar-client-cpp/tests/HttpHelper.cc
@@ -16,15 +16,14 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- #include "HttpHelper.h"
-
- #include <curl/curl.h>
+#include "HttpHelper.h"
 
+#include <curl/curl.h>
 
 static int makeRequest(const std::string& method, const std::string& url, const std::string& body) {
     CURL* curl = curl_easy_init();
 
-    struct curl_slist *list = NULL;
+    struct curl_slist* list = NULL;
 
     list = curl_slist_append(list, "Content-Type: application/json");
 
@@ -42,12 +41,10 @@ static int makeRequest(const std::string& method, const std::string& url, const
     long httpResult = 0;
     curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &httpResult);
     curl_easy_cleanup(curl);
-    return (int) httpResult;
+    return (int)httpResult;
 }
 
-int makePutRequest(const std::string& url, const std::string& body) {
-    return makeRequest("PUT", url, body);
-}
+int makePutRequest(const std::string& url, const std::string& body) { return makeRequest("PUT", url, body); }
 
 int makePostRequest(const std::string& url, const std::string& body) {
     return makeRequest("POST", url, body);
diff --git a/pulsar-client-cpp/tests/HttpHelper.h b/pulsar-client-cpp/tests/HttpHelper.h
index b6de778ec..31abc2d90 100644
--- a/pulsar-client-cpp/tests/HttpHelper.h
+++ b/pulsar-client-cpp/tests/HttpHelper.h
@@ -24,5 +24,4 @@
 int makePutRequest(const std::string& url, const std::string& body);
 int makePostRequest(const std::string& url, const std::string& body);
 
-
 #endif /* end of include guard: HTTP_HELPER */
diff --git a/pulsar-client-cpp/tests/LatchTest.cc b/pulsar-client-cpp/tests/LatchTest.cc
index 8f6b1dddf..38e19ee99 100644
--- a/pulsar-client-cpp/tests/LatchTest.cc
+++ b/pulsar-client-cpp/tests/LatchTest.cc
@@ -28,17 +28,15 @@ using namespace pulsar;
 using namespace boost::posix_time;
 
 class Service {
- private:
+   private:
     std::string serviceName_;
     time_duration sleepDuration_;
     Latch latch_;
     boost::thread thread_;
 
- public:
+   public:
     Service(const std::string& serviceName, time_duration sleepDuration, const Latch& latch)
-            : serviceName_(serviceName),
-              sleepDuration_(sleepDuration),
-              latch_(latch) {
+        : serviceName_(serviceName), sleepDuration_(sleepDuration), latch_(latch) {
         thread_ = boost::thread(&Service::run, this);
     }
 
@@ -48,9 +46,7 @@ class Service {
         latch_.countdown();
     }
 
-    ~Service() {
-        thread_.join();
-    }
+    ~Service() { thread_.join(); }
 };
 
 TEST(LatchTest, testCountDown) {
diff --git a/pulsar-client-cpp/tests/MessageTest.cc b/pulsar-client-cpp/tests/MessageTest.cc
index d669c7be6..410bfe1d7 100644
--- a/pulsar-client-cpp/tests/MessageTest.cc
+++ b/pulsar-client-cpp/tests/MessageTest.cc
@@ -32,14 +32,14 @@ TEST(MessageTest, testMessageContents) {
     Message msg = msgBuilder1.build();
     ASSERT_EQ(content, msg.getDataAsString());
     ASSERT_EQ(content.length(), msg.getLength());
-    ASSERT_EQ(content, std::string((char * ) msg.getData(), msg.getLength()));
+    ASSERT_EQ(content, std::string((char*)msg.getData(), msg.getLength()));
 
     MessageBuilder msgBuilder2;
     std::string myContents = "mycontents";
     msgBuilder2.setContent(myContents.c_str(), myContents.length());
     msg = msgBuilder2.build();
-    ASSERT_EQ(myContents, std::string((char * ) msg.getData(), msg.getLength()));
-    ASSERT_NE(myContents.c_str(), (char * ) msg.getData());
+    ASSERT_EQ(myContents, std::string((char*)msg.getData(), msg.getLength()));
+    ASSERT_NE(myContents.c_str(), (char*)msg.getData());
     ASSERT_EQ(myContents, msg.getDataAsString());
     ASSERT_EQ(std::string("mycontents").length(), msg.getLength());
 }
@@ -47,16 +47,16 @@ TEST(MessageTest, testMessageContents) {
 TEST(MessageTest, testAllocatedContents) {
     MessageBuilder msgBuilder;
     std::string str = "content";
-    char *content = new char[str.size()];
+    char* content = new char[str.size()];
     strcpy(content, str.c_str());
     msgBuilder.setAllocatedContent(content, str.length());
     Message msg = msgBuilder.build();
-    ASSERT_FALSE(strncmp("content", (char * ) msg.getData(), msg.getLength()));
-    ASSERT_EQ(content, (char * ) msg.getData());
+    ASSERT_FALSE(strncmp("content", (char*)msg.getData(), msg.getLength()));
+    ASSERT_EQ(content, (char*)msg.getData());
     delete[] content;
 }
 
-template<typename Map>
+template <typename Map>
 bool compareMaps(const Map& lhs, const Map& rhs) {
     return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());
 }
diff --git a/pulsar-client-cpp/tests/PulsarFriend.h b/pulsar-client-cpp/tests/PulsarFriend.h
index 2247126f0..1cebf0a7c 100644
--- a/pulsar-client-cpp/tests/PulsarFriend.h
+++ b/pulsar-client-cpp/tests/PulsarFriend.h
@@ -23,19 +23,17 @@
 
 using std::string;
 
-namespace pulsar{
+namespace pulsar {
 class PulsarFriend {
-    public:
-    static int getBatchIndex(const BatchMessageId& mId) {
-        return mId.batchIndex_;
-    }
+   public:
+    static int getBatchIndex(const BatchMessageId& mId) { return mId.batchIndex_; }
 
     static ProducerStatsImplPtr getProducerStatsPtr(Producer producer) {
         ProducerImpl* producerImpl = static_cast<ProducerImpl*>(producer.impl_.get());
         return boost::static_pointer_cast<ProducerStatsImpl>(producerImpl->producerStatsBasePtr_);
     }
 
-    template<typename T>
+    template <typename T>
     static unsigned long sum(std::map<T, unsigned long> m) {
         unsigned long sum = 0;
         for (typename std::map<T, unsigned long>::iterator iter = m.begin(); iter != m.end(); iter++) {
@@ -59,9 +57,7 @@ class PulsarFriend {
         return *consumerImpl;
     }
 
-    static ClientConnectionWeakPtr getClientConnection(HandlerBase&  handler) {
-        return handler.connection_;
-    }
+    static ClientConnectionWeakPtr getClientConnection(HandlerBase& handler) { return handler.connection_; }
 
     static boost::posix_time::ptime& getFirstBackoffTime(Backoff& backoff) {
         return backoff.firstBackoffTime_;
diff --git a/pulsar-client-cpp/tests/ReaderTest.cc b/pulsar-client-cpp/tests/ReaderTest.cc
index d578d9ada..0e31f6a14 100644
--- a/pulsar-client-cpp/tests/ReaderTest.cc
+++ b/pulsar-client-cpp/tests/ReaderTest.cc
@@ -60,8 +60,7 @@ TEST(ReaderTest, testSimpleReader) {
 TEST(ReaderTest, testReaderAfterMessagesWerePublished) {
     Client client(serviceUrl);
 
-    std::string topicName =
-            "persistent://property/cluster/namespace/testReaderAfterMessagesWerePublished";
+    std::string topicName = "persistent://property/cluster/namespace/testReaderAfterMessagesWerePublished";
 
     Producer producer;
     ASSERT_EQ(ResultOk, client.createProducer(topicName, producer));
@@ -212,7 +211,6 @@ TEST(ReaderTest, testReaderOnSpecificMessage) {
     client.close();
 }
 
-
 /**
  * Test that we can position on a particular message even within a batch
  */
@@ -274,4 +272,3 @@ TEST(ReaderTest, testReaderOnSpecificMessageWithBatches) {
     reader2.close();
     client.close();
 }
-
diff --git a/pulsar-client-cpp/tests/RoundRobinMessageRouterTest.cc b/pulsar-client-cpp/tests/RoundRobinMessageRouterTest.cc
index 2cab6d491..95423534b 100644
--- a/pulsar-client-cpp/tests/RoundRobinMessageRouterTest.cc
+++ b/pulsar-client-cpp/tests/RoundRobinMessageRouterTest.cc
@@ -65,8 +65,10 @@ TEST(RoundRobinMessageRouterTest, DISABLED_getPartitionWithPartitionKey) {
     EXPECT_CALL(message2, hasPartitionKey()).Times(1).WillOnce(Return(true));
     EXPECT_CALL(message2, getPartitionKey()).Times(1).WillOnce(ReturnRef(partitionKey2));
 
-    auto expectedParrtition1 = static_cast<const int>(boost::hash<std::string>()(partitionKey1) % numPartitons);
-    auto expectedParrtition2 = static_cast<const int>(boost::hash<std::string>()(partitionKey2) % numPartitons);
+    auto expectedParrtition1 =
+        static_cast<const int>(boost::hash<std::string>()(partitionKey1) % numPartitons);
+    auto expectedParrtition2 =
+        static_cast<const int>(boost::hash<std::string>()(partitionKey2) % numPartitons);
 
     ASSERT_EQ(expectedParrtition1, router.getPartition(message1, TopicMetadataImpl(numPartitons)));
     ASSERT_EQ(expectedParrtition2, router.getPartition(message2, TopicMetadataImpl(numPartitons)));
diff --git a/pulsar-client-cpp/tests/SinglePartitionMessageRouterTest.cc b/pulsar-client-cpp/tests/SinglePartitionMessageRouterTest.cc
index bb3fe1c38..9457acc16 100644
--- a/pulsar-client-cpp/tests/SinglePartitionMessageRouterTest.cc
+++ b/pulsar-client-cpp/tests/SinglePartitionMessageRouterTest.cc
@@ -61,8 +61,10 @@ TEST(SinglePartitionMessageRouterTest, DISABLED_getPartitionWithPartitionKey) {
     EXPECT_CALL(message2, hasPartitionKey()).Times(1).WillOnce(Return(true));
     EXPECT_CALL(message2, getPartitionKey()).Times(1).WillOnce(ReturnRef(partitionKey2));
 
-    auto expectedParrtition1 = static_cast<const int>(boost::hash<std::string>()(partitionKey1) % numPartitons);
-    auto expectedParrtition2 = static_cast<const int>(boost::hash<std::string>()(partitionKey2) % numPartitons);
+    auto expectedParrtition1 =
+        static_cast<const int>(boost::hash<std::string>()(partitionKey1) % numPartitons);
+    auto expectedParrtition2 =
+        static_cast<const int>(boost::hash<std::string>()(partitionKey2) % numPartitons);
 
     ASSERT_EQ(expectedParrtition1, router.getPartition(message1, TopicMetadataImpl(numPartitons)));
     ASSERT_EQ(expectedParrtition2, router.getPartition(message2, TopicMetadataImpl(numPartitons)));
diff --git a/pulsar-client-cpp/tests/UrlTest.cc b/pulsar-client-cpp/tests/UrlTest.cc
index 365659c98..6cd2d1c82 100644
--- a/pulsar-client-cpp/tests/UrlTest.cc
+++ b/pulsar-client-cpp/tests/UrlTest.cc
@@ -65,7 +65,10 @@ TEST(UrlTest, testUrl) {
     ASSERT_EQ("pulsar", url.protocol());
     ASSERT_EQ(6650, url.port());
 
-    ASSERT_TRUE(Url::parse("http://env-broker3.messaging.cluster.company.com:4080/lookup/v2/destination/persistent/cmscpp/gq1/TESTNS.4/TOPIC_1490664894335_1?authoritative=false", url));
+    ASSERT_TRUE(
+        Url::parse("http://env-broker3.messaging.cluster.company.com:4080/lookup/v2/destination/persistent/"
+                   "cmscpp/gq1/TESTNS.4/TOPIC_1490664894335_1?authoritative=false",
+                   url));
     ASSERT_EQ("http", url.protocol());
     ASSERT_EQ(4080, url.port());
     ASSERT_EQ("/lookup/v2/destination/persistent/cmscpp/gq1/TESTNS.4/TOPIC_1490664894335_1", url.path());
@@ -73,7 +76,8 @@ TEST(UrlTest, testUrl) {
     ASSERT_EQ("TOPIC_1490664894335_1", url.file());
     ASSERT_EQ("?authoritative=false", url.parameter());
 
-    ASSERT_TRUE(Url::parse("http://abc.com:8090/ads/ad/asd/TOPIC_1490664894335_1?authoritative=false,temp=true", url));
+    ASSERT_TRUE(Url::parse(
+        "http://abc.com:8090/ads/ad/asd/TOPIC_1490664894335_1?authoritative=false,temp=true", url));
     ASSERT_EQ("http", url.protocol());
     ASSERT_EQ(8090, url.port());
     ASSERT_EQ("/ads/ad/asd/TOPIC_1490664894335_1", url.path());
diff --git a/pulsar-client-cpp/tests/ZTSClientTest.cc b/pulsar-client-cpp/tests/ZTSClientTest.cc
index 645726ac3..c902313ba 100644
--- a/pulsar-client-cpp/tests/ZTSClientTest.cc
+++ b/pulsar-client-cpp/tests/ZTSClientTest.cc
@@ -21,35 +21,32 @@
 
 using namespace pulsar;
 
-namespace pulsar{
+namespace pulsar {
 
 class ZTSClientWrapper {
-    public:
-    static PrivateKeyUri parseUri(const char* uri) {
-        return ZTSClient::parseUri(uri);
-    }
+   public:
+    static PrivateKeyUri parseUri(const char* uri) { return ZTSClient::parseUri(uri); }
 };
 }
 
 TEST(ZTSClientTest, testZTSClient) {
-
     {
         PrivateKeyUri uri = ZTSClientWrapper::parseUri("file:/path/to/private.key");
-        ASSERT_EQ("file",                 uri.scheme);
+        ASSERT_EQ("file", uri.scheme);
         ASSERT_EQ("/path/to/private.key", uri.path);
     }
 
     {
         PrivateKeyUri uri = ZTSClientWrapper::parseUri("file:///path/to/private.key");
-        ASSERT_EQ("file",                   uri.scheme);
+        ASSERT_EQ("file", uri.scheme);
         ASSERT_EQ("///path/to/private.key", uri.path);
     }
 
     {
         PrivateKeyUri uri = ZTSClientWrapper::parseUri("data:application/x-pem-file;base64,SGVsbG8gV29ybGQK");
-        ASSERT_EQ("data",                          uri.scheme);
+        ASSERT_EQ("data", uri.scheme);
         ASSERT_EQ("application/x-pem-file;base64", uri.mediaTypeAndEncodingType);
-        ASSERT_EQ("SGVsbG8gV29ybGQK",              uri.data);
+        ASSERT_EQ("SGVsbG8gV29ybGQK", uri.data);
     }
 
     {
@@ -67,5 +64,4 @@ TEST(ZTSClientTest, testZTSClient) {
         ASSERT_EQ("", uri.mediaTypeAndEncodingType);
         ASSERT_EQ("", uri.data);
     }
-
 }
diff --git a/pulsar-client-cpp/tests/mocks/GMockMessage.h b/pulsar-client-cpp/tests/mocks/GMockMessage.h
index 29e3eb04e..716c1d755 100644
--- a/pulsar-client-cpp/tests/mocks/GMockMessage.h
+++ b/pulsar-client-cpp/tests/mocks/GMockMessage.h
@@ -24,13 +24,13 @@
 #include <pulsar/Message.h>
 
 namespace pulsar {
-    // TODO: For the mock tests, we need to make all methods and destructor virtual in Message class
-    class GMockMessage : public Message {
-    public:
-        MOCK_CONST_METHOD0(hasPartitionKey, bool());
+// TODO: For the mock tests, we need to make all methods and destructor virtual in Message class
+class GMockMessage : public Message {
+   public:
+    MOCK_CONST_METHOD0(hasPartitionKey, bool());
 
-        MOCK_CONST_METHOD0(getPartitionKey, const std::string&());
-    };
+    MOCK_CONST_METHOD0(getPartitionKey, const std::string&());
+};
 }
 
-#endif // MOCK_MESSAGE_HPP_
+#endif  // MOCK_MESSAGE_HPP_


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services