From 4ccd5f7d5f37728b83798b4ec2b5e7532bafc7b0 Mon Sep 17 00:00:00 2001 From: Jacob Barrett Date: Fri, 27 Aug 2021 12:13:18 -0700 Subject: [PATCH] GEODE-9551: Fixes API return and parameter types. (#860) --- cppcache/include/geode/Pool.hpp | 8 ++------ cppcache/include/geode/PoolFactory.hpp | 2 +- cppcache/src/Pool.cpp | 7 +++++-- cppcache/src/PoolAttributes.hpp | 8 ++++---- cppcache/src/PoolFactory.cpp | 5 ++--- cppcache/src/TcrConnection.cpp | 4 ++-- cppcache/src/ThinClientPoolDM.hpp | 2 -- 7 files changed, 16 insertions(+), 20 deletions(-) diff --git a/cppcache/include/geode/Pool.hpp b/cppcache/include/geode/Pool.hpp index 5c82c29161..f4abcd528f 100644 --- a/cppcache/include/geode/Pool.hpp +++ b/cppcache/include/geode/Pool.hpp @@ -31,10 +31,6 @@ #include "internal/geode_base.hpp" #include "internal/geode_globals.hpp" -/** - * @file - */ - namespace apache { namespace geode { namespace client { @@ -98,13 +94,13 @@ class APACHE_GEODE_EXPORT Pool : public std::enable_shared_from_this { * Gets the host name of the SniProxy. * @see PoolFactory#setSniProxy(string, int) */ - std::string getSniProxyHost() const; + const std::string& getSniProxyHost() const; /** * Gets the port of the SniProxy. * @see PoolFactory#setSniProxy(string, int) */ - int getSniProxyPort() const; + uint16_t getSniProxyPort() const; /** * Gets the minimum connections for this pool. diff --git a/cppcache/include/geode/PoolFactory.hpp b/cppcache/include/geode/PoolFactory.hpp index d554482918..7dc52b2c05 100644 --- a/cppcache/include/geode/PoolFactory.hpp +++ b/cppcache/include/geode/PoolFactory.hpp @@ -429,7 +429,7 @@ class APACHE_GEODE_EXPORT PoolFactory { /** * Set proxy info for SNI connection. Used for connecting via SNI proxy. */ - PoolFactory& setSniProxy(const std::string& hostname, const int port); + PoolFactory& setSniProxy(std::string hostname, uint16_t port); /** * If set to true then the created pool will have diff --git a/cppcache/src/Pool.cpp b/cppcache/src/Pool.cpp index 795cc239cc..4fbf5e04b2 100644 --- a/cppcache/src/Pool.cpp +++ b/cppcache/src/Pool.cpp @@ -46,8 +46,11 @@ std::chrono::milliseconds Pool::getReadTimeout() const { return m_attrs->getReadTimeout(); } -std::string Pool::getSniProxyHost() const { return m_attrs->getSniProxyHost(); } -int Pool::getSniProxyPort() const { return m_attrs->getSniProxyPort(); } +const std::string& Pool::getSniProxyHost() const { + return m_attrs->getSniProxyHost(); +} + +uint16_t Pool::getSniProxyPort() const { return m_attrs->getSniProxyPort(); } int Pool::getMinConnections() const { return m_attrs->getMinConnections(); } diff --git a/cppcache/src/PoolAttributes.hpp b/cppcache/src/PoolAttributes.hpp index 44d963334a..5af3b26cef 100644 --- a/cppcache/src/PoolAttributes.hpp +++ b/cppcache/src/PoolAttributes.hpp @@ -123,11 +123,11 @@ class PoolAttributes { const std::string& getSniProxyHost() const { return m_sniProxyHost; } - void setSniProxyHost(const std::string& host) { m_sniProxyHost = host; } + void setSniProxyHost(std::string host) { m_sniProxyHost = std::move(host); } - int getSniProxyPort() const { return m_sniProxyPort; } + uint16_t getSniProxyPort() const { return m_sniProxyPort; } - void setSniProxyPort(const int port) { m_sniProxyPort = port; } + void setSniProxyPort(const uint16_t port) { m_sniProxyPort = port; } const std::string& getServerGroup() const { return m_serverGrp; } @@ -203,7 +203,7 @@ class PoolAttributes { std::vector m_initServList; std::string m_sniProxyHost; - int m_sniProxyPort; + uint16_t m_sniProxyPort; static bool compareVectorOfStrings( const std::vector& thisVector, diff --git a/cppcache/src/PoolFactory.cpp b/cppcache/src/PoolFactory.cpp index 465a1fc9f1..e769d1bc91 100644 --- a/cppcache/src/PoolFactory.cpp +++ b/cppcache/src/PoolFactory.cpp @@ -183,9 +183,8 @@ PoolFactory& PoolFactory::addServer(const std::string& host, int port) { return *this; } -PoolFactory& PoolFactory::setSniProxy(const std::string& hostname, - const int port) { - m_attrs->setSniProxyHost(hostname); +PoolFactory& PoolFactory::setSniProxy(std::string hostname, uint16_t port) { + m_attrs->setSniProxyHost(std::move(hostname)); m_attrs->setSniProxyPort(port); return *this; } diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp index 8cc88bf9af..7ed0a9155f 100644 --- a/cppcache/src/TcrConnection.cpp +++ b/cppcache/src/TcrConnection.cpp @@ -470,14 +470,14 @@ void TcrConnection::createConnection(const std::string& address, .getSystemProperties(); if (systemProperties.sslEnabled()) { - auto sniHostname = m_poolDM->getSNIProxyHostname(); - auto sniPort = m_poolDM->getSNIPort(); + const auto& sniHostname = m_poolDM->getSniProxyHost(); if (sniHostname.empty()) { m_conn.reset(new TcpSslConn(address, connectTimeout, maxBuffSizePool, systemProperties.sslTrustStore(), systemProperties.sslKeyStore(), systemProperties.sslKeystorePassword())); } else { + const auto sniPort = m_poolDM->getSniProxyPort(); m_conn.reset(new TcpSslConn( address, connectTimeout, maxBuffSizePool, sniHostname, sniPort, systemProperties.sslTrustStore(), systemProperties.sslKeyStore(), diff --git a/cppcache/src/ThinClientPoolDM.hpp b/cppcache/src/ThinClientPoolDM.hpp index e306dfffdd..3e03b8a4e7 100644 --- a/cppcache/src/ThinClientPoolDM.hpp +++ b/cppcache/src/ThinClientPoolDM.hpp @@ -173,8 +173,6 @@ class ThinClientPoolDM GfErrType getConnectionToAnEndPoint(std::string epNameStr, TcrConnection*& conn); - const std::string getSNIProxyHostname() { return m_attrs->getSniProxyHost(); } - uint16_t getSNIPort() { return m_attrs->getSniProxyPort(); } virtual inline bool isSticky() { return m_sticky; } virtual TcrEndpoint* getEndPoint( const std::shared_ptr& serverLocation,