Merge pull request #588 from Nordix/feature/GEODE-7930

GEODE-7930: Fix endpoint name truncation bug
diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp
index 3503ea0..12bedbf 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -1966,11 +1966,8 @@
 }
 
 TcrEndpoint* ThinClientPoolDM::addEP(ServerLocation& serverLoc) {
-  std::string serverName = serverLoc.getServerName();
-  int port = serverLoc.getPort();
-  char endpointName[100];
-  std::snprintf(endpointName, 100, "%s:%d", serverName.c_str(), port);
-
+  const auto endpointName =
+      serverLoc.getServerName() + ":" + std::to_string(serverLoc.getPort());
   return addEP(endpointName);
 }
 
@@ -1982,7 +1979,7 @@
     LOGFINE("Created new endpoint %s for pool %s", endpointName.c_str(),
             m_poolName.c_str());
     ep = createEP(endpointName.c_str());
-    if (m_endpoints.emplace(endpointName, ep).second) {
+    if (!m_endpoints.emplace(endpointName, ep).second) {
       LOGERROR("Failed to add endpoint %s to pool %s", endpointName.c_str(),
                m_poolName.c_str());
     }