You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by jb...@apache.org on 2018/10/10 16:59:44 UTC
[geode-native] branch develop updated (f735c53 -> cdcb703)
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git.
from f735c53 GEODE-5770: Fixes clang-analyzer-optin.performance.Padding warning
new 9ed0ced GEODE-5773: Fixes misc google-* clang-tidy warnings.
new ecc62a6 GEODE-5839: Fixes misc clang-tidy warnings.
new cdcb703 GEODE-5839: Fixes explicit constructor definition.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.clang-tidy | 54 +-
cppcache/include/geode/DataOutput.hpp | 2 +-
cppcache/include/geode/RegionAttributesFactory.hpp | 2 +-
.../geode/internal/CacheableBuiltinTemplates.hpp | 2 +-
cppcache/integration-test-2/framework/.clang-tidy | 14 +
cppcache/integration-test/BBNamingContext.cpp | 3 +-
.../integration-test/BuiltinCacheableWrappers.hpp | 7 +-
cppcache/integration-test/CacheHelper.cpp | 4 +-
cppcache/integration-test/CacheImplHelper.hpp | 2 +-
cppcache/integration-test/DeltaEx.hpp | 2 +-
cppcache/integration-test/LocatorHelper.hpp | 20 +-
cppcache/integration-test/QueryHelper.hpp | 2 +-
.../integration-test/ThinClientCallbackArg.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps2.hpp | 2 +-
cppcache/integration-test/ThinClientDurable.hpp | 2 +-
.../integration-test/ThinClientDurableFailover.hpp | 2 +-
.../integration-test/ThinClientDurableInterest.hpp | 2 +-
.../ThinClientDurableReconnect.hpp | 2 +-
cppcache/integration-test/ThinClientFailover.hpp | 2 +-
cppcache/integration-test/ThinClientFailover2.hpp | 2 +-
cppcache/integration-test/ThinClientFailover3.hpp | 2 +-
.../ThinClientFailoverInterest.hpp | 2 +-
.../ThinClientFailoverInterest2.hpp | 2 +-
.../ThinClientFailoverInterestAllWithCache.hpp | 2 +-
.../integration-test/ThinClientFailoverRegex.hpp | 2 +-
.../integration-test/ThinClientGatewayTest.hpp | 2 +-
cppcache/integration-test/ThinClientHelper.hpp | 2 +-
cppcache/integration-test/ThinClientInterest3.hpp | 2 +-
.../ThinClientInterest3Cacheless.hpp | 2 +-
.../integration-test/ThinClientInterestList.hpp | 2 +-
.../integration-test/ThinClientInterestList2.hpp | 2 +-
.../integration-test/ThinClientListenerInit.hpp | 4 +-
.../integration-test/ThinClientListenerWriter.hpp | 2 +-
.../ThinClientLocalCacheLoader.hpp | 4 +-
.../integration-test/ThinClientMultipleCaches.hpp | 2 +-
.../integration-test/ThinClientNotification.hpp | 2 +-
.../integration-test/ThinClientPdxSerializer.hpp | 2 +-
.../integration-test/ThinClientPdxSerializers.hpp | 6 +-
cppcache/integration-test/ThinClientPutAll.hpp | 2 +-
.../integration-test/ThinClientPutAllTimeout.hpp | 2 +-
.../ThinClientPutAllWithCallBack.hpp | 2 +-
cppcache/integration-test/ThinClientPutGetAll.hpp | 2 +-
.../ThinClientRIwithlocalRegionDestroy.hpp | 2 +-
cppcache/integration-test/ThinClientRegex.hpp | 2 +-
cppcache/integration-test/ThinClientRegex2.hpp | 2 +-
cppcache/integration-test/ThinClientRegex3.hpp | 2 +-
cppcache/integration-test/ThinClientRemoveAll.hpp | 2 +-
cppcache/integration-test/ThinClientSSL.hpp | 2 +-
.../integration-test/ThinClientSSLWithPassword.hpp | 2 +-
cppcache/integration-test/ThinClientSecurity.hpp | 2 +-
.../integration-test/ThinClientSecurityHelper.hpp | 4 +-
cppcache/integration-test/ThinClientTXFailover.hpp | 2 +-
cppcache/integration-test/ThinClientTasks_C2S2.hpp | 2 +-
.../integration-test/ThinClientTransactions.hpp | 2 +-
.../integration-test/ThinClientTransactionsXA.hpp | 2 +-
cppcache/integration-test/fw_dunit.cpp | 32 +-
cppcache/integration-test/fw_dunit.hpp | 4 +-
cppcache/integration-test/fw_spawn.hpp | 2 +-
cppcache/integration-test/locator_globals.hpp | 2 +-
.../integration-test/testRegionTemplateArgs.cpp | 1 +
cppcache/integration-test/testSerialization.cpp | 2 +-
cppcache/integration-test/testSpinLock.cpp | 2 +-
.../integration-test/testThinClientBigValue.cpp | 2 +-
.../testThinClientCacheablesLimits.cpp | 30 +-
.../testThinClientFixedPartitionResolver.cpp | 1 +
.../integration-test/testThinClientPRSingleHop.cpp | 17 +-
.../testThinClientPartitionResolver.cpp | 1 +
.../integration-test/testThinClientPdxInstance.cpp | 4 +-
.../testThinClientRemoteQueryRS.cpp | 3 -
.../testThinClientRemoteRegionQuery.cpp | 10 -
.../testThinClientSSLAuthCorrupt.cpp | 3 +-
.../integration-test/testThinClientSSLAuthFail.cpp | 3 +-
.../testThinClientSSLAuthUntrusted.cpp | 3 +-
.../testThinClientSSLWithSecurityAuthz.cpp | 2 +-
.../testThinClientSecurityAuthentication.cpp | 2 +-
.../testThinClientSecurityAuthenticationMU.cpp | 2 +-
...ientSecurityAuthenticationSetAuthInitialize.cpp | 2 +-
.../testThinClientSecurityAuthorization.cpp | 2 +-
.../testThinClientSecurityAuthorizationMU.cpp | 2 +-
.../testThinClientSecurityCQAuthorizationMU.cpp | 2 +-
.../integration-test/testThinClientSecurityDH.cpp | 2 +-
.../testThinClientSecurityDH_MU.cpp | 2 +-
...tThinClientSecurityDurableCQAuthorizationMU.cpp | 2 +-
.../testThinClientWriterException.cpp | 2 +-
cppcache/integration-test/testUtils.hpp | 2 +-
cppcache/src/AuthenticatedView.cpp | 2 +-
cppcache/src/CacheXmlParser.cpp | 1113 +++++++++-----------
cppcache/src/ClientMetadataService.cpp | 42 +-
cppcache/src/ClientMetadataService.hpp | 5 +-
cppcache/src/CqService.cpp | 2 +-
cppcache/src/ExpiryTaskManager.cpp | 9 +-
cppcache/src/FarSideEntryOp.cpp | 37 +-
.../src/InternalCacheTransactionManager2PCImpl.cpp | 19 +-
cppcache/src/LocalRegion.cpp | 10 +-
cppcache/src/MapSegment.hpp | 3 +-
cppcache/src/PdxHelper.cpp | 2 +-
cppcache/src/PdxInstanceFactory.cpp | 2 +-
cppcache/src/PdxTypeRegistry.cpp | 6 +-
cppcache/src/PoolFactory.cpp | 2 +-
cppcache/src/PoolXmlCreation.cpp | 6 +-
cppcache/src/PoolXmlCreation.hpp | 14 +-
cppcache/src/ProxyRegion.hpp | 4 +-
cppcache/src/Queue.hpp | 21 +-
cppcache/src/RegionAttributesFactory.cpp | 2 +-
cppcache/src/RegionCommit.cpp | 4 +-
cppcache/src/RegionXmlCreation.cpp | 9 +-
cppcache/src/RegionXmlCreation.hpp | 2 +-
cppcache/src/RemoteQuery.cpp | 10 +-
cppcache/src/SerializationRegistry.cpp | 2 +-
cppcache/src/SerializationRegistry.hpp | 11 +-
cppcache/src/TXCommitMessage.cpp | 16 +-
cppcache/src/TableOfPrimes.hpp | 25 +-
cppcache/src/TcrConnection.cpp | 3 +-
cppcache/src/TcrConnectionManager.hpp | 6 +-
cppcache/src/TcrEndpoint.cpp | 3 +-
cppcache/src/TcrMessage.cpp | 72 +-
cppcache/src/ThinClientBaseDM.hpp | 2 +-
cppcache/src/ThinClientLocatorHelper.cpp | 93 +-
cppcache/src/ThinClientLocatorHelper.hpp | 12 +-
cppcache/src/ThinClientPoolDM.cpp | 47 +-
cppcache/src/ThinClientPoolDM.hpp | 6 +-
cppcache/src/ThinClientRedundancyManager.cpp | 32 +-
cppcache/src/ThinClientRegion.cpp | 34 +-
cppcache/src/Utils.cpp | 7 -
cppcache/src/Utils.hpp | 18 +-
cppcache/src/statistics/HostStatSampler.cpp | 25 +-
cppcache/src/statistics/HostStatSampler.hpp | 14 +-
cppcache/test/ByteArray.cpp | 16 -
cppcache/test/CacheableKeyCreateTests.cpp | 3 +-
cppcache/test/SerializableCreateTests.cpp | 4 +-
cryptoimpl/DHImpl.cpp | 26 +-
dependencies/boost/CMakeLists.txt | 33 +-
dependencies/boost/patches | 16 +
dependencies/boost/solaris.patch | 25 -
dhimpl/DHImpl.cpp | 21 +-
tests/cpp/fwklib/FwkLog.cpp | 2 +-
tests/cpp/fwklib/IpcHandler.cpp | 2 +-
tests/cpp/security/PkcsAuthInit.cpp | 14 +-
tests/cpp/security/PkcsCredentialGenerator.hpp | 36 +-
tests/cpp/security/XmlAuthzCredentialGenerator.hpp | 30 +-
tests/cpp/testobject/DeltaFastAssetAccount.hpp | 2 +-
tests/cpp/testobject/PdxClassV1.hpp | 4 +-
tests/cpp/testobject/PdxClassV2.hpp | 4 +-
tests/cpp/testobject/TestObject1.cpp | 2 +-
145 files changed, 1053 insertions(+), 1299 deletions(-)
create mode 100644 cppcache/integration-test-2/framework/.clang-tidy
create mode 100644 dependencies/boost/patches
delete mode 100644 dependencies/boost/solaris.patch
[geode-native] 01/03: GEODE-5773: Fixes misc google-* clang-tidy
warnings.
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
commit 9ed0ceddf4cf15a40801cc1ed8436bf58cfd1b14
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Sat Sep 22 06:48:04 2018 -0700
GEODE-5773: Fixes misc google-* clang-tidy warnings.
* google-readability-braces-around-statements
* google-build-namespaces
---
.clang-tidy | 5 +++-
cppcache/integration-test/CacheImplHelper.hpp | 2 +-
cppcache/integration-test/DeltaEx.hpp | 2 +-
cppcache/integration-test/LocatorHelper.hpp | 20 +++++++++-------
cppcache/integration-test/QueryHelper.hpp | 2 +-
.../integration-test/ThinClientCallbackArg.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps2.hpp | 2 +-
cppcache/integration-test/ThinClientDurable.hpp | 2 +-
.../integration-test/ThinClientDurableFailover.hpp | 2 +-
.../integration-test/ThinClientDurableInterest.hpp | 2 +-
.../ThinClientDurableReconnect.hpp | 2 +-
cppcache/integration-test/ThinClientFailover.hpp | 2 +-
cppcache/integration-test/ThinClientFailover2.hpp | 2 +-
cppcache/integration-test/ThinClientFailover3.hpp | 2 +-
.../ThinClientFailoverInterest.hpp | 2 +-
.../ThinClientFailoverInterest2.hpp | 2 +-
.../ThinClientFailoverInterestAllWithCache.hpp | 2 +-
.../integration-test/ThinClientFailoverRegex.hpp | 2 +-
.../integration-test/ThinClientGatewayTest.hpp | 2 +-
cppcache/integration-test/ThinClientHelper.hpp | 2 +-
cppcache/integration-test/ThinClientInterest3.hpp | 2 +-
.../ThinClientInterest3Cacheless.hpp | 2 +-
.../integration-test/ThinClientInterestList.hpp | 2 +-
.../integration-test/ThinClientInterestList2.hpp | 2 +-
.../integration-test/ThinClientListenerInit.hpp | 2 +-
.../integration-test/ThinClientListenerWriter.hpp | 2 +-
.../ThinClientLocalCacheLoader.hpp | 2 +-
.../integration-test/ThinClientMultipleCaches.hpp | 2 +-
.../integration-test/ThinClientNotification.hpp | 2 +-
.../integration-test/ThinClientPdxSerializer.hpp | 2 +-
.../integration-test/ThinClientPdxSerializers.hpp | 2 +-
cppcache/integration-test/ThinClientPutAll.hpp | 2 +-
.../integration-test/ThinClientPutAllTimeout.hpp | 2 +-
.../ThinClientPutAllWithCallBack.hpp | 2 +-
cppcache/integration-test/ThinClientPutGetAll.hpp | 2 +-
.../ThinClientRIwithlocalRegionDestroy.hpp | 2 +-
cppcache/integration-test/ThinClientRegex.hpp | 2 +-
cppcache/integration-test/ThinClientRegex2.hpp | 2 +-
cppcache/integration-test/ThinClientRegex3.hpp | 2 +-
cppcache/integration-test/ThinClientRemoveAll.hpp | 2 +-
cppcache/integration-test/ThinClientSSL.hpp | 2 +-
.../integration-test/ThinClientSSLWithPassword.hpp | 2 +-
cppcache/integration-test/ThinClientSecurity.hpp | 2 +-
.../integration-test/ThinClientSecurityHelper.hpp | 2 +-
cppcache/integration-test/ThinClientTXFailover.hpp | 2 +-
cppcache/integration-test/ThinClientTasks_C2S2.hpp | 2 +-
.../integration-test/ThinClientTransactions.hpp | 2 +-
.../integration-test/ThinClientTransactionsXA.hpp | 2 +-
cppcache/integration-test/locator_globals.hpp | 2 +-
.../integration-test/testRegionTemplateArgs.cpp | 2 +-
cppcache/integration-test/testSpinLock.cpp | 2 +-
.../testThinClientSSLAuthCorrupt.cpp | 3 ++-
.../integration-test/testThinClientSSLAuthFail.cpp | 3 ++-
.../testThinClientSSLAuthUntrusted.cpp | 3 ++-
cppcache/integration-test/testUtils.hpp | 2 +-
cppcache/src/LocalRegion.cpp | 3 ++-
cppcache/src/TableOfPrimes.hpp | 25 +++++++++----------
cppcache/src/TcrConnection.cpp | 3 ++-
cppcache/src/TcrEndpoint.cpp | 3 ++-
cppcache/src/TcrMessage.cpp | 28 ++++++++++++++--------
cppcache/src/ThinClientPoolDM.cpp | 3 ++-
cppcache/src/ThinClientPoolDM.hpp | 6 +++--
cppcache/src/ThinClientRedundancyManager.cpp | 3 ++-
64 files changed, 118 insertions(+), 92 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index b9e74b0..2de6c8f 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,6 +1,6 @@
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments'
-WarningsAsErrors: 'google-build-using-namespace,google-readability-redundant-smartptr-get,google-explicit-constructor,google-global-names-in-headers,google-runtime-int,google-readability-casting,google-readability-namespace-comments,clang-analyzer-optin.performance.Padding'
+WarningsAsErrors: 'clang-analyzer-optin.performance.Padding,google-*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: file
@@ -50,3 +50,6 @@ CheckOptions:
# Disable Checks
# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule.
# google-readability-todo - Adds current user name when fix applied.
+
+# TODO - Fix these checks
+# google-default-arguments'
diff --git a/cppcache/integration-test/CacheImplHelper.hpp b/cppcache/integration-test/CacheImplHelper.hpp
index ac7c66d..5bb9ad0 100644
--- a/cppcache/integration-test/CacheImplHelper.hpp
+++ b/cppcache/integration-test/CacheImplHelper.hpp
@@ -33,7 +33,7 @@
#define ROOT_SCOPE LOCAL
#endif
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheHelper;
using apache::geode::client::Properties;
diff --git a/cppcache/integration-test/DeltaEx.hpp b/cppcache/integration-test/DeltaEx.hpp
index 260cb30..e2e78ec 100644
--- a/cppcache/integration-test/DeltaEx.hpp
+++ b/cppcache/integration-test/DeltaEx.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::DataInput;
using apache::geode::client::DataOutput;
diff --git a/cppcache/integration-test/LocatorHelper.hpp b/cppcache/integration-test/LocatorHelper.hpp
index 202022d..1fdb80c 100644
--- a/cppcache/integration-test/LocatorHelper.hpp
+++ b/cppcache/integration-test/LocatorHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_INTEGRATION_TEST_LOCATORHELPER_H_
-#define GEODE_INTEGRATION_TEST_LOCATORHELPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,11 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_INTEGRATION_TEST_LOCATORHELPER_H_
+#define GEODE_INTEGRATION_TEST_LOCATORHELPER_H_
+
#ifndef SERVER2
#define SERVER2 s2p2
#endif
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheHelper;
@@ -53,15 +54,18 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL)
{
// starting servers
- if (isLocalServer)
+ if (isLocalServer) {
CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true);
+ }
}
END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer2_With_Locator)
{
// starting servers
- if (isLocalServer) CacheHelper::initServer(2, nullptr, locatorsG);
+ if (isLocalServer) {
+ CacheHelper::initServer(2, nullptr, locatorsG);
+ }
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/QueryHelper.hpp b/cppcache/integration-test/QueryHelper.hpp
index 7aa59af..d3c9aec 100644
--- a/cppcache/integration-test/QueryHelper.hpp
+++ b/cppcache/integration-test/QueryHelper.hpp
@@ -51,7 +51,7 @@
#define ROOT_SCOPE LOCAL
#endif
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableStringArray;
diff --git a/cppcache/integration-test/ThinClientCallbackArg.hpp b/cppcache/integration-test/ThinClientCallbackArg.hpp
index 964d972..2dcf7ed 100644
--- a/cppcache/integration-test/ThinClientCallbackArg.hpp
+++ b/cppcache/integration-test/ThinClientCallbackArg.hpp
@@ -37,7 +37,7 @@
* + callback Argument
*/
-namespace {
+namespace { // NOLINT
using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
diff --git a/cppcache/integration-test/ThinClientDistOps.hpp b/cppcache/integration-test/ThinClientDistOps.hpp
index 6e1e47c..61d9c22 100644
--- a/cppcache/integration-test/ThinClientDistOps.hpp
+++ b/cppcache/integration-test/ThinClientDistOps.hpp
@@ -39,7 +39,7 @@
#define CREATE_TWICE_KEY "__create_twice_key"
#define CREATE_TWICE_VALUE "__create_twice_value"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
diff --git a/cppcache/integration-test/ThinClientDistOps2.hpp b/cppcache/integration-test/ThinClientDistOps2.hpp
index 4cf486a..10b2272 100644
--- a/cppcache/integration-test/ThinClientDistOps2.hpp
+++ b/cppcache/integration-test/ThinClientDistOps2.hpp
@@ -36,7 +36,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
diff --git a/cppcache/integration-test/ThinClientDurable.hpp b/cppcache/integration-test/ThinClientDurable.hpp
index 5fd025d..226f1ba 100644
--- a/cppcache/integration-test/ThinClientDurable.hpp
+++ b/cppcache/integration-test/ThinClientDurable.hpp
@@ -46,7 +46,7 @@ Client 1 is with R =0 and Client 2 with R = 1
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::EntryEvent;
using apache::geode::client::Exception;
diff --git a/cppcache/integration-test/ThinClientDurableFailover.hpp b/cppcache/integration-test/ThinClientDurableFailover.hpp
index 2220265..d113345 100644
--- a/cppcache/integration-test/ThinClientDurableFailover.hpp
+++ b/cppcache/integration-test/ThinClientDurableFailover.hpp
@@ -45,7 +45,7 @@ Shutdown
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::EntryEvent;
using apache::geode::client::Exception;
diff --git a/cppcache/integration-test/ThinClientDurableInterest.hpp b/cppcache/integration-test/ThinClientDurableInterest.hpp
index 4a798ad..3b7ce70 100644
--- a/cppcache/integration-test/ThinClientDurableInterest.hpp
+++ b/cppcache/integration-test/ThinClientDurableInterest.hpp
@@ -44,7 +44,7 @@ recieved.
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::EntryEvent;
using apache::geode::client::HashMapOfCacheable;
diff --git a/cppcache/integration-test/ThinClientDurableReconnect.hpp b/cppcache/integration-test/ThinClientDurableReconnect.hpp
index c4adb99..19b48ea 100644
--- a/cppcache/integration-test/ThinClientDurableReconnect.hpp
+++ b/cppcache/integration-test/ThinClientDurableReconnect.hpp
@@ -38,7 +38,7 @@
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::EntryEvent;
diff --git a/cppcache/integration-test/ThinClientFailover.hpp b/cppcache/integration-test/ThinClientFailover.hpp
index 1ce764d..1eb536e 100644
--- a/cppcache/integration-test/ThinClientFailover.hpp
+++ b/cppcache/integration-test/ThinClientFailover.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailover2.hpp b/cppcache/integration-test/ThinClientFailover2.hpp
index 37c63ca..4f44018 100644
--- a/cppcache/integration-test/ThinClientFailover2.hpp
+++ b/cppcache/integration-test/ThinClientFailover2.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailover3.hpp b/cppcache/integration-test/ThinClientFailover3.hpp
index a3bb641..a18b4f5 100644
--- a/cppcache/integration-test/ThinClientFailover3.hpp
+++ b/cppcache/integration-test/ThinClientFailover3.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverInterest.hpp b/cppcache/integration-test/ThinClientFailoverInterest.hpp
index 7af0822..f1ec444 100644
--- a/cppcache/integration-test/ThinClientFailoverInterest.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterest.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverInterest2.hpp b/cppcache/integration-test/ThinClientFailoverInterest2.hpp
index 5674478..9c77052 100644
--- a/cppcache/integration-test/ThinClientFailoverInterest2.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterest2.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp b/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
index faf6b9d..6485e18 100644
--- a/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
@@ -29,7 +29,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverRegex.hpp b/cppcache/integration-test/ThinClientFailoverRegex.hpp
index 71ea18d..349d37a 100644
--- a/cppcache/integration-test/ThinClientFailoverRegex.hpp
+++ b/cppcache/integration-test/ThinClientFailoverRegex.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientGatewayTest.hpp b/cppcache/integration-test/ThinClientGatewayTest.hpp
index 06a786b..3b396bf 100644
--- a/cppcache/integration-test/ThinClientGatewayTest.hpp
+++ b/cppcache/integration-test/ThinClientGatewayTest.hpp
@@ -33,7 +33,7 @@
#include <string>
-namespace {
+namespace { // NOLINT
using apache::geode::client::EntryEvent;
using apache::geode::client::RegionEvent;
diff --git a/cppcache/integration-test/ThinClientHelper.hpp b/cppcache/integration-test/ThinClientHelper.hpp
index 39ac430..a4f5f77 100644
--- a/cppcache/integration-test/ThinClientHelper.hpp
+++ b/cppcache/integration-test/ThinClientHelper.hpp
@@ -42,7 +42,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/ThinClientInterest3.hpp b/cppcache/integration-test/ThinClientInterest3.hpp
index 0f7c5fe..c9e0e06 100644
--- a/cppcache/integration-test/ThinClientInterest3.hpp
+++ b/cppcache/integration-test/ThinClientInterest3.hpp
@@ -29,7 +29,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
diff --git a/cppcache/integration-test/ThinClientInterest3Cacheless.hpp b/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
index 17ed22c..fbe73dd 100644
--- a/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
+++ b/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
@@ -29,7 +29,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
diff --git a/cppcache/integration-test/ThinClientInterestList.hpp b/cppcache/integration-test/ThinClientInterestList.hpp
index b2f563a..31bf6a1 100644
--- a/cppcache/integration-test/ThinClientInterestList.hpp
+++ b/cppcache/integration-test/ThinClientInterestList.hpp
@@ -33,7 +33,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientInterestList2.hpp b/cppcache/integration-test/ThinClientInterestList2.hpp
index 47dad05..a69ad39 100644
--- a/cppcache/integration-test/ThinClientInterestList2.hpp
+++ b/cppcache/integration-test/ThinClientInterestList2.hpp
@@ -34,7 +34,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientListenerInit.hpp b/cppcache/integration-test/ThinClientListenerInit.hpp
index 601b90a..f2015c8 100644
--- a/cppcache/integration-test/ThinClientListenerInit.hpp
+++ b/cppcache/integration-test/ThinClientListenerInit.hpp
@@ -30,7 +30,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::Cacheable;
diff --git a/cppcache/integration-test/ThinClientListenerWriter.hpp b/cppcache/integration-test/ThinClientListenerWriter.hpp
index 550bef0..a78262d 100644
--- a/cppcache/integration-test/ThinClientListenerWriter.hpp
+++ b/cppcache/integration-test/ThinClientListenerWriter.hpp
@@ -30,7 +30,7 @@
#define SERVER1 s2p1
#define CLIENT3 s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::EntryEvent;
using apache::geode::client::RegionEvent;
diff --git a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
index 472670d..64784ca 100644
--- a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
+++ b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
@@ -28,7 +28,7 @@
#define CLIENT1 s1p1
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::Cacheable;
using apache::geode::client::CacheFactory;
diff --git a/cppcache/integration-test/ThinClientMultipleCaches.hpp b/cppcache/integration-test/ThinClientMultipleCaches.hpp
index a994d1c..9c614c2 100644
--- a/cppcache/integration-test/ThinClientMultipleCaches.hpp
+++ b/cppcache/integration-test/ThinClientMultipleCaches.hpp
@@ -32,7 +32,7 @@
#define CLIENT1 s1p1
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::Cache;
using apache::geode::client::CacheFactory;
diff --git a/cppcache/integration-test/ThinClientNotification.hpp b/cppcache/integration-test/ThinClientNotification.hpp
index db5a896..951731e 100644
--- a/cppcache/integration-test/ThinClientNotification.hpp
+++ b/cppcache/integration-test/ThinClientNotification.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientPdxSerializer.hpp b/cppcache/integration-test/ThinClientPdxSerializer.hpp
index ef6b255..4cb9311 100644
--- a/cppcache/integration-test/ThinClientPdxSerializer.hpp
+++ b/cppcache/integration-test/ThinClientPdxSerializer.hpp
@@ -39,7 +39,7 @@
#define LOCATOR s2p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableBoolean;
using apache::geode::client::UserObjectSizer;
diff --git a/cppcache/integration-test/ThinClientPdxSerializers.hpp b/cppcache/integration-test/ThinClientPdxSerializers.hpp
index 7f6ed15..6ef9614 100644
--- a/cppcache/integration-test/ThinClientPdxSerializers.hpp
+++ b/cppcache/integration-test/ThinClientPdxSerializers.hpp
@@ -20,7 +20,7 @@
#ifndef GEODE_INTEGRATION_TEST_THINCLIENTPDXSERIALIZERS_H_
#define GEODE_INTEGRATION_TEST_THINCLIENTPDXSERIALIZERS_H_
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableArrayList;
using apache::geode::client::CacheableHashMap;
diff --git a/cppcache/integration-test/ThinClientPutAll.hpp b/cppcache/integration-test/ThinClientPutAll.hpp
index b4a3e88..355d0a5 100644
--- a/cppcache/integration-test/ThinClientPutAll.hpp
+++ b/cppcache/integration-test/ThinClientPutAll.hpp
@@ -33,7 +33,7 @@
#define ROOT_SCOPE DISTRIBUTED_ACK
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::Cache;
using apache::geode::client::CacheableInt32;
diff --git a/cppcache/integration-test/ThinClientPutAllTimeout.hpp b/cppcache/integration-test/ThinClientPutAllTimeout.hpp
index d865e7c..f11520a 100644
--- a/cppcache/integration-test/ThinClientPutAllTimeout.hpp
+++ b/cppcache/integration-test/ThinClientPutAllTimeout.hpp
@@ -29,7 +29,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::Exception;
using apache::geode::client::HashMapOfCacheable;
diff --git a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
index ba6cec3..5da3246 100644
--- a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
+++ b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
@@ -39,7 +39,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
diff --git a/cppcache/integration-test/ThinClientPutGetAll.hpp b/cppcache/integration-test/ThinClientPutGetAll.hpp
index a62f1e3..f812b81 100644
--- a/cppcache/integration-test/ThinClientPutGetAll.hpp
+++ b/cppcache/integration-test/ThinClientPutGetAll.hpp
@@ -38,7 +38,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using PdxTests::PdxTypes1;
using PdxTests::PdxTypes10;
diff --git a/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp b/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
index 498173b..bb31ad1 100644
--- a/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
+++ b/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientRegex.hpp b/cppcache/integration-test/ThinClientRegex.hpp
index 7282d92..483ed23 100644
--- a/cppcache/integration-test/ThinClientRegex.hpp
+++ b/cppcache/integration-test/ThinClientRegex.hpp
@@ -34,7 +34,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientRegex2.hpp b/cppcache/integration-test/ThinClientRegex2.hpp
index 511be90..765ad20 100644
--- a/cppcache/integration-test/ThinClientRegex2.hpp
+++ b/cppcache/integration-test/ThinClientRegex2.hpp
@@ -34,7 +34,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientRegex3.hpp b/cppcache/integration-test/ThinClientRegex3.hpp
index 612a8b0..ddebb2c 100644
--- a/cppcache/integration-test/ThinClientRegex3.hpp
+++ b/cppcache/integration-test/ThinClientRegex3.hpp
@@ -33,7 +33,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace {
+namespace { // NOLINT
using apache::geode::client::Cacheable;
using apache::geode::client::CacheableInt32;
diff --git a/cppcache/integration-test/ThinClientRemoveAll.hpp b/cppcache/integration-test/ThinClientRemoveAll.hpp
index b58f38d..026c77c 100644
--- a/cppcache/integration-test/ThinClientRemoveAll.hpp
+++ b/cppcache/integration-test/ThinClientRemoveAll.hpp
@@ -41,7 +41,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableKey;
diff --git a/cppcache/integration-test/ThinClientSSL.hpp b/cppcache/integration-test/ThinClientSSL.hpp
index 8850bef..a77309d 100644
--- a/cppcache/integration-test/ThinClientSSL.hpp
+++ b/cppcache/integration-test/ThinClientSSL.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientSSLWithPassword.hpp b/cppcache/integration-test/ThinClientSSLWithPassword.hpp
index 06b34a8..6ddf593 100644
--- a/cppcache/integration-test/ThinClientSSLWithPassword.hpp
+++ b/cppcache/integration-test/ThinClientSSLWithPassword.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientSecurity.hpp b/cppcache/integration-test/ThinClientSecurity.hpp
index 0ada7ca..2463832 100644
--- a/cppcache/integration-test/ThinClientSecurity.hpp
+++ b/cppcache/integration-test/ThinClientSecurity.hpp
@@ -26,7 +26,7 @@
#include "CacheImplHelper.hpp"
#include "testUtils.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::AuthenticatedView;
diff --git a/cppcache/integration-test/ThinClientSecurityHelper.hpp b/cppcache/integration-test/ThinClientSecurityHelper.hpp
index 2091ecc..dfae3de 100644
--- a/cppcache/integration-test/ThinClientSecurityHelper.hpp
+++ b/cppcache/integration-test/ThinClientSecurityHelper.hpp
@@ -26,7 +26,7 @@
#include "ThinClientHelper.hpp"
#include "hacks/AceThreadId.h"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableBoolean;
using apache::geode::client::Exception;
diff --git a/cppcache/integration-test/ThinClientTXFailover.hpp b/cppcache/integration-test/ThinClientTXFailover.hpp
index 01d3608..061f076 100644
--- a/cppcache/integration-test/ThinClientTXFailover.hpp
+++ b/cppcache/integration-test/ThinClientTXFailover.hpp
@@ -32,7 +32,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientTasks_C2S2.hpp b/cppcache/integration-test/ThinClientTasks_C2S2.hpp
index 37fc0bf..d3d9ded 100644
--- a/cppcache/integration-test/ThinClientTasks_C2S2.hpp
+++ b/cppcache/integration-test/ThinClientTasks_C2S2.hpp
@@ -32,7 +32,7 @@
#define PROCESS3 s2p1
#define PROCESS4 s2p2
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/ThinClientTransactions.hpp b/cppcache/integration-test/ThinClientTransactions.hpp
index 6a781b9..ff41477 100644
--- a/cppcache/integration-test/ThinClientTransactions.hpp
+++ b/cppcache/integration-test/ThinClientTransactions.hpp
@@ -34,7 +34,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientTransactionsXA.hpp b/cppcache/integration-test/ThinClientTransactionsXA.hpp
index a2b4cd4..436f55d 100644
--- a/cppcache/integration-test/ThinClientTransactionsXA.hpp
+++ b/cppcache/integration-test/ThinClientTransactionsXA.hpp
@@ -34,7 +34,7 @@
#include "CacheHelper.hpp"
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/locator_globals.hpp b/cppcache/integration-test/locator_globals.hpp
index d1bc3d1..ab04511 100644
--- a/cppcache/integration-test/locator_globals.hpp
+++ b/cppcache/integration-test/locator_globals.hpp
@@ -20,7 +20,7 @@
#ifndef GEODE_INTEGRATION_TEST_LOCATOR_GLOBALS_H_
#define GEODE_INTEGRATION_TEST_LOCATOR_GLOBALS_H_
-namespace {
+namespace { // NOLINT
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/testRegionTemplateArgs.cpp b/cppcache/integration-test/testRegionTemplateArgs.cpp
index 84f5b4a..0432dc9 100644
--- a/cppcache/integration-test/testRegionTemplateArgs.cpp
+++ b/cppcache/integration-test/testRegionTemplateArgs.cpp
@@ -46,7 +46,7 @@ bool CheckBytesEqual(std::shared_ptr<CacheableBytes> result,
// This test checks the template methods of Region API with all possible
// combinations of key and value types.
-BEGIN_TEST(CheckTemplates)
+BEGIN_TEST(CheckTemplates) // NOLINT
{
auto cacheFactory = CacheFactory();
auto cache = std::make_shared<Cache>(cacheFactory.create());
diff --git a/cppcache/integration-test/testSpinLock.cpp b/cppcache/integration-test/testSpinLock.cpp
index 5878277..425cd0a 100644
--- a/cppcache/integration-test/testSpinLock.cpp
+++ b/cppcache/integration-test/testSpinLock.cpp
@@ -26,7 +26,7 @@
#include <ace/Time_Value.h>
#include <ace/Guard_T.h>
-namespace {
+namespace { // NOLINT
using apache::geode::util::concurrent::spinlock_mutex;
diff --git a/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp b/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
index 7ff72b4..0540cb5 100644
--- a/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
+++ b/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
@@ -126,9 +126,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
{
// starting servers
- if (isLocalServer)
+ if (isLocalServer) {
CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true, true, false,
false, false);
+ }
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/testThinClientSSLAuthFail.cpp b/cppcache/integration-test/testThinClientSSLAuthFail.cpp
index d84815d..f99571a 100644
--- a/cppcache/integration-test/testThinClientSSLAuthFail.cpp
+++ b/cppcache/integration-test/testThinClientSSLAuthFail.cpp
@@ -126,9 +126,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
{
// starting servers
- if (isLocalServer)
+ if (isLocalServer) {
CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true, true, false,
false, true);
+ }
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp b/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
index fa7c3d4..a3824ff 100644
--- a/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
+++ b/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
@@ -127,9 +127,10 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(SERVER1, CreateServer1_With_Locator_And_SSL_untrustedCert)
{
// starting servers
- if (isLocalServer)
+ if (isLocalServer) {
CacheHelper::initServer(1, nullptr, locatorsG, nullptr, true, true, false,
false, false);
+ }
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/testUtils.hpp b/cppcache/integration-test/testUtils.hpp
index 84c746e..1139d8f 100644
--- a/cppcache/integration-test/testUtils.hpp
+++ b/cppcache/integration-test/testUtils.hpp
@@ -40,7 +40,7 @@
#include <DistributedSystemImpl.hpp>
#include <CacheImpl.hpp>
-namespace {
+namespace { // NOLINT
using apache::geode::client::Cache;
using apache::geode::client::CacheableKey;
diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp
index 6cc6699..9b88901 100644
--- a/cppcache/src/LocalRegion.cpp
+++ b/cppcache/src/LocalRegion.cpp
@@ -275,8 +275,9 @@ std::shared_ptr<Region> LocalRegion::createSubregion(
std::vector<std::shared_ptr<Region>> LocalRegion::subregions(
const bool recursive) {
CHECK_DESTROY_PENDING(TryReadGuard, LocalRegion::subregions);
- if (m_subRegions.current_size() == 0)
+ if (m_subRegions.current_size() == 0) {
return std::vector<std::shared_ptr<Region>>();
+ }
return subregions_internal(recursive);
}
diff --git a/cppcache/src/TableOfPrimes.hpp b/cppcache/src/TableOfPrimes.hpp
index 6253baa..26bfa93 100644
--- a/cppcache/src/TableOfPrimes.hpp
+++ b/cppcache/src/TableOfPrimes.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_TABLEOFPRIMES_H_
-#define GEODE_TABLEOFPRIMES_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,10 +15,20 @@
* limitations under the License.
*/
-#include <geode/internal/geode_globals.hpp>
+#pragma once
+
+#ifndef GEODE_TABLEOFPRIMES_H_
+#define GEODE_TABLEOFPRIMES_H_
+
#include <algorithm>
-namespace {
+#include <geode/internal/geode_globals.hpp>
+#include <geode/ExceptionTypes.hpp>
+
+namespace apache {
+namespace geode {
+namespace client {
+
static const uint32_t g_primeTable[] = {
53, 97, 193, 389, 769, 1543,
3079, 6151, 12289, 24593, 49157, 98317,
@@ -40,11 +45,6 @@ static const uint8_t g_primeConcurTable[] = {
static const uint8_t g_primeConcurLen =
static_cast<uint8_t>(sizeof(g_primeConcurTable) / sizeof(uint8_t));
-} // anonymous namespace
-
-namespace apache {
-namespace geode {
-namespace client {
/** @brief find a prime number greater than a given integer.
* A sampling of primes are used from 0 to 1 million. Not every prime is
* necessary, as the map scales, little steps are usually uninteresting.
@@ -87,6 +87,7 @@ class APACHE_GEODE_EXPORT TableOfPrimes {
"find a prime number that large");
}
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp
index 8565eed..b50b9fc 100644
--- a/cppcache/src/TcrConnection.cpp
+++ b/cppcache/src/TcrConnection.cpp
@@ -1475,8 +1475,9 @@ bool TcrConnection::setAndGetBeingUsed(volatile bool isBeingUsed,
if (m_isUsed == 2) { // transaction thread has set, reused it
return true;
}
- if (m_isUsed.compare_exchange_strong(currentValue, 2 /*for transaction*/))
+ if (m_isUsed.compare_exchange_strong(currentValue, 2 /*for transaction*/)) {
return true;
+ }
return false;
} else {
// m_isUsed = 0;//this will done by releasing the connection by
diff --git a/cppcache/src/TcrEndpoint.cpp b/cppcache/src/TcrEndpoint.cpp
index 987be3c..b61bb90 100644
--- a/cppcache/src/TcrEndpoint.cpp
+++ b/cppcache/src/TcrEndpoint.cpp
@@ -878,8 +878,9 @@ GfErrType TcrEndpoint::sendRequestConn(const TcrMessage& request,
error = GF_NOTCON;
}
if (error == GF_NOERR) {
- if (m_baseDM != nullptr)
+ if (m_baseDM) {
m_baseDM->afterSendingRequest(request, reply, conn);
+ }
}
return error;
diff --git a/cppcache/src/TcrMessage.cpp b/cppcache/src/TcrMessage.cpp
index f21bb31..83c4a2b 100644
--- a/cppcache/src/TcrMessage.cpp
+++ b/cppcache/src/TcrMessage.cpp
@@ -85,7 +85,7 @@ void TcrMessage::setKeepAlive(bool keepalive) {
void TcrMessage::writeInterestResultPolicyPart(InterestResultPolicy policy) {
m_request->writeInt(static_cast<int32_t>(3)); // size
- m_request->write(static_cast<int8_t>(1)); // isObject
+ m_request->write(static_cast<int8_t>(1)); // isObject
m_request->write(static_cast<int8_t>(DSCode::FixedIDByte));
m_request->write(static_cast<int8_t>(DSCode::InterestResultPolicy));
m_request->write(static_cast<int8_t>(policy.getOrdinal()));
@@ -626,7 +626,8 @@ void TcrMessage::writeRegionPart(const std::string& regionName) {
int32_t len = static_cast<int32_t>(regionName.length());
m_request->writeInt(len);
m_request->write(static_cast<int8_t>(0)); // isObject = 0
- m_request->writeBytesOnly(reinterpret_cast<int8_t*>(const_cast<char*>(regionName.c_str())), len);
+ m_request->writeBytesOnly(
+ reinterpret_cast<int8_t*>(const_cast<char*>(regionName.c_str())), len);
}
void TcrMessage::writeStringPart(const std::string& str) {
@@ -1070,8 +1071,9 @@ void TcrMessage::handleByteArrayResponse(
case TcrMessage::INVALIDATE: {
uint32_t flags = 0;
readIntPart(input, &flags);
- if (flags & 0x01)
+ if (flags & 0x01) {
readVersionTag(input, endpointMemId, memberListForVersionStamp);
+ }
readPrMetaData(input);
break;
@@ -1079,8 +1081,9 @@ void TcrMessage::handleByteArrayResponse(
case TcrMessage::DESTROY: {
uint32_t flags = 0;
readIntPart(input, &flags);
- if (flags & 0x01)
+ if (flags & 0x01) {
readVersionTag(input, endpointMemId, memberListForVersionStamp);
+ }
readPrMetaData(input);
// skip the Destroy65.java response entryNotFound int part so
// that the readSecureObjectPart() call below gets the security part
@@ -1386,8 +1389,9 @@ TcrMessageDestroyRegion::TcrMessageDestroyRegion(
numOfParts++;
- if (m_messageResponseTimeout >= std::chrono::milliseconds::zero())
+ if (m_messageResponseTimeout >= std::chrono::milliseconds::zero()) {
numOfParts++;
+ }
writeHeader(m_msgType, numOfParts);
writeRegionPart(m_regionName);
writeEventIdPart();
@@ -1425,8 +1429,9 @@ TcrMessageClearRegion::TcrMessageClearRegion(
numOfParts++;
- if (m_messageResponseTimeout >= std::chrono::milliseconds::zero())
+ if (m_messageResponseTimeout >= std::chrono::milliseconds::zero()) {
numOfParts++;
+ }
writeHeader(m_msgType, numOfParts);
writeRegionPart(m_regionName);
writeEventIdPart();
@@ -1455,8 +1460,9 @@ TcrMessageQuery::TcrMessageQuery(
numOfParts++;
- if (m_messageResponseTimeout >= std::chrono::milliseconds::zero())
+ if (m_messageResponseTimeout >= std::chrono::milliseconds::zero()) {
numOfParts++;
+ }
writeHeader(m_msgType, numOfParts);
writeRegionPart(m_regionName);
writeEventIdPart();
@@ -1830,7 +1836,7 @@ TcrMessageCloseConnection::TcrMessageCloseConnection(DataOutput* dataOutput,
m_request->write(static_cast<int8_t>(0)); // Early ack is '0'.
// last two parts are not used ... setting zero in both the parts.
m_request->writeInt(static_cast<int32_t>(1)); // len is 1
- m_request->write(static_cast<int8_t>(0)); // is obj is '0'.
+ m_request->write(static_cast<int8_t>(0)); // is obj is '0'.
// cast away constness here since we want to modify this
TcrMessage::m_keepalive = const_cast<uint8_t*>(m_request->getCursor());
m_request->write(static_cast<int8_t>(0)); // keepalive is '0'.
@@ -2130,8 +2136,9 @@ TcrMessagePutAll::TcrMessagePutAll(
// numOfParts++;
- if (m_messageResponseTimeout >= std::chrono::milliseconds::zero())
+ if (m_messageResponseTimeout >= std::chrono::milliseconds::zero()) {
numOfParts++;
+ }
writeHeader(m_msgType, numOfParts);
writeRegionPart(m_regionName);
@@ -2186,8 +2193,9 @@ TcrMessageRemoveAll::TcrMessageRemoveAll(
// value can be nullptr also.
uint32_t numOfParts = 5 + static_cast<uint32_t>(keys.size());
- if (m_messageResponseTimeout >= std::chrono::milliseconds::zero())
+ if (m_messageResponseTimeout >= std::chrono::milliseconds::zero()) {
numOfParts++;
+ }
writeHeader(m_msgType, numOfParts);
writeRegionPart(m_regionName);
writeEventIdPart(static_cast<int>(keys.size() - 1));
diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp
index cd83156..cc90da0 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -1979,8 +1979,9 @@ GfErrType ThinClientPoolDM::sendRequestToEP(const TcrMessage& request,
if (ua == nullptr) {
LOGWARN("Attempted operation type %d without credentials",
request.getMessageType());
- if (conn != nullptr)
+ if (conn) {
putInQueue(conn, false, request.forTransaction());
+ }
return GF_NOT_AUTHORIZED_EXCEPTION;
} else {
UserConnectionAttributes* uca =
diff --git a/cppcache/src/ThinClientPoolDM.hpp b/cppcache/src/ThinClientPoolDM.hpp
index 6cd9f20..bb7dc89 100644
--- a/cppcache/src/ThinClientPoolDM.hpp
+++ b/cppcache/src/ThinClientPoolDM.hpp
@@ -396,8 +396,9 @@ class FunctionExecution : public PooledWork<GfErrType> {
// TSSUserAttributesWrapper::s_geodeTSSUserAttributes->setUserAttributes(m_userAttr);
GuardUserAttributes gua;
- if (m_userAttr != nullptr)
+ if (m_userAttr) {
gua.setAuthenticatedView(m_userAttr->getAuthenticatedView());
+ }
std::string funcName(m_func);
TcrMessageExecuteFunction request(
@@ -524,8 +525,9 @@ class OnRegionFunctionExecution : public PooledWork<GfErrType> {
GfErrType execute(void) {
GuardUserAttributes gua;
- if (m_userAttr != nullptr)
+ if (m_userAttr) {
gua.setAuthenticatedView(m_userAttr->getAuthenticatedView());
+ }
return m_poolDM->sendSyncRequest(*m_request, *m_reply, !(m_getResult & 1),
m_isBGThread, m_serverLocation);
diff --git a/cppcache/src/ThinClientRedundancyManager.cpp b/cppcache/src/ThinClientRedundancyManager.cpp
index 92c4c46..ad180b7 100644
--- a/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/cppcache/src/ThinClientRedundancyManager.cpp
@@ -872,8 +872,9 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestCq(
if (err != GF_NOERR || m_redundantEndpoints.empty()) {
auto userAttr = TSSUserAttributesWrapper::s_geodeTSSUserAttributes
->getUserAttributes();
- if (userAttr != nullptr)
+ if (userAttr) {
authenticatedView = userAttr->getAuthenticatedView();
+ }
err = maintainRedundancyLevel();
// we continue on fatal error because MRL only tries a handshake without
// sending a request (no params passed) so no need to check
[geode-native] 02/03: GEODE-5839: Fixes misc clang-tidy warnings.
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
commit ecc62a61c93d72c759a3139ce4620eb335f89a15
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Mon Oct 8 17:21:48 2018 -0700
GEODE-5839: Fixes misc clang-tidy warnings.
* Fixes clang-analyzer-core.CallAndMessage warning
* Fixes clang-diagnostic-return-std-move-in-c++11 warning.
* Cleanup NOLINT with specific warning it suppresses.
* Fixes clang-analyzer-core.CallAndMessage warning
* Updates to Boost 1.68 to fix uninitilalized variable.
* Fixes clang-analyzer-unix.* warnings.
* Fixes clang-analyzer-unix.* warnings.
* Fixes clang-analyzer-cplusplus.NewDeleteLeaks warnings.
* Fixes clang-analyzer-security.insecureAPI.rand warnings.
* Fixes remaining clang-diagnostic-* warnings.
* Fixes clang-analyzer-deadcode.DeadStores warnings.
* Fixes clang-analyzer-security.insecureAPI.strcpy warning
* Fixes clang-analyzer-cplusplus.NewDelete warning
* Cleanup clang-tidy configs
---
.clang-tidy | 53 +-
cppcache/include/geode/DataOutput.hpp | 2 +-
cppcache/include/geode/RegionAttributesFactory.hpp | 2 +-
cppcache/integration-test-2/framework/.clang-tidy | 12 +
cppcache/integration-test/BBNamingContext.cpp | 3 +-
.../integration-test/BuiltinCacheableWrappers.hpp | 7 +-
cppcache/integration-test/CacheHelper.cpp | 4 +-
cppcache/integration-test/CacheImplHelper.hpp | 2 +-
cppcache/integration-test/DeltaEx.hpp | 2 +-
cppcache/integration-test/LocatorHelper.hpp | 2 +-
cppcache/integration-test/QueryHelper.hpp | 2 +-
.../integration-test/ThinClientCallbackArg.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps.hpp | 2 +-
cppcache/integration-test/ThinClientDistOps2.hpp | 2 +-
cppcache/integration-test/ThinClientDurable.hpp | 2 +-
.../integration-test/ThinClientDurableFailover.hpp | 2 +-
.../integration-test/ThinClientDurableInterest.hpp | 2 +-
.../ThinClientDurableReconnect.hpp | 2 +-
cppcache/integration-test/ThinClientFailover.hpp | 2 +-
cppcache/integration-test/ThinClientFailover2.hpp | 2 +-
cppcache/integration-test/ThinClientFailover3.hpp | 2 +-
.../ThinClientFailoverInterest.hpp | 2 +-
.../ThinClientFailoverInterest2.hpp | 2 +-
.../ThinClientFailoverInterestAllWithCache.hpp | 2 +-
.../integration-test/ThinClientFailoverRegex.hpp | 2 +-
.../integration-test/ThinClientGatewayTest.hpp | 2 +-
cppcache/integration-test/ThinClientHelper.hpp | 2 +-
cppcache/integration-test/ThinClientInterest3.hpp | 2 +-
.../ThinClientInterest3Cacheless.hpp | 2 +-
.../integration-test/ThinClientInterestList.hpp | 2 +-
.../integration-test/ThinClientInterestList2.hpp | 2 +-
.../integration-test/ThinClientListenerInit.hpp | 4 +-
.../integration-test/ThinClientListenerWriter.hpp | 2 +-
.../ThinClientLocalCacheLoader.hpp | 4 +-
.../integration-test/ThinClientMultipleCaches.hpp | 2 +-
.../integration-test/ThinClientNotification.hpp | 2 +-
.../integration-test/ThinClientPdxSerializer.hpp | 2 +-
.../integration-test/ThinClientPdxSerializers.hpp | 6 +-
cppcache/integration-test/ThinClientPutAll.hpp | 2 +-
.../integration-test/ThinClientPutAllTimeout.hpp | 2 +-
.../ThinClientPutAllWithCallBack.hpp | 2 +-
cppcache/integration-test/ThinClientPutGetAll.hpp | 2 +-
.../ThinClientRIwithlocalRegionDestroy.hpp | 2 +-
cppcache/integration-test/ThinClientRegex.hpp | 2 +-
cppcache/integration-test/ThinClientRegex2.hpp | 2 +-
cppcache/integration-test/ThinClientRegex3.hpp | 2 +-
cppcache/integration-test/ThinClientRemoveAll.hpp | 2 +-
cppcache/integration-test/ThinClientSSL.hpp | 2 +-
.../integration-test/ThinClientSSLWithPassword.hpp | 2 +-
cppcache/integration-test/ThinClientSecurity.hpp | 2 +-
.../integration-test/ThinClientSecurityHelper.hpp | 4 +-
cppcache/integration-test/ThinClientTXFailover.hpp | 2 +-
cppcache/integration-test/ThinClientTasks_C2S2.hpp | 2 +-
.../integration-test/ThinClientTransactions.hpp | 2 +-
.../integration-test/ThinClientTransactionsXA.hpp | 2 +-
cppcache/integration-test/fw_dunit.cpp | 32 +-
cppcache/integration-test/fw_dunit.hpp | 4 +-
cppcache/integration-test/fw_spawn.hpp | 2 +-
cppcache/integration-test/locator_globals.hpp | 2 +-
.../integration-test/testRegionTemplateArgs.cpp | 3 +-
cppcache/integration-test/testSerialization.cpp | 2 +-
cppcache/integration-test/testSpinLock.cpp | 2 +-
.../integration-test/testThinClientBigValue.cpp | 2 +-
.../testThinClientCacheablesLimits.cpp | 30 +-
.../testThinClientFixedPartitionResolver.cpp | 1 +
.../integration-test/testThinClientPRSingleHop.cpp | 17 +-
.../testThinClientPartitionResolver.cpp | 1 +
.../integration-test/testThinClientPdxInstance.cpp | 4 +-
.../testThinClientRemoteQueryRS.cpp | 3 -
.../testThinClientRemoteRegionQuery.cpp | 10 -
.../testThinClientSSLWithSecurityAuthz.cpp | 2 +-
.../testThinClientSecurityAuthentication.cpp | 2 +-
.../testThinClientSecurityAuthenticationMU.cpp | 2 +-
...ientSecurityAuthenticationSetAuthInitialize.cpp | 2 +-
.../testThinClientSecurityAuthorization.cpp | 2 +-
.../testThinClientSecurityAuthorizationMU.cpp | 2 +-
.../testThinClientSecurityCQAuthorizationMU.cpp | 2 +-
.../integration-test/testThinClientSecurityDH.cpp | 2 +-
.../testThinClientSecurityDH_MU.cpp | 2 +-
...tThinClientSecurityDurableCQAuthorizationMU.cpp | 2 +-
.../testThinClientWriterException.cpp | 2 +-
cppcache/integration-test/testUtils.hpp | 2 +-
cppcache/src/AuthenticatedView.cpp | 2 +-
cppcache/src/CacheXmlParser.cpp | 1113 +++++++++-----------
cppcache/src/ClientMetadataService.cpp | 42 +-
cppcache/src/ClientMetadataService.hpp | 5 +-
cppcache/src/CqService.cpp | 2 +-
cppcache/src/ExpiryTaskManager.cpp | 9 +-
cppcache/src/FarSideEntryOp.cpp | 37 +-
.../src/InternalCacheTransactionManager2PCImpl.cpp | 19 +-
cppcache/src/LocalRegion.cpp | 7 +-
cppcache/src/MapSegment.hpp | 3 +-
cppcache/src/PdxHelper.cpp | 2 +-
cppcache/src/PdxInstanceFactory.cpp | 2 +-
cppcache/src/PdxTypeRegistry.cpp | 6 +-
cppcache/src/PoolFactory.cpp | 2 +-
cppcache/src/PoolXmlCreation.cpp | 6 +-
cppcache/src/PoolXmlCreation.hpp | 14 +-
cppcache/src/ProxyRegion.hpp | 4 +-
cppcache/src/Queue.hpp | 21 +-
cppcache/src/RegionAttributesFactory.cpp | 2 +-
cppcache/src/RegionCommit.cpp | 4 +-
cppcache/src/RegionXmlCreation.cpp | 9 +-
cppcache/src/RegionXmlCreation.hpp | 2 +-
cppcache/src/RemoteQuery.cpp | 10 +-
cppcache/src/SerializationRegistry.cpp | 2 +-
cppcache/src/SerializationRegistry.hpp | 11 +-
cppcache/src/TXCommitMessage.cpp | 16 +-
cppcache/src/TcrConnectionManager.hpp | 6 +-
cppcache/src/TcrMessage.cpp | 44 +-
cppcache/src/ThinClientBaseDM.hpp | 2 +-
cppcache/src/ThinClientLocatorHelper.cpp | 93 +-
cppcache/src/ThinClientLocatorHelper.hpp | 12 +-
cppcache/src/ThinClientPoolDM.cpp | 44 +-
cppcache/src/ThinClientRedundancyManager.cpp | 29 +-
cppcache/src/ThinClientRegion.cpp | 34 +-
cppcache/src/Utils.cpp | 7 -
cppcache/src/Utils.hpp | 18 +-
cppcache/src/statistics/HostStatSampler.cpp | 25 +-
cppcache/src/statistics/HostStatSampler.hpp | 14 +-
cppcache/test/ByteArray.cpp | 16 -
cppcache/test/CacheableKeyCreateTests.cpp | 3 +-
cppcache/test/SerializableCreateTests.cpp | 4 +-
cryptoimpl/DHImpl.cpp | 26 +-
dependencies/boost/CMakeLists.txt | 33 +-
dependencies/boost/patches | 16 +
dependencies/boost/solaris.patch | 25 -
dhimpl/DHImpl.cpp | 21 +-
tests/cpp/fwklib/FwkLog.cpp | 2 +-
tests/cpp/fwklib/IpcHandler.cpp | 2 +-
tests/cpp/security/PkcsAuthInit.cpp | 14 +-
tests/cpp/security/PkcsCredentialGenerator.hpp | 36 +-
tests/cpp/security/XmlAuthzCredentialGenerator.hpp | 30 +-
tests/cpp/testobject/DeltaFastAssetAccount.hpp | 2 +-
tests/cpp/testobject/PdxClassV1.hpp | 4 +-
tests/cpp/testobject/PdxClassV2.hpp | 4 +-
tests/cpp/testobject/TestObject1.cpp | 2 +-
137 files changed, 987 insertions(+), 1261 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 2de6c8f..0968e48 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,50 +1,8 @@
---
-Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments'
-WarningsAsErrors: 'clang-analyzer-optin.performance.Padding,google-*'
+Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-optin.cplusplus.VirtualCall'
+WarningsAsErrors: 'clang-analyzer-optin.performance.*,clang-analyzer-core.*,clang-analyzer-unix.*,clang-diagnostic-*,google-*,clang-analyzer-cplusplus.*,clang-analyzer-security.insecureAPI.*,clang-analyzer-deadcode.*'
HeaderFilterRegex: '.*'
-AnalyzeTemporaryDtors: false
FormatStyle: file
-CheckOptions:
- - key: google-build-namespaces.HeaderFileExtensions
- value: h,hh,hpp,hxx
- - key: google-global-names-in-headers.HeaderFileExtensions
- value: h
- - key: google-readability-braces-around-statements.ShortStatementLines
- value: '1'
- - key: google-readability-function-size.BranchThreshold
- value: '4294967295'
- - key: google-readability-function-size.LineThreshold
- value: '4294967295'
- - key: google-readability-function-size.NestingThreshold
- value: '4294967295'
- - key: google-readability-function-size.ParameterThreshold
- value: '4294967295'
- - key: google-readability-function-size.StatementThreshold
- value: '800'
- - key: google-readability-namespace-comments.ShortNamespaceLines
- value: '0'
- - key: google-readability-namespace-comments.SpacesBeforeComments
- value: '2'
- - key: google-runtime-int.SignedTypePrefix
- value: int
- - key: google-runtime-int.TypeSuffix
- value: ''
- - key: google-runtime-int.UnsignedTypePrefix
- value: uint
- - key: google-runtime-references.WhiteListTypes
- value: ''
- - key: modernize-loop-convert.MaxCopySize
- value: '16'
- - key: modernize-loop-convert.MinConfidence
- value: reasonable
- - key: modernize-loop-convert.NamingStyle
- value: CamelCase
- - key: modernize-pass-by-value.IncludeStyle
- value: llvm
- - key: modernize-replace-auto-ptr.IncludeStyle
- value: llvm
- - key: modernize-use-nullptr.NullMacros
- value: 'NULL'
...
# Disable Checks
@@ -52,4 +10,9 @@ CheckOptions:
# google-readability-todo - Adds current user name when fix applied.
# TODO - Fix these checks
-# google-default-arguments'
+# google-default-arguments
+# clang-analyzer-core.uninitialized.UndefReturn - Generates errors in ACE, how do we ignore?
+# clang-analyzer-core.UndefinedBinaryOperatorResult - Generates errors in ACE, how do we ignore?
+
+# TEMP
+# clang-analyzer-optin.cplusplus.VirtualCall
\ No newline at end of file
diff --git a/cppcache/include/geode/DataOutput.hpp b/cppcache/include/geode/DataOutput.hpp
index c95db70..d92cbf6 100644
--- a/cppcache/include/geode/DataOutput.hpp
+++ b/cppcache/include/geode/DataOutput.hpp
@@ -498,7 +498,7 @@ class APACHE_GEODE_EXPORT DataOutput {
static void releaseLock();
// memory m_buffer to encode to.
- std::unique_ptr<uint8_t> m_bytes;
+ std::unique_ptr<uint8_t[]> m_bytes;
// cursor.
uint8_t* m_buf;
// size of m_bytes.
diff --git a/cppcache/include/geode/RegionAttributesFactory.hpp b/cppcache/include/geode/RegionAttributesFactory.hpp
index 357133c..199adff 100644
--- a/cppcache/include/geode/RegionAttributesFactory.hpp
+++ b/cppcache/include/geode/RegionAttributesFactory.hpp
@@ -338,7 +338,7 @@ class APACHE_GEODE_EXPORT RegionAttributesFactory {
* @return a reference to <code>this</code>
* @throws IllegalArgumentException if initialCapacity is negative.
*/
- RegionAttributesFactory& setInitialCapacity(int initialCapacity);
+ RegionAttributesFactory& setInitialCapacity(int32_t initialCapacity);
/**
* Sets the entry load factor for the next <code>RegionAttributes</code>
diff --git a/cppcache/integration-test-2/framework/.clang-tidy b/cppcache/integration-test-2/framework/.clang-tidy
new file mode 100644
index 0000000..07eb839
--- /dev/null
+++ b/cppcache/integration-test-2/framework/.clang-tidy
@@ -0,0 +1,12 @@
+---
+Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-clang-analyzer-unix.cstring.NullArg'
+WarningsAsErrors: '*,-google-default-arguments'
+HeaderFilterRegex: '.*'
+FormatStyle: file
+
+# Disable Checks
+# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule.
+# google-readability-todo - Adds current user name when fix applied.
+
+# TODO - Fix these checks
+# clang-analyzer-unix.cstring.NullArg - Generates errors in Boost, how do we ignore?
diff --git a/cppcache/integration-test/BBNamingContext.cpp b/cppcache/integration-test/BBNamingContext.cpp
index 1c2a2e9..e316385 100644
--- a/cppcache/integration-test/BBNamingContext.cpp
+++ b/cppcache/integration-test/BBNamingContext.cpp
@@ -58,6 +58,7 @@ static int getRandomNum() {
// Whilst this approach is pessimal, it can not be
// remedied as the test depend upon it.
ACE_OS::srand(seed);
+ // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand)
return (ACE_OS::rand() % 49999) + 14000;
}
@@ -191,7 +192,7 @@ int BBNamingContextClientImpl::resolve(const char* key, char* value, char*) {
std::string v = m_bbc->getString(k, k1);
// fprintf(stdout, "resolve: got value %s for key=%s\n", v.c_str(),
// key);fflush(stdout);
- ACE_OS::strcpy(value, v.c_str());
+ ACE_OS::strncpy(value, v.c_str(), sizeof(value));
if (m_errCount > 0) {
m_errCount = 0;
}
diff --git a/cppcache/integration-test/BuiltinCacheableWrappers.hpp b/cppcache/integration-test/BuiltinCacheableWrappers.hpp
index 951b03f..a68f674 100644
--- a/cppcache/integration-test/BuiltinCacheableWrappers.hpp
+++ b/cppcache/integration-test/BuiltinCacheableWrappers.hpp
@@ -23,6 +23,7 @@
#include <limits.h>
#include <cstdlib>
#include <wchar.h>
+#include <random>
#include <ace/Date_Time.h>
@@ -122,9 +123,9 @@ const uint32_t m_crc32Table[] = {
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d};
inline double random(double maxValue) {
- // Random number generator is initialized in registerBuiltins()
- return (maxValue * static_cast<double>(rand())) /
- (static_cast<double>(RAND_MAX) + 1.0);
+ static thread_local std::default_random_engine generator(
+ std::random_device{}());
+ return std::uniform_real_distribution<double>{0.0, maxValue}(generator);
}
template <typename TPRIM>
diff --git a/cppcache/integration-test/CacheHelper.cpp b/cppcache/integration-test/CacheHelper.cpp
index fa71c78..dcb9eca 100644
--- a/cppcache/integration-test/CacheHelper.cpp
+++ b/cppcache/integration-test/CacheHelper.cpp
@@ -1776,9 +1776,7 @@ int CacheHelper::hashcode(char* str) {
}
int CacheHelper::getRandomNumber() {
- // char * testName = ACE_OS::getenv( "TESTNAME" );
-
- // int seed = hashcode(testName);
+ // NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.rand)
return (ACE_OS::rand() % RANDOM_NUMBER_DIVIDER) + RANDOM_NUMBER_OFFSET;
}
diff --git a/cppcache/integration-test/CacheImplHelper.hpp b/cppcache/integration-test/CacheImplHelper.hpp
index 5bb9ad0..e2328cd 100644
--- a/cppcache/integration-test/CacheImplHelper.hpp
+++ b/cppcache/integration-test/CacheImplHelper.hpp
@@ -33,7 +33,7 @@
#define ROOT_SCOPE LOCAL
#endif
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheHelper;
using apache::geode::client::Properties;
diff --git a/cppcache/integration-test/DeltaEx.hpp b/cppcache/integration-test/DeltaEx.hpp
index e2e78ec..931456c 100644
--- a/cppcache/integration-test/DeltaEx.hpp
+++ b/cppcache/integration-test/DeltaEx.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::DataInput;
using apache::geode::client::DataOutput;
diff --git a/cppcache/integration-test/LocatorHelper.hpp b/cppcache/integration-test/LocatorHelper.hpp
index 1fdb80c..441af29 100644
--- a/cppcache/integration-test/LocatorHelper.hpp
+++ b/cppcache/integration-test/LocatorHelper.hpp
@@ -24,7 +24,7 @@
#define SERVER2 s2p2
#endif
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/QueryHelper.hpp b/cppcache/integration-test/QueryHelper.hpp
index d3c9aec..18e3249 100644
--- a/cppcache/integration-test/QueryHelper.hpp
+++ b/cppcache/integration-test/QueryHelper.hpp
@@ -51,7 +51,7 @@
#define ROOT_SCOPE LOCAL
#endif
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableStringArray;
diff --git a/cppcache/integration-test/ThinClientCallbackArg.hpp b/cppcache/integration-test/ThinClientCallbackArg.hpp
index 2dcf7ed..ecf14c0 100644
--- a/cppcache/integration-test/ThinClientCallbackArg.hpp
+++ b/cppcache/integration-test/ThinClientCallbackArg.hpp
@@ -37,7 +37,7 @@
* + callback Argument
*/
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
diff --git a/cppcache/integration-test/ThinClientDistOps.hpp b/cppcache/integration-test/ThinClientDistOps.hpp
index 61d9c22..406d576 100644
--- a/cppcache/integration-test/ThinClientDistOps.hpp
+++ b/cppcache/integration-test/ThinClientDistOps.hpp
@@ -39,7 +39,7 @@
#define CREATE_TWICE_KEY "__create_twice_key"
#define CREATE_TWICE_VALUE "__create_twice_value"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
diff --git a/cppcache/integration-test/ThinClientDistOps2.hpp b/cppcache/integration-test/ThinClientDistOps2.hpp
index 10b2272..e6da087 100644
--- a/cppcache/integration-test/ThinClientDistOps2.hpp
+++ b/cppcache/integration-test/ThinClientDistOps2.hpp
@@ -36,7 +36,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
diff --git a/cppcache/integration-test/ThinClientDurable.hpp b/cppcache/integration-test/ThinClientDurable.hpp
index 226f1ba..2a35737 100644
--- a/cppcache/integration-test/ThinClientDurable.hpp
+++ b/cppcache/integration-test/ThinClientDurable.hpp
@@ -46,7 +46,7 @@ Client 1 is with R =0 and Client 2 with R = 1
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::EntryEvent;
using apache::geode::client::Exception;
diff --git a/cppcache/integration-test/ThinClientDurableFailover.hpp b/cppcache/integration-test/ThinClientDurableFailover.hpp
index d113345..9d169e1 100644
--- a/cppcache/integration-test/ThinClientDurableFailover.hpp
+++ b/cppcache/integration-test/ThinClientDurableFailover.hpp
@@ -45,7 +45,7 @@ Shutdown
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::EntryEvent;
using apache::geode::client::Exception;
diff --git a/cppcache/integration-test/ThinClientDurableInterest.hpp b/cppcache/integration-test/ThinClientDurableInterest.hpp
index 3b7ce70..b3f9b58 100644
--- a/cppcache/integration-test/ThinClientDurableInterest.hpp
+++ b/cppcache/integration-test/ThinClientDurableInterest.hpp
@@ -44,7 +44,7 @@ recieved.
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::EntryEvent;
using apache::geode::client::HashMapOfCacheable;
diff --git a/cppcache/integration-test/ThinClientDurableReconnect.hpp b/cppcache/integration-test/ThinClientDurableReconnect.hpp
index 19b48ea..cba82f6 100644
--- a/cppcache/integration-test/ThinClientDurableReconnect.hpp
+++ b/cppcache/integration-test/ThinClientDurableReconnect.hpp
@@ -38,7 +38,7 @@
#define SERVER1 s2p1
#define FEEDER s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::EntryEvent;
diff --git a/cppcache/integration-test/ThinClientFailover.hpp b/cppcache/integration-test/ThinClientFailover.hpp
index 1eb536e..6256e8e 100644
--- a/cppcache/integration-test/ThinClientFailover.hpp
+++ b/cppcache/integration-test/ThinClientFailover.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailover2.hpp b/cppcache/integration-test/ThinClientFailover2.hpp
index 4f44018..3e84d1c 100644
--- a/cppcache/integration-test/ThinClientFailover2.hpp
+++ b/cppcache/integration-test/ThinClientFailover2.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailover3.hpp b/cppcache/integration-test/ThinClientFailover3.hpp
index a18b4f5..5a553bd 100644
--- a/cppcache/integration-test/ThinClientFailover3.hpp
+++ b/cppcache/integration-test/ThinClientFailover3.hpp
@@ -31,7 +31,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverInterest.hpp b/cppcache/integration-test/ThinClientFailoverInterest.hpp
index f1ec444..6503a65 100644
--- a/cppcache/integration-test/ThinClientFailoverInterest.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterest.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverInterest2.hpp b/cppcache/integration-test/ThinClientFailoverInterest2.hpp
index 9c77052..95d0049 100644
--- a/cppcache/integration-test/ThinClientFailoverInterest2.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterest2.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp b/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
index 6485e18..a7fb8ee 100644
--- a/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
+++ b/cppcache/integration-test/ThinClientFailoverInterestAllWithCache.hpp
@@ -29,7 +29,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientFailoverRegex.hpp b/cppcache/integration-test/ThinClientFailoverRegex.hpp
index 349d37a..7930482 100644
--- a/cppcache/integration-test/ThinClientFailoverRegex.hpp
+++ b/cppcache/integration-test/ThinClientFailoverRegex.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientGatewayTest.hpp b/cppcache/integration-test/ThinClientGatewayTest.hpp
index 3b396bf..9be06a0 100644
--- a/cppcache/integration-test/ThinClientGatewayTest.hpp
+++ b/cppcache/integration-test/ThinClientGatewayTest.hpp
@@ -33,7 +33,7 @@
#include <string>
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::EntryEvent;
using apache::geode::client::RegionEvent;
diff --git a/cppcache/integration-test/ThinClientHelper.hpp b/cppcache/integration-test/ThinClientHelper.hpp
index a4f5f77..56736aa 100644
--- a/cppcache/integration-test/ThinClientHelper.hpp
+++ b/cppcache/integration-test/ThinClientHelper.hpp
@@ -42,7 +42,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/ThinClientInterest3.hpp b/cppcache/integration-test/ThinClientInterest3.hpp
index c9e0e06..ad3c338 100644
--- a/cppcache/integration-test/ThinClientInterest3.hpp
+++ b/cppcache/integration-test/ThinClientInterest3.hpp
@@ -29,7 +29,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
diff --git a/cppcache/integration-test/ThinClientInterest3Cacheless.hpp b/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
index fbe73dd..af6ebef 100644
--- a/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
+++ b/cppcache/integration-test/ThinClientInterest3Cacheless.hpp
@@ -29,7 +29,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::testing::TallyListener;
using apache::geode::client::testing::TallyWriter;
diff --git a/cppcache/integration-test/ThinClientInterestList.hpp b/cppcache/integration-test/ThinClientInterestList.hpp
index 31bf6a1..59a68f8 100644
--- a/cppcache/integration-test/ThinClientInterestList.hpp
+++ b/cppcache/integration-test/ThinClientInterestList.hpp
@@ -33,7 +33,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientInterestList2.hpp b/cppcache/integration-test/ThinClientInterestList2.hpp
index a69ad39..5c665c6 100644
--- a/cppcache/integration-test/ThinClientInterestList2.hpp
+++ b/cppcache/integration-test/ThinClientInterestList2.hpp
@@ -34,7 +34,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientListenerInit.hpp b/cppcache/integration-test/ThinClientListenerInit.hpp
index f2015c8..02f53d1 100644
--- a/cppcache/integration-test/ThinClientListenerInit.hpp
+++ b/cppcache/integration-test/ThinClientListenerInit.hpp
@@ -30,7 +30,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Cacheable;
@@ -74,7 +74,7 @@ class ThinClientTallyLoader : public TallyLoader {
lstrvalue);
rp.put(key, lreturnValue);
}
- return lreturnValue;
+ return std::move(lreturnValue);
}
};
diff --git a/cppcache/integration-test/ThinClientListenerWriter.hpp b/cppcache/integration-test/ThinClientListenerWriter.hpp
index a78262d..8f53c65 100644
--- a/cppcache/integration-test/ThinClientListenerWriter.hpp
+++ b/cppcache/integration-test/ThinClientListenerWriter.hpp
@@ -30,7 +30,7 @@
#define SERVER1 s2p1
#define CLIENT3 s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::EntryEvent;
using apache::geode::client::RegionEvent;
diff --git a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
index 64784ca..44a0c6b 100644
--- a/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
+++ b/cppcache/integration-test/ThinClientLocalCacheLoader.hpp
@@ -28,7 +28,7 @@
#define CLIENT1 s1p1
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Cacheable;
using apache::geode::client::CacheFactory;
@@ -61,7 +61,7 @@ class ThinClientTallyLoader : public TallyLoader {
lstrvalue);
rp.put(key, lreturnValue);
}
- return lreturnValue;
+ return std::move(lreturnValue);
}
void close(Region& region) {
diff --git a/cppcache/integration-test/ThinClientMultipleCaches.hpp b/cppcache/integration-test/ThinClientMultipleCaches.hpp
index 9c614c2..6214eed 100644
--- a/cppcache/integration-test/ThinClientMultipleCaches.hpp
+++ b/cppcache/integration-test/ThinClientMultipleCaches.hpp
@@ -32,7 +32,7 @@
#define CLIENT1 s1p1
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Cache;
using apache::geode::client::CacheFactory;
diff --git a/cppcache/integration-test/ThinClientNotification.hpp b/cppcache/integration-test/ThinClientNotification.hpp
index 951731e..8e66631 100644
--- a/cppcache/integration-test/ThinClientNotification.hpp
+++ b/cppcache/integration-test/ThinClientNotification.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientPdxSerializer.hpp b/cppcache/integration-test/ThinClientPdxSerializer.hpp
index 4cb9311..c5c1970 100644
--- a/cppcache/integration-test/ThinClientPdxSerializer.hpp
+++ b/cppcache/integration-test/ThinClientPdxSerializer.hpp
@@ -39,7 +39,7 @@
#define LOCATOR s2p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableBoolean;
using apache::geode::client::UserObjectSizer;
diff --git a/cppcache/integration-test/ThinClientPdxSerializers.hpp b/cppcache/integration-test/ThinClientPdxSerializers.hpp
index 6ef9614..f8996cd 100644
--- a/cppcache/integration-test/ThinClientPdxSerializers.hpp
+++ b/cppcache/integration-test/ThinClientPdxSerializers.hpp
@@ -20,7 +20,7 @@
#ifndef GEODE_INTEGRATION_TEST_THINCLIENTPDXSERIALIZERS_H_
#define GEODE_INTEGRATION_TEST_THINCLIENTPDXSERIALIZERS_H_
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableArrayList;
using apache::geode::client::CacheableHashMap;
@@ -77,7 +77,7 @@ class TestPdxSerializer : public PdxSerializer {
nonPdxAddress->_aptNumber = pr.readInt("_aptNumber");
nonPdxAddress->_street = pr.readString("_street");
nonPdxAddress->_city = pr.readString("_city");
- return nonPdxAddress;
+ return std::move(nonPdxAddress);
} catch (...) {
return nullptr;
}
@@ -176,7 +176,7 @@ class TestPdxSerializer : public PdxSerializer {
} catch (...) {
return nullptr;
}
- return nonPdxType;
+ return std::move(nonPdxType);
}
bool toDataForAddress(const std::shared_ptr<const void>& testObject,
diff --git a/cppcache/integration-test/ThinClientPutAll.hpp b/cppcache/integration-test/ThinClientPutAll.hpp
index 355d0a5..3ef4f28 100644
--- a/cppcache/integration-test/ThinClientPutAll.hpp
+++ b/cppcache/integration-test/ThinClientPutAll.hpp
@@ -33,7 +33,7 @@
#define ROOT_SCOPE DISTRIBUTED_ACK
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Cache;
using apache::geode::client::CacheableInt32;
diff --git a/cppcache/integration-test/ThinClientPutAllTimeout.hpp b/cppcache/integration-test/ThinClientPutAllTimeout.hpp
index f11520a..fa179ec 100644
--- a/cppcache/integration-test/ThinClientPutAllTimeout.hpp
+++ b/cppcache/integration-test/ThinClientPutAllTimeout.hpp
@@ -29,7 +29,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Exception;
using apache::geode::client::HashMapOfCacheable;
diff --git a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
index 5da3246..47927fc 100644
--- a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
+++ b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
@@ -39,7 +39,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableInt64;
diff --git a/cppcache/integration-test/ThinClientPutGetAll.hpp b/cppcache/integration-test/ThinClientPutGetAll.hpp
index f812b81..0cf950b 100644
--- a/cppcache/integration-test/ThinClientPutGetAll.hpp
+++ b/cppcache/integration-test/ThinClientPutGetAll.hpp
@@ -38,7 +38,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using PdxTests::PdxTypes1;
using PdxTests::PdxTypes10;
diff --git a/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp b/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
index bb31ad1..29d96d1 100644
--- a/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
+++ b/cppcache/integration-test/ThinClientRIwithlocalRegionDestroy.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientRegex.hpp b/cppcache/integration-test/ThinClientRegex.hpp
index 483ed23..0b1818f 100644
--- a/cppcache/integration-test/ThinClientRegex.hpp
+++ b/cppcache/integration-test/ThinClientRegex.hpp
@@ -34,7 +34,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientRegex2.hpp b/cppcache/integration-test/ThinClientRegex2.hpp
index 765ad20..26ccb2e 100644
--- a/cppcache/integration-test/ThinClientRegex2.hpp
+++ b/cppcache/integration-test/ThinClientRegex2.hpp
@@ -34,7 +34,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientRegex3.hpp b/cppcache/integration-test/ThinClientRegex3.hpp
index ddebb2c..5f5f7ac 100644
--- a/cppcache/integration-test/ThinClientRegex3.hpp
+++ b/cppcache/integration-test/ThinClientRegex3.hpp
@@ -33,7 +33,7 @@
#define CLIENT2 s1p2
#define SERVER1 s2p1
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Cacheable;
using apache::geode::client::CacheableInt32;
diff --git a/cppcache/integration-test/ThinClientRemoveAll.hpp b/cppcache/integration-test/ThinClientRemoveAll.hpp
index 026c77c..c8a44dc 100644
--- a/cppcache/integration-test/ThinClientRemoveAll.hpp
+++ b/cppcache/integration-test/ThinClientRemoveAll.hpp
@@ -41,7 +41,7 @@
#define SERVER1 s2p1
#define SERVER2 s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableInt32;
using apache::geode::client::CacheableKey;
diff --git a/cppcache/integration-test/ThinClientSSL.hpp b/cppcache/integration-test/ThinClientSSL.hpp
index a77309d..03dc4db 100644
--- a/cppcache/integration-test/ThinClientSSL.hpp
+++ b/cppcache/integration-test/ThinClientSSL.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientSSLWithPassword.hpp b/cppcache/integration-test/ThinClientSSLWithPassword.hpp
index 6ddf593..2ea392b 100644
--- a/cppcache/integration-test/ThinClientSSLWithPassword.hpp
+++ b/cppcache/integration-test/ThinClientSSLWithPassword.hpp
@@ -30,7 +30,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientSecurity.hpp b/cppcache/integration-test/ThinClientSecurity.hpp
index 2463832..9e77d62 100644
--- a/cppcache/integration-test/ThinClientSecurity.hpp
+++ b/cppcache/integration-test/ThinClientSecurity.hpp
@@ -26,7 +26,7 @@
#include "CacheImplHelper.hpp"
#include "testUtils.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::AuthenticatedView;
diff --git a/cppcache/integration-test/ThinClientSecurityHelper.hpp b/cppcache/integration-test/ThinClientSecurityHelper.hpp
index dfae3de..181e31a 100644
--- a/cppcache/integration-test/ThinClientSecurityHelper.hpp
+++ b/cppcache/integration-test/ThinClientSecurityHelper.hpp
@@ -26,7 +26,7 @@
#include "ThinClientHelper.hpp"
#include "hacks/AceThreadId.h"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableBoolean;
using apache::geode::client::Exception;
@@ -63,7 +63,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/ThinClientTXFailover.hpp b/cppcache/integration-test/ThinClientTXFailover.hpp
index 061f076..babd047 100644
--- a/cppcache/integration-test/ThinClientTXFailover.hpp
+++ b/cppcache/integration-test/ThinClientTXFailover.hpp
@@ -32,7 +32,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientTasks_C2S2.hpp b/cppcache/integration-test/ThinClientTasks_C2S2.hpp
index d3d9ded..a94880d 100644
--- a/cppcache/integration-test/ThinClientTasks_C2S2.hpp
+++ b/cppcache/integration-test/ThinClientTasks_C2S2.hpp
@@ -32,7 +32,7 @@
#define PROCESS3 s2p1
#define PROCESS4 s2p2
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/ThinClientTransactions.hpp b/cppcache/integration-test/ThinClientTransactions.hpp
index ff41477..c770f44 100644
--- a/cppcache/integration-test/ThinClientTransactions.hpp
+++ b/cppcache/integration-test/ThinClientTransactions.hpp
@@ -34,7 +34,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/ThinClientTransactionsXA.hpp b/cppcache/integration-test/ThinClientTransactionsXA.hpp
index 436f55d..bfdda2a 100644
--- a/cppcache/integration-test/ThinClientTransactionsXA.hpp
+++ b/cppcache/integration-test/ThinClientTransactionsXA.hpp
@@ -34,7 +34,7 @@
#include "CacheHelper.hpp"
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheableKey;
using apache::geode::client::CacheableString;
diff --git a/cppcache/integration-test/fw_dunit.cpp b/cppcache/integration-test/fw_dunit.cpp
index 522b68b..804970b 100644
--- a/cppcache/integration-test/fw_dunit.cpp
+++ b/cppcache/integration-test/fw_dunit.cpp
@@ -71,7 +71,6 @@ using apache::geode::client::testframework::BBNamingContextServer;
#define __DUNIT_NO_MAIN__
#include "fw_dunit.hpp"
-
ACE_TCHAR* g_programName = nullptr;
uint32_t g_masterPid = 0;
@@ -102,12 +101,12 @@ void setupCRTOutput() {
#endif
}
-void getTimeStr(char* bufPtr) {
+void getTimeStr(char* bufPtr, size_t sizeOfBuf) {
ACE_TCHAR timestamp[64] = {0}; // only 35 needed here
ACE::timestamp(timestamp, sizeof timestamp);
// timestamp is like "Tue May 17 2005 12:54:22.546780"
// for our purpose we just want "12:54:22.546780"
- strcpy(bufPtr, ×tamp[16]);
+ strncpy(bufPtr, ×tamp[16], sizeOfBuf);
}
// some common values..
@@ -152,7 +151,7 @@ class NamingContextImpl : virtual public NamingContext {
LOGMASTER("Naming context ready.");
}
- virtual ~NamingContextImpl() {
+ ~NamingContextImpl() noexcept override {
m_context.close();
ACE_OS::unlink(ACE_OS::getenv("TESTNAME"));
}
@@ -161,7 +160,7 @@ class NamingContextImpl : virtual public NamingContext {
* Share a string value, return -1 if there is a failure to store value,
* otherwise returns 0.
*/
- virtual int rebind(const char* key, const char* value) {
+ int rebind(const char* key, const char* value) override {
int res = -1;
int attempts = 10;
while ((res = m_context.rebind(key, value, const_cast<char*>(""))) == -1 &&
@@ -175,7 +174,7 @@ class NamingContextImpl : virtual public NamingContext {
* Share an int value, return -1 if there is a failure to store value,
* otherwise returns 0.
*/
- virtual int rebind(const char* key, int value) {
+ int rebind(const char* key, int value) override {
return rebind(key, std::to_string(value).c_str());
}
@@ -183,7 +182,7 @@ class NamingContextImpl : virtual public NamingContext {
* retreive a value by key, storing the result in the users buf. If the key
* is not found, the buf will contain the empty string "".
*/
- virtual void getValue(const char* key, char* buf) {
+ void getValue(const char* key, char* buf, size_t sizeOfBuf) override {
#ifdef SOLARIS_USE_BB
char value[VALUE_MAX] = {0};
char type[VALUE_MAX] = {0};
@@ -201,19 +200,19 @@ class NamingContextImpl : virtual public NamingContext {
}
if (res != 0) {
- strcpy(buf, "");
+ strncpy(buf, "", sizeOfBuf);
return;
}
- ACE_OS::strcpy(buf, value);
+ ACE_OS::strncpy(buf, value, sizeOfBuf);
}
/**
* return the value by key, as an int using the string to int conversion
* rules of atoi.
*/
- virtual int getIntValue(const char* key) {
+ int getIntValue(const char* key) override {
char value[VALUE_MAX] = {0};
- getValue(key, value);
+ getValue(key, value, sizeof(value));
if (ACE_OS::strcmp(value, "") == 0) return 0;
return ACE_OS::atoi(value);
}
@@ -249,7 +248,7 @@ class NamingContextImpl : virtual public NamingContext {
}
/** print out all the entries' keys and values in the naming context. */
- virtual void dump() {
+ void dump() override {
#ifdef SOLARIS_USE_BB
m_context.dump();
#else
@@ -794,7 +793,7 @@ void sleep(int millis) {
void logMaster(std::string s, int lineno, const char* /*filename*/) {
char buf[128] = {0};
- dunit::getTimeStr(buf);
+ dunit::getTimeStr(buf, sizeof(buf));
fprintf(stdout, "[TEST master:pid(%d)] %s at line: %d\n", ACE_OS::getpid(),
s.c_str(), lineno);
@@ -805,7 +804,7 @@ void logMaster(std::string s, int lineno, const char* /*filename*/) {
// slave id.
void log(std::string s, int lineno, const char* /*filename*/, int /*id*/) {
char buf[128] = {0};
- dunit::getTimeStr(buf);
+ dunit::getTimeStr(buf, sizeof(buf));
fprintf(stdout, "[TEST 0:pid(%d)] %s at line: %d\n", ACE_OS::getpid(),
s.c_str(), lineno);
@@ -815,7 +814,7 @@ void log(std::string s, int lineno, const char* /*filename*/, int /*id*/) {
// log a message and print the slave id as well..
void log(std::string s, int lineno, const char* /*filename*/) {
char buf[128] = {0};
- dunit::getTimeStr(buf);
+ dunit::getTimeStr(buf, sizeof(buf));
fprintf(stdout, "[TEST %s %s:pid(%d)] %s at line: %d\n", buf,
(dunit::TestSlave::procSlaveId
@@ -836,7 +835,7 @@ int dmain(int argc, ACE_TCHAR* argv[]) {
// tb->arm(); // leak this on purpose.
try {
g_programName = new ACE_TCHAR[2048];
- ACE_OS::strcpy(g_programName, argv[0]);
+ ACE_OS::strncpy(g_programName, argv[0], 2048);
const ACE_TCHAR options[] = ACE_TEXT("s:m:");
ACE_Get_Opt cmd_opts(argc, argv, options);
@@ -1171,4 +1170,3 @@ void Semaphore::release(int t) {
}
} // namespace perf
-
diff --git a/cppcache/integration-test/fw_dunit.hpp b/cppcache/integration-test/fw_dunit.hpp
index fc75cc9..9378169 100644
--- a/cppcache/integration-test/fw_dunit.hpp
+++ b/cppcache/integration-test/fw_dunit.hpp
@@ -308,7 +308,7 @@ class NamingContext {
* is not found, the buf will contain the empty string "". Make sure the
* buffer is big enough to hold whatever has have bound.
*/
- virtual void getValue(const char* key, char* buf) = 0;
+ virtual void getValue(const char* key, char* buf, size_t sizeOfBuf) = 0;
/**
* return the value by key, as an int using the string to int conversion
@@ -318,6 +318,8 @@ class NamingContext {
/** dump the entire context in LOG messages. */
virtual void dump() = 0;
+
+ virtual ~NamingContext() noexcept = default;
};
extern "C" {
diff --git a/cppcache/integration-test/fw_spawn.hpp b/cppcache/integration-test/fw_spawn.hpp
index 30d630b..0411a63 100644
--- a/cppcache/integration-test/fw_spawn.hpp
+++ b/cppcache/integration-test/fw_spawn.hpp
@@ -45,7 +45,7 @@
class Manager : virtual public ACE_Process {
public:
explicit Manager(const ACE_TCHAR *program_name) : ACE_Process() {
- ACE_OS::strcpy(programName_, program_name);
+ ACE_OS::strncpy(programName_, program_name, sizeof(programName_));
}
virtual int doWork(void) {
diff --git a/cppcache/integration-test/locator_globals.hpp b/cppcache/integration-test/locator_globals.hpp
index ab04511..9d16d29 100644
--- a/cppcache/integration-test/locator_globals.hpp
+++ b/cppcache/integration-test/locator_globals.hpp
@@ -20,7 +20,7 @@
#ifndef GEODE_INTEGRATION_TEST_LOCATOR_GLOBALS_H_
#define GEODE_INTEGRATION_TEST_LOCATOR_GLOBALS_H_
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::CacheHelper;
diff --git a/cppcache/integration-test/testRegionTemplateArgs.cpp b/cppcache/integration-test/testRegionTemplateArgs.cpp
index 0432dc9..fd74369 100644
--- a/cppcache/integration-test/testRegionTemplateArgs.cpp
+++ b/cppcache/integration-test/testRegionTemplateArgs.cpp
@@ -46,7 +46,8 @@ bool CheckBytesEqual(std::shared_ptr<CacheableBytes> result,
// This test checks the template methods of Region API with all possible
// combinations of key and value types.
-BEGIN_TEST(CheckTemplates) // NOLINT
+// NOLINTNEXTLINE(google-readability-function-size)
+BEGIN_TEST(CheckTemplates)
{
auto cacheFactory = CacheFactory();
auto cache = std::make_shared<Cache>(cacheFactory.create());
diff --git a/cppcache/integration-test/testSerialization.cpp b/cppcache/integration-test/testSerialization.cpp
index fd7a25b..8efb9b0 100644
--- a/cppcache/integration-test/testSerialization.cpp
+++ b/cppcache/integration-test/testSerialization.cpp
@@ -111,7 +111,7 @@ class OtherType : public DataSerializable {
printf("double hex 0x%016" PRIX64 "\n", ot->m_struct.e);
- return ot;
+ return std::move(ot);
}
static void validateCT(int32_t i, const std::shared_ptr<Cacheable> otPtr) {
diff --git a/cppcache/integration-test/testSpinLock.cpp b/cppcache/integration-test/testSpinLock.cpp
index 425cd0a..63ba916 100644
--- a/cppcache/integration-test/testSpinLock.cpp
+++ b/cppcache/integration-test/testSpinLock.cpp
@@ -26,7 +26,7 @@
#include <ace/Time_Value.h>
#include <ace/Guard_T.h>
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::util::concurrent::spinlock_mutex;
diff --git a/cppcache/integration-test/testThinClientBigValue.cpp b/cppcache/integration-test/testThinClientBigValue.cpp
index 60a0482..9cab945 100644
--- a/cppcache/integration-test/testThinClientBigValue.cpp
+++ b/cppcache/integration-test/testThinClientBigValue.cpp
@@ -152,7 +152,7 @@ DUNIT_TASK(CLIENT2, VerifyPuts)
{
auto regPtr = getHelper()->getRegion(regionNames[0]);
// region should already have n entries...
- int entriesExpected = dunit::globals()->getIntValue("entriesToExpect");
+ dunit::globals()->getIntValue("entriesToExpect");
for (int i = 0; i <= MAX_PAYLOAD; grow(&i)) {
char keybuf[100];
diff --git a/cppcache/integration-test/testThinClientCacheablesLimits.cpp b/cppcache/integration-test/testThinClientCacheablesLimits.cpp
index 8d0a826..206c0a6 100644
--- a/cppcache/integration-test/testThinClientCacheablesLimits.cpp
+++ b/cppcache/integration-test/testThinClientCacheablesLimits.cpp
@@ -26,7 +26,6 @@
#include <cstring>
-
#include "CacheHelper.hpp"
#include "ThinClientHelper.hpp"
@@ -70,24 +69,32 @@ void createRegion(const char* name, bool ackMode,
ASSERT(regPtr != nullptr, "Failed to create region.");
LOG("Region created.");
}
+
+template <typename T>
+T randomValue(T maxValue) {
+ static thread_local std::default_random_engine generator(
+ std::random_device{}());
+ return std::uniform_int_distribution<T>{0, maxValue}(generator);
+}
+
uint8_t* createRandByteArray(int size) {
uint8_t* ptr = new uint8_t[size];
for (int i = 0; i < size; i++) {
- ptr[i] = (rand()) % 256;
+ ptr[i] = randomValue(255);
}
return ptr;
}
+
char* createRandCharArray(int size) {
char* ch;
ch = static_cast<char*>(std::malloc((size + 1) * sizeof(char)));
if (ch == nullptr) {
- throw OutOfMemoryException(
- "Out of Memory while resizing buffer");
+ throw OutOfMemoryException("Out of Memory while resizing buffer");
}
ch[size] = '\0';
- int length = sizeof(charArray) / sizeof(char);
+ auto length = sizeof(charArray) / sizeof(char);
for (int i = 0; i < size; i++) {
- ch[i] = charArray[(rand()) % (length)];
+ ch[i] = charArray[randomValue(length - 1)];
}
return ch;
}
@@ -112,9 +119,11 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutsTask)
char* ptrChar = createRandCharArray(keyArr[count]);
auto emptyBytesArr = CacheableBytes::create();
- auto bytePtrSent = CacheableBytes::create(std::vector<int8_t>(ptr, ptr + keyArr[count]));
+ auto bytePtrSent =
+ CacheableBytes::create(std::vector<int8_t>(ptr, ptr + keyArr[count]));
auto stringPtrSent =
CacheableString::create(std::string(ptrChar, keyArr[count]));
+ std::free(ptrChar);
verifyReg->put(KEY_BYTE, bytePtrSent);
verifyReg->put(KEY_STRING, stringPtrSent);
@@ -145,9 +154,10 @@ DUNIT_TASK_DEFINITION(CLIENT1, PutsTask)
ASSERT(emptyBytesArrReturn != nullptr,
"Empty Bytes Array ptr is nullptr");
- bool isSameBytes = (bytePtrReturn->length() == bytePtrSent->length() &&
- !memcmp(bytePtrReturn->value().data(), bytePtrSent->value().data(),
- bytePtrReturn->length()));
+ bool isSameBytes =
+ (bytePtrReturn->length() == bytePtrSent->length() &&
+ !memcmp(bytePtrReturn->value().data(), bytePtrSent->value().data(),
+ bytePtrReturn->length()));
bool isSameString =
(stringPtrReturn->length() == stringPtrSent->length() &&
!memcmp(stringPtrReturn->value().c_str(),
diff --git a/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp b/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp
index ad662ad..00bde8f 100644
--- a/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp
+++ b/cppcache/integration-test/testThinClientFixedPartitionResolver.cpp
@@ -195,6 +195,7 @@ std::vector<char*> storeEndPoints(const char* points) {
endpointNames.push_back(token);
token = strtok(nullptr, ",");
}
+ free(ep);
}
ASSERT(endpointNames.size() == 3, "There should be 3 end points");
return endpointNames;
diff --git a/cppcache/integration-test/testThinClientPRSingleHop.cpp b/cppcache/integration-test/testThinClientPRSingleHop.cpp
index 9ee66d5..3105679 100644
--- a/cppcache/integration-test/testThinClientPRSingleHop.cpp
+++ b/cppcache/integration-test/testThinClientPRSingleHop.cpp
@@ -19,6 +19,8 @@
#define ROOT_SCOPE DISTRIBUTED_ACK
#include <string>
+#include <random>
+#include <limits>
#include <ace/OS.h>
#include <ace/High_Res_Timer.h>
@@ -77,7 +79,6 @@ std::string convertHostToCanonicalForm(const char* endpoints) {
endpointsStr = endpointsStr.substr(pos, length);
} else {
hostString = "";
- port = 0;
return "";
}
hostString = endpoint;
@@ -99,6 +100,13 @@ std::string convertHostToCanonicalForm(const char* endpoints) {
return endpoints;
}
+template <typename T>
+T randomValue(T maxValue) {
+ static thread_local std::default_random_engine generator(
+ std::random_device{}());
+ return std::uniform_int_distribution<T>{0, maxValue}(generator);
+}
+
class putThread : public ACE_Task_Base {
private:
std::shared_ptr<Region> regPtr;
@@ -119,11 +127,9 @@ class putThread : public ACE_Task_Base {
int svc(void) {
std::shared_ptr<CacheableKey> keyPtr;
- int rand;
for (int i = m_min; i < m_max; i++) {
if (!m_isWarmUpTask) {
- unsigned int seed = i;
- rand = ACE_OS::rand_r(&seed);
+ auto rand = randomValue(std::numeric_limits<int32_t>::max());
keyPtr = std::dynamic_pointer_cast<CacheableKey>(
CacheableInt32::create(rand));
LOGDEBUG("svc: putting key %d ", rand);
@@ -204,6 +210,7 @@ std::vector<char*> storeEndPoints(const char* points) {
endpointNames.push_back(token);
token = strtok(nullptr, ",");
}
+ free(ep);
}
ASSERT(endpointNames.size() == 3, "There should be 3 end points");
return endpointNames;
@@ -1162,8 +1169,6 @@ DUNIT_MAIN
CALL_TASK(CheckPrSingleHopForIntKeysTask);
size_t totKeyTypes =
CacheableWrapperFactory::getRegisteredKeyTypes().size();
- size_t totValTypes =
- CacheableWrapperFactory::getRegisteredValueTypes().size();
CALL_TASK(CheckPrSingleHopForIntKeysTask);
for (size_t i = 0; i < totKeyTypes; i++) {
diff --git a/cppcache/integration-test/testThinClientPartitionResolver.cpp b/cppcache/integration-test/testThinClientPartitionResolver.cpp
index cff3fd3..40c5278 100644
--- a/cppcache/integration-test/testThinClientPartitionResolver.cpp
+++ b/cppcache/integration-test/testThinClientPartitionResolver.cpp
@@ -78,6 +78,7 @@ std::vector<char *> storeEndPoints(const char *points) {
endpointNames.push_back(token);
token = strtok(nullptr, ",");
}
+ free(ep);
}
ASSERT(endpointNames.size() == 3, "There should be 3 end points");
return endpointNames;
diff --git a/cppcache/integration-test/testThinClientPdxInstance.cpp b/cppcache/integration-test/testThinClientPdxInstance.cpp
index 5efe64a..6b50bcb 100644
--- a/cppcache/integration-test/testThinClientPdxInstance.cpp
+++ b/cppcache/integration-test/testThinClientPdxInstance.cpp
@@ -828,7 +828,6 @@ DUNIT_TASK_DEFINITION(CLIENT2, verifyPdxInstanceEquals)
pIPtr2 = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport1));
LOG("parentPdx get2 Successfully....");
- ret = false;
ret = (*pIPtr1 == *pIPtr2);
LOGINFO("parentPdx ret = %d ", ret);
ASSERT(ret == true, "Both PdxInstances should be equal.");
@@ -1991,14 +1990,13 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstanceAndCheckLocally)
std::vector<bool> setBoolArray{true, false, true, false,
true, true, false, true};
- auto arrayLen = setBoolArray.size();
wpiPtr->setField("m_boolArray", setBoolArray);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
ASSERT(pIPtr->hasField("m_boolArray") == true,
"m_boolArray = true expected");
auto getBoolArray = newPiPtr->getBooleanArrayField("m_boolArray");
- arrayLen = getBoolArray.size();
+ auto arrayLen = getBoolArray.size();
ASSERT(arrayLen == 8, "Arraylength == 8 expected");
ASSERT(genericCompare(setBoolArray, getBoolArray, arrayLen) == true,
"boolArray should be equal");
diff --git a/cppcache/integration-test/testThinClientRemoteQueryRS.cpp b/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
index ac041be..4fc53d0 100644
--- a/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQueryRS.cpp
@@ -204,7 +204,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
if (!qh->verifyRS(results, resultsetRowCountsOPL[i])) {
char failmsg[100] = {0};
ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
- doAnyErrorOccured = true;
ASSERT(false, failmsg);
}
@@ -306,7 +305,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFive)
qh->getPortfolioNumSets()))) {
char failmsg[100] = {0};
ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
- doAnyErrorOccured = true;
ASSERT(false, failmsg);
}
@@ -418,7 +416,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepSix)
qh->getPortfolioNumSets()))) {
char failmsg[100] = {0};
ACE_OS::sprintf(failmsg, "Query verify failed for query index %d", i);
- doAnyErrorOccured = true;
ASSERT(false, failmsg);
}
diff --git a/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp b/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
index 3535d23..1444589 100644
--- a/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
+++ b/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
@@ -251,8 +251,6 @@ END_TASK_DEFINITION
DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
{
- bool doAnyErrorOccured = false;
-
auto region = getHelper()->getRegion(qRegionNames[0]);
for (int i = 0; i < QueryStrings::RQsize(); i++) {
@@ -270,7 +268,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
failmsg,
"FAIL: Query # %d existsValue expected is %s, actual is %s", i,
expectedResult ? "true" : "false", existsValue ? "true" : "false");
- doAnyErrorOccured = true;
ASSERT(false, failmsg);
}
}
@@ -310,13 +307,6 @@ DUNIT_TASK_DEFINITION(CLIENT1, StepFour)
LOG(ex.what());
}
- if (!doAnyErrorOccured) {
- LOG("ALL QUERIES PASSED");
- } else {
- LOG("QUERY ERROR(S) OCCURED");
- FAIL("QUERY ERROR(S) OCCURED");
- }
-
LOG("StepFour complete.");
}
END_TASK_DEFINITION
diff --git a/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp b/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
index 402b133..2458171 100644
--- a/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
+++ b/cppcache/integration-test/testThinClientSSLWithSecurityAuthz.cpp
@@ -62,7 +62,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityAuthentication.cpp b/cppcache/integration-test/testThinClientSecurityAuthentication.cpp
index ac10ed3..2d8591d 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthentication.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthentication.cpp
@@ -40,7 +40,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
index 45fcfe3..2752c4d 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthenticationMU.cpp
@@ -42,7 +42,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp b/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
index 66c5815..e4f89e8 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthenticationSetAuthInitialize.cpp
@@ -40,7 +40,7 @@ std::string getXmlPath() {
ASSERT(path != NULL,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorization.cpp b/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
index 1b1d660..7479243 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorization.cpp
@@ -59,7 +59,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
index 066e6ec..fe00dad 100644
--- a/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityAuthorizationMU.cpp
@@ -70,7 +70,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
index 7afc3d9..c82f9be 100644
--- a/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityCQAuthorizationMU.cpp
@@ -140,7 +140,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityDH.cpp b/cppcache/integration-test/testThinClientSecurityDH.cpp
index 652f615..8bf8620 100644
--- a/cppcache/integration-test/testThinClientSecurityDH.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDH.cpp
@@ -65,7 +65,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityDH_MU.cpp b/cppcache/integration-test/testThinClientSecurityDH_MU.cpp
index 08b5e40..cb8add4 100644
--- a/cppcache/integration-test/testThinClientSecurityDH_MU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDH_MU.cpp
@@ -68,7 +68,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
index 8874401..a58f046 100644
--- a/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
+++ b/cppcache/integration-test/testThinClientSecurityDurableCQAuthorizationMU.cpp
@@ -141,7 +141,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testThinClientWriterException.cpp b/cppcache/integration-test/testThinClientWriterException.cpp
index aa96e3a..8bff02a 100644
--- a/cppcache/integration-test/testThinClientWriterException.cpp
+++ b/cppcache/integration-test/testThinClientWriterException.cpp
@@ -57,7 +57,7 @@ std::string getXmlPath() {
ASSERT(path != nullptr,
"Environment variable TESTSRC for test source directory is not set.");
strncpy(xmlPath, path, strlen(path) - strlen("cppcache"));
- strcat(xmlPath, "xml/Security/");
+ strncat(xmlPath, "xml/Security/", sizeof(xmlPath) - strlen(xmlPath) - 1);
return std::string(xmlPath);
}
diff --git a/cppcache/integration-test/testUtils.hpp b/cppcache/integration-test/testUtils.hpp
index 1139d8f..90d3b58 100644
--- a/cppcache/integration-test/testUtils.hpp
+++ b/cppcache/integration-test/testUtils.hpp
@@ -40,7 +40,7 @@
#include <DistributedSystemImpl.hpp>
#include <CacheImpl.hpp>
-namespace { // NOLINT
+namespace { // NOLINT(google-build-namespaces)
using apache::geode::client::Cache;
using apache::geode::client::CacheableKey;
diff --git a/cppcache/src/AuthenticatedView.cpp b/cppcache/src/AuthenticatedView.cpp
index 571ffd1..27f2973 100644
--- a/cppcache/src/AuthenticatedView.cpp
+++ b/cppcache/src/AuthenticatedView.cpp
@@ -127,7 +127,7 @@ std::shared_ptr<QueryService> AuthenticatedView::getQueryService() {
if (m_remoteQueryService != nullptr) return m_remoteQueryService;
auto prqsPtr = std::make_shared<ProxyRemoteQueryService>(this);
m_remoteQueryService = prqsPtr;
- return prqsPtr;
+ return std::move(prqsPtr);
}
throw IllegalStateException("User cache has been closed.");
}
diff --git a/cppcache/src/CacheXmlParser.cpp b/cppcache/src/CacheXmlParser.cpp
index fdc6a26..1386970 100644
--- a/cppcache/src/CacheXmlParser.cpp
+++ b/cppcache/src/CacheXmlParser.cpp
@@ -78,13 +78,15 @@ extern "C" void startElementSAX2Function(void* ctx, const xmlChar* name,
CacheXmlParser* parser = (CacheXmlParser*)ctx;
if (!parser) {
Log::error("CacheXmlParser::startElementSAX2Function:Parser is nullptr");
+ return;
}
if ((!parser->isCacheXmlException()) &&
(!parser->isIllegalStateException()) &&
(!parser->isAnyOtherException())) {
try {
- auto uname = reinterpret_cast<const char*>(const_cast<unsigned char*>(name));
+ auto uname =
+ reinterpret_cast<const char*>(const_cast<unsigned char*>(name));
if (std::strcmp(uname, parser->CACHE) == 0) {
parser->startCache(ctx, atts);
} else if (strcmp(uname, parser->CLIENT_CACHE) == 0) {
@@ -125,9 +127,8 @@ extern "C" void startElementSAX2Function(void* ctx, const xmlChar* name,
} else if (strcmp(uname, parser->SERVER) == 0) {
parser->startServer(atts);
} else {
- std::string temp(uname);
- std::string s = "XML:Unknown XML element \"" + temp + "\"";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:Unknown XML element \"" +
+ std::string(uname) + "\"");
}
} catch (const CacheXmlException& e) {
parser->setCacheXmlException();
@@ -158,7 +159,8 @@ extern "C" void endElementSAX2Function(void* ctx, const xmlChar* name) {
(!parser->isIllegalStateException()) &&
(!parser->isAnyOtherException())) {
try {
- auto uname = reinterpret_cast<const char*>(const_cast<unsigned char*>(name));
+ auto uname =
+ reinterpret_cast<const char*>(const_cast<unsigned char*>(name));
if (strcmp(uname, parser->CACHE) == 0) {
parser->endCache();
} else if (strcmp(uname, parser->CLIENT_CACHE) == 0) {
@@ -197,9 +199,8 @@ extern "C" void endElementSAX2Function(void* ctx, const xmlChar* name) {
} else if (strcmp(uname, parser->SERVER) == 0) {
// parser->endServer();
} else {
- std::string temp(uname);
- std::string s = "XML:Unknown XML element \"" + temp + "\"";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:Unknown XML element \"" +
+ std::string(uname) + "\"");
}
} catch (CacheXmlException& e) {
parser->setCacheXmlException();
@@ -327,9 +328,7 @@ void CacheXmlParser::parseFile(const char* filename) {
res = xmlSAXUserParseFile(&this->m_saxHandler, this, filename);
if (res == -1) {
- std::string temp(filename);
- std::string tempString = "Xml file " + temp + " not found\n";
- throw CacheXmlException(tempString.c_str());
+ throw CacheXmlException("Xml file " + std::string(filename) + " not found");
}
handleParserErrors(res);
}
@@ -352,22 +351,20 @@ void CacheXmlParser::handleParserErrors(int res) {
res);
Log::error(buf);
- std::string temp =
- "Xml file is not well formed. Error _stack: \n" + this->m_parserMessage;
- throw CacheXmlException(temp.c_str());
+ throw CacheXmlException("Xml file is not well formed. Error _stack: \n" +
+ std::string(this->m_parserMessage));
}
std::string temp = this->getError();
- if (temp == "") {
+ if (temp.empty()) {
Log::info("Xml file parsed successfully");
- } else // well formed, but not according to our specs(dtd errors thrown
- // manually)
- {
+ } else {
+ // well formed, but not according to our specs(dtd errors thrown manually)
if (this->m_flagCacheXmlException) {
- throw CacheXmlException(temp.c_str());
+ throw CacheXmlException(temp);
} else if (this->m_flagIllegalStateException) {
- throw IllegalStateException(temp.c_str());
+ throw IllegalStateException(temp);
} else if (this->m_flagAnyOtherException) {
- throw UnknownException(temp.c_str());
+ throw UnknownException(temp);
}
this->setError("");
}
@@ -430,8 +427,8 @@ void CacheXmlParser::create(Cache* cache) {
DeleteObject<CacheXmlCreation> delCacheCreation(m_cacheCreation);
if (cache == nullptr) {
- std::string s = "XML:No cache specified for performing configuration";
- throw IllegalArgumentException(s.c_str());
+ throw IllegalArgumentException(
+ "XML:No cache specified for performing configuration");
}
if (!m_cacheCreation) {
throw CacheXmlException("XML: Element <cache> was not provided in the xml");
@@ -441,30 +438,24 @@ void CacheXmlParser::create(Cache* cache) {
Log::info("Declarative configuration of cache completed successfully");
}
-void CacheXmlParser::startCache(void*, const xmlChar** attrs) {
- int attrsCount = 0;
- if (attrs != nullptr) {
- const char* attrName;
- const char* attrValue;
- while ((attrName = reinterpret_cast<const char*>(attrs[attrsCount++])) != nullptr) {
- attrValue = reinterpret_cast<const char*>(attrs[attrsCount++]);
- if (attrValue == nullptr) {
- std::string exStr = "XML: No value provided for attribute: ";
- exStr += attrName;
- throw CacheXmlException(exStr.c_str());
+void CacheXmlParser::startCache(void*, const xmlChar** atts) {
+ if (atts) {
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (value.empty()) {
+ throw CacheXmlException("XML: No value provided for attribute: " +
+ name);
}
- if (strcmp(attrName, ENDPOINTS) == 0) {
+
+ if (ENDPOINTS == name) {
if (m_poolFactory) {
- std::vector<std::pair<std::string, int>> endPoints(
- parseEndPoints(attrValue));
- std::vector<std::pair<std::string, int>>::iterator endPoint;
- for (endPoint = endPoints.begin(); endPoint != endPoints.end();
- endPoint++) {
- m_poolFactory->addServer(endPoint->first.c_str(), endPoint->second);
+ for (auto&& endPoint : parseEndPoints(value)) {
+ m_poolFactory->addServer(endPoint.first, endPoint.second);
}
}
- } else if (strcmp(attrName, REDUNDANCY_LEVEL) == 0) {
- m_poolFactory->setSubscriptionRedundancy(atoi(attrValue));
+ } else if (REDUNDANCY_LEVEL == name) {
+ m_poolFactory->setSubscriptionRedundancy(std::stoi(value));
}
}
}
@@ -476,151 +467,154 @@ void CacheXmlParser::startPdx(const xmlChar** atts) {
return;
}
- int attrsCount = 0;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (value.empty()) {
+ throw CacheXmlException("XML: No value provided for attribute: " + name);
+ }
- while (atts[attrsCount] != nullptr) {
- const char* name = reinterpret_cast<const char*>(atts[attrsCount]);
- ++attrsCount;
- const char* value = reinterpret_cast<const char*>(atts[attrsCount]);
- if (strcmp(name, IGNORE_UNREAD_FIELDS) == 0) {
- bool ignorePdxUnreadfields = false;
- if (strcmp("true", value) == 0 || strcmp("TRUE", value) == 0) {
- ignorePdxUnreadfields = true;
- } else if (strcmp("false", value) == 0 || strcmp("FALSE", value) == 0) {
- ignorePdxUnreadfields = false;
+ if (IGNORE_UNREAD_FIELDS == name) {
+ bool flag = false;
+ std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+ if ("false" == value) {
+ flag = false;
+ } else if ("true" == value) {
+ flag = true;
} else {
- std::string temp(value);
- std::string s =
- "XML: " + temp +
- " is not a valid value for the attribute <ignore-unread-fields>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid value for the attribute <ignore-unread-fields>");
}
- m_cacheCreation->setPdxIgnoreUnreadField(ignorePdxUnreadfields);
- } else if (strcmp(name, READ_SERIALIZED) == 0) {
- bool readSerialized = false;
- if (strcmp("true", value) == 0 || strcmp("TRUE", value) == 0) {
- readSerialized = true;
- } else if (strcmp("false", value) == 0 || strcmp("FALSE", value) == 0) {
- readSerialized = false;
+ m_cacheCreation->setPdxIgnoreUnreadField(flag);
+ } else if (READ_SERIALIZED == name) {
+ bool flag = false;
+ std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+ if ("false" == value) {
+ flag = false;
+ } else if ("true" == value) {
+ flag = true;
} else {
- std::string temp(value);
- std::string s =
- "XML: " + temp +
- " is not a valid value for the attribute <ignore-unread-fields>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid value for the attribute <ignore-unread-fields>");
}
- m_cacheCreation->setPdxReadSerialized(readSerialized);
+ m_cacheCreation->setPdxReadSerialized(flag);
} else {
- throw CacheXmlException("XML:Unrecognized pdx attribute");
+ throw CacheXmlException("XML:Unrecognized pdx attribute " + name);
}
- ++attrsCount;
}
}
void CacheXmlParser::endPdx() {}
void CacheXmlParser::startLocator(const xmlChar** atts) {
- int attrsCount = 0;
if (!atts) {
- std::string s =
- "XML:No attributes provided for <locator>. "
- "A locator requires a host and port";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:No attributes provided for <locator>. A locator requires a host "
+ "and port");
}
m_poolFactory = std::static_pointer_cast<PoolFactory>(_stack.top());
- const char* host = nullptr;
- const char* port = nullptr;
+ std::string host;
+ std::string port;
+ int attrsCount = 0;
- while (atts[attrsCount] != nullptr) {
- const char* name = reinterpret_cast<const char*>(atts[attrsCount]);
- ++attrsCount;
- const char* value = reinterpret_cast<const char*>(atts[attrsCount]);
- if (strcmp(name, HOST) == 0) {
- host = value;
- } else if (strcmp(name, PORT) == 0) {
- port = value;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (value.empty()) {
+ throw CacheXmlException("XML: No value provided for attribute: " + name);
+ }
+
+ if (HOST == name) {
+ host = std::move(value);
+ } else if (PORT == name) {
+ port = std::move(value);
} else {
throw CacheXmlException("XML:Unrecognized locator attribute");
}
+
++attrsCount;
}
- if (attrsCount < 4) {
+ if (attrsCount < 2) {
throw CacheXmlException(
"XML:Not enough attributes provided for a <locator> - host and port "
"required");
}
- m_poolFactory->addLocator(host, atoi(port));
+ m_poolFactory->addLocator(host, std::stoi(port));
}
void CacheXmlParser::startServer(const xmlChar** atts) {
- int attrsCount = 0;
if (!atts) {
- std::string s =
+ throw CacheXmlException(
"XML:No attributes provided for <server>. A server requires a host and "
- "port";
- throw CacheXmlException(s.c_str());
+ "port");
}
auto factory = std::static_pointer_cast<PoolFactory>(_stack.top());
- const char* host = nullptr;
- const char* port = nullptr;
+ std::string host;
+ std::string port;
+ int attrsCount = 0;
- while (atts[attrsCount] != nullptr) {
- const char* name = reinterpret_cast<const char*>(atts[attrsCount]);
- ++attrsCount;
- const char* value = reinterpret_cast<const char*>(atts[attrsCount]);
- if (strcmp(name, HOST) == 0) {
- host = value;
- } else if (strcmp(name, PORT) == 0) {
- port = value;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (value.empty()) {
+ throw CacheXmlException("XML: No value provided for attribute: " + name);
+ }
+
+ if (HOST == name) {
+ host = std::move(value);
+ } else if (PORT == name) {
+ port = std::move(value);
} else {
throw CacheXmlException("XML:Unrecognized server attribute");
}
+
++attrsCount;
}
- if (attrsCount < 4) {
+ if (attrsCount < 2) {
throw CacheXmlException(
"XML:Not enough attributes provided for a <server> - host and port "
"required");
}
- factory->addServer(host, atoi(port));
+ factory->addServer(host, std::stoi(port));
}
void CacheXmlParser::startPool(const xmlChar** atts) {
- int attrsCount = 0;
if (!atts) {
- std::string s =
- "XML:No attributes provided for <pool>. "
- "A pool cannot be created without a name";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:No attributes provided for <pool>. A pool cannot be created "
+ "without a name");
}
auto factory =
std::make_shared<PoolFactory>(m_cache->getPoolManager().createFactory());
- const char* poolName = nullptr;
+ std::string poolName;
- while (atts[attrsCount] != nullptr) {
- const char* name = reinterpret_cast<const char*>(atts[attrsCount]);
- ++attrsCount;
- const char* value = reinterpret_cast<const char*>(atts[attrsCount]);
- if (strcmp(name, NAME) == 0) {
- poolName = value;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (value.empty()) {
+ throw CacheXmlException("XML: No value provided for attribute: " + name);
+ }
+
+ if (NAME == name) {
+ poolName = std::move(value);
} else {
- setPoolInfo(factory.get(), name, value);
+ setPoolInfo(factory.get(), name.c_str(), value.c_str());
}
- ++attrsCount;
}
- if (attrsCount < 2) {
- std::string s =
+ if (poolName.empty()) {
+ throw CacheXmlException(
"XML:No attributes provided for a <pool> - at least the name is "
- "required";
- throw CacheXmlException(s.c_str());
+ "required");
}
auto poolxml = std::make_shared<PoolXmlCreation>(poolName, factory);
@@ -704,9 +698,8 @@ void CacheXmlParser::setPoolInfo(PoolFactory* factory, const char* name,
factory->setPRSingleHopEnabled(false);
}
} else {
- std::string s = "XML:Unrecognized pool attribute ";
- s += name;
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:Unrecognized pool attribute " +
+ std::string(name));
}
}
@@ -718,48 +711,37 @@ void CacheXmlParser::setPoolInfo(PoolFactory* factory, const char* name,
void CacheXmlParser::startRegion(const xmlChar** atts, bool isRoot) {
int attrsCount = 0;
if (!atts) {
- std::string s =
- "XML:No attributes provided for <region>. "
- "A region cannot be created without a name";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:No attributes provided for <region>. A region cannot be created "
+ "without a name");
}
- while (atts[attrsCount] != nullptr) ++attrsCount;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount < 2 || attrsCount > 4) {
- std::string s =
- "XML:Incorrect number of attributes provided for a <region>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect number of attributes provided for a <region>");
}
- const char* regionName = nullptr;
- const char* refid = nullptr;
+ std::string regionName;
+ std::string refid;
- for (int i = 0; (atts[i] != nullptr); i++) {
- if (atts[i] != nullptr) {
- const char* name = reinterpret_cast<const char*>(const_cast<xmlChar*>(atts[i]));
- i++;
- if (atts[i] != nullptr) {
- const char* value = reinterpret_cast<const char*>(const_cast<xmlChar*>(atts[i]));
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
- if (std::strcmp(name, "name") == 0) {
- regionName = value;
- } else if (std::strcmp(name, "refid") == 0) {
- refid = value;
- } else {
- std::string temp(name);
- std::string s =
- "XML:<region> does not contain the attribute :" + temp + "";
- throw CacheXmlException(s.c_str());
- }
- }
+ if ("name" == name) {
+ regionName = value;
+ } else if ("refid" == name) {
+ refid = value;
+ } else {
+ throw CacheXmlException("XML:<region> does not contain the attribute :" +
+ name);
}
}
- if (regionName == nullptr || strcmp(regionName, "") == 0) // empty string
- {
- std::string s =
+ if (regionName.empty()) {
+ throw CacheXmlException(
"XML:The attribute name of <region> should be specified and cannot be "
- "empty ";
- throw CacheXmlException(s.c_str());
+ "empty");
}
auto region = std::make_shared<RegionXmlCreation>(regionName, isRoot);
@@ -769,25 +751,17 @@ void CacheXmlParser::startRegion(const xmlChar** atts, bool isRoot) {
_stack.push(region);
- RegionAttributesFactory* regionAttributesFactory = nullptr;
- if (refid == nullptr) {
- regionAttributesFactory = new RegionAttributesFactory();
- } else {
- std::string refidStr(refid);
-
- if (namedRegions.find(refidStr) != namedRegions.end()) {
- regionAttributesFactory =
- new RegionAttributesFactory(namedRegions[refidStr]);
+ RegionAttributesFactory regionAttributesFactory;
+ if (!refid.empty()) {
+ if (namedRegions.find(refid) != namedRegions.end()) {
+ regionAttributesFactory = RegionAttributesFactory(namedRegions[refid]);
} else {
- std::string s =
- "XML:referenced named attribute '" + refidStr + "' does not exist.";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:referenced named attribute '" + refid +
+ "' does not exist.");
}
}
- region->setAttributes(
- regionAttributesFactory->create());
- delete regionAttributesFactory;
+ region->setAttributes(regionAttributesFactory.create());
}
void CacheXmlParser::startSubregion(const xmlChar** atts) {
@@ -804,56 +778,45 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
std::shared_ptr<RegionAttributesFactory> regionAttributesFactory = nullptr;
if (atts) {
int attrsCount = 0;
- while (atts[attrsCount] != nullptr) ++attrsCount;
-
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 24) // Remember to change this when the number changes
{
- std::string s =
- "XML:Number of attributes provided for <region-attributes> are more";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:Number of attributes provided for <region-attributes> are more");
}
- const char* refid = nullptr;
+ std::string refid;
- for (int i = 0; (atts[i] != nullptr); i++) {
- i++;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
- if (atts[i] != nullptr) {
- const char* value = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(value, "") == 0) {
- std::string s =
- "XML:In the <region-attributes> element no "
- "attribute can be set to empty string. It should either have a "
- "value or the attribute should be removed. In the latter case "
- "the default value will be set";
- throw CacheXmlException(s.c_str());
- }
+ if (value.empty()) {
+ throw CacheXmlException(
+ "XML:In the <region-attributes> element attribute " + name +
+ " can be set to empty string. It should either have a "
+ "value or the attribute should be removed. In the latter case "
+ "the default value will be set");
+ }
- const char* prev = reinterpret_cast<const char*>(atts[i - 1]);
- if (strcmp(prev, ID) == 0) {
- auto region =
- std::static_pointer_cast<RegionXmlCreation>(_stack.top());
- region->setAttrId(std::string(value));
- } else if (strcmp(prev, REFID) == 0) {
- refid = value;
- }
+ if (ID == name) {
+ auto region = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
+ region->setAttrId(value);
+ } else if (REFID == name) {
+ refid = std::move(value);
}
}
- if (refid == nullptr) {
+ if (refid.empty()) {
auto region = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
regionAttributesFactory =
std::make_shared<RegionAttributesFactory>(region->getAttributes());
} else {
- std::string refidStr(refid);
-
- if (namedRegions.find(refidStr) != namedRegions.end()) {
- regionAttributesFactory =
- std::make_shared<RegionAttributesFactory>(namedRegions[refidStr]);
+ if (namedRegions.find(refid) != namedRegions.end()) {
+ regionAttributesFactory =
+ std::make_shared<RegionAttributesFactory>(namedRegions[refid]);
} else {
- std::string s =
- "XML:referenced named attribute '" + refidStr + "' does not exist.";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:referenced named attribute '" + refid +
+ "' does not exist.");
}
}
@@ -864,142 +827,97 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
_stack.push(regionAttributesFactory);
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(ID, name) == 0 ||
- strcmp(REFID, name) == 0) {
- i++;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+
+ if (ID == name || REFID == name) {
continue;
- } else if (strcmp(CLIENT_NOTIFICATION_ENABLED, name) == 0) {
- i++;
- auto client_notification_enabled = reinterpret_cast<const char*>(atts[i]);
- if (strcmp("false", client_notification_enabled) == 0 ||
- strcmp("FALSE", client_notification_enabled) == 0) {
- if (m_poolFactory) {
- m_poolFactory->setSubscriptionEnabled(false);
- }
- } else if (strcmp("true", client_notification_enabled) == 0 ||
- strcmp("TRUE", client_notification_enabled) == 0) {
- if (m_poolFactory) {
- m_poolFactory->setSubscriptionEnabled(true);
- }
+ } else if (CLIENT_NOTIFICATION_ENABLED == name) {
+ bool flag = false;
+ std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+ if ("false" == value) {
+ flag = false;
+ } else if ("true" == value) {
+ flag = true;
} else {
- std::string temp(client_notification_enabled);
- std::string s =
- "XML: " + temp +
- " is not a valid name for the attribute <client-notification>\n";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid name for the attribute <client-notification>");
}
- } else if (strcmp(INITIAL_CAPACITY, name) == 0) {
- i++;
- auto initialCapacity = reinterpret_cast<const char*>(atts[i]);
- regionAttributesFactory->setInitialCapacity(atoi(initialCapacity));
- } else if (strcmp(CONCURRENCY_LEVEL, name) == 0) {
- i++;
- auto concurrencyLevel = reinterpret_cast<const char*>(atts[i]);
- regionAttributesFactory->setConcurrencyLevel(atoi(concurrencyLevel));
- } else if (strcmp(LOAD_FACTOR, name) == 0) {
- i++;
- auto loadFactor = reinterpret_cast<const char*>(atts[i]);
- regionAttributesFactory->setLoadFactor(
- static_cast<float>(atof(loadFactor))); // check whether this works
- } else if (strcmp(CACHING_ENABLED, name) == 0) {
+ if (m_poolFactory) {
+ m_poolFactory->setSubscriptionEnabled(flag);
+ }
+ } else if (INITIAL_CAPACITY == name) {
+ regionAttributesFactory->setInitialCapacity(std::stoi(value));
+ } else if (CONCURRENCY_LEVEL == name) {
+ regionAttributesFactory->setConcurrencyLevel(std::stoi(value));
+ } else if (LOAD_FACTOR == name) {
+ regionAttributesFactory->setLoadFactor(std::stof(value));
+ } else if (CACHING_ENABLED == name) {
bool flag = false;
- i++;
- auto cachingEnabled = reinterpret_cast<const char*>(atts[i]);
- if (strcmp("true", cachingEnabled) == 0 ||
- strcmp("TRUE", cachingEnabled) == 0) {
- flag = true;
- } else if (strcmp("false", cachingEnabled) == 0 ||
- strcmp("FALSE", cachingEnabled) == 0) {
+ std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+ if ("false" == value) {
flag = false;
+ } else if ("true" == value) {
+ flag = true;
} else {
- std::string temp(cachingEnabled);
- std::string s =
- "XML: " + temp +
- " is not a valid name for the attribute <caching-enabled>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid name for the attribute <caching-enabled>");
}
- regionAttributesFactory->setCachingEnabled(
- flag); // check whether this works
- } else if (strcmp(LRU_ENTRIES_LIMIT, name) == 0) {
- i++;
- auto lruentriesLimit = reinterpret_cast<const char*>(atts[i]);
- int lruentriesLimitInt = atoi(lruentriesLimit);
- uint32_t temp = static_cast<uint32_t>(lruentriesLimitInt);
- regionAttributesFactory->setLruEntriesLimit(temp);
- } else if (strcmp(DISK_POLICY, name) == 0) {
- i++;
- auto diskPolicy = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(OVERFLOWS, diskPolicy) == 0) {
- regionAttributesFactory->setDiskPolicy(
- apache::geode::client::DiskPolicyType::OVERFLOWS);
- } else if (strcmp(PERSIST, diskPolicy) == 0) {
- throw IllegalStateException(" persistence feature is not supported");
- } else if (strcmp(NONE, diskPolicy) == 0) {
- regionAttributesFactory->setDiskPolicy(
- apache::geode::client::DiskPolicyType::NONE);
+ regionAttributesFactory->setCachingEnabled(flag);
+ } else if (LRU_ENTRIES_LIMIT == name) {
+ regionAttributesFactory->setLruEntriesLimit(std::stoi(value));
+ } else if (DISK_POLICY == name) {
+ auto diskPolicy = apache::geode::client::DiskPolicyType::NONE;
+ if (OVERFLOWS == value) {
+ diskPolicy = apache::geode::client::DiskPolicyType::OVERFLOWS;
+ } else if (PERSIST == value) {
+ throw IllegalStateException("Persistence feature is not supported");
+ } else if (NONE == value) {
+ diskPolicy = apache::geode::client::DiskPolicyType::NONE;
} else {
- std::string temp(diskPolicy);
- std::string s =
- "XML: " + temp +
- " is not a valid name for the attribute <disk-policy>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid name for the attribute <disk-policy>");
}
- } else if (strcmp(ENDPOINTS, name) == 0) {
- i++;
+ regionAttributesFactory->setDiskPolicy(diskPolicy);
+ } else if (ENDPOINTS == name) {
if (m_poolFactory) {
- std::vector<std::pair<std::string, int>> endPoints(
- parseEndPoints(name));
- std::vector<std::pair<std::string, int>>::iterator endPoint;
- for (endPoint = endPoints.begin(); endPoint != endPoints.end();
- endPoint++) {
- m_poolFactory->addServer(endPoint->first.c_str(), endPoint->second);
+ for (auto&& endPoint : parseEndPoints(name)) {
+ m_poolFactory->addServer(endPoint.first, endPoint.second);
}
}
isTCR = true;
- } else if (strcmp(POOL_NAME, name) == 0) {
- i++;
- auto poolName = reinterpret_cast<const char*>(atts[i]);
- regionAttributesFactory->setPoolName(poolName);
+ } else if (POOL_NAME == name) {
+ regionAttributesFactory->setPoolName(value);
isTCR = true;
- } else if (strcmp(CLONING_ENABLED, name) == 0) {
- i++;
+ } else if (CLONING_ENABLED == name) {
bool flag = false;
- auto isClonable = reinterpret_cast<const char*>(atts[i]);
-
- if (strcmp("true", isClonable) == 0 ||
- strcmp("TRUE", isClonable) == 0) {
- flag = true;
- } else if (strcmp("false", isClonable) == 0 ||
- strcmp("FALSE", isClonable) == 0) {
+ std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+ if ("false" == value) {
flag = false;
+ } else if ("true" == value) {
+ flag = true;
} else {
- std::string temp(isClonable);
- std::string s =
- "XML: " + temp +
- " is not a valid value for the attribute <cloning-enabled>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid value for the attribute <cloning-enabled>");
}
-
regionAttributesFactory->setCloningEnabled(flag);
isTCR = true;
- } else if (strcmp(CONCURRENCY_CHECKS_ENABLED, name) == 0) {
+ } else if (CONCURRENCY_CHECKS_ENABLED == name) {
bool flag = false;
- i++;
- auto concurrencyChecksEnabled = reinterpret_cast<const char*>(atts[i]);
- if (strcmp("true", concurrencyChecksEnabled) == 0 ||
- strcmp("TRUE", concurrencyChecksEnabled) == 0) {
- flag = true;
- } else if (strcmp("false", concurrencyChecksEnabled) == 0 ||
- strcmp("FALSE", concurrencyChecksEnabled) == 0) {
+ std::transform(value.begin(), value.end(), value.begin(), ::tolower);
+ if ("false" == value) {
flag = false;
+ } else if ("true" == value) {
+ flag = true;
} else {
- std::string temp(name);
- std::string s = "XML: " + temp +
- " is not a valid value for the attribute "
- "<concurrency-checks-enabled>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML: " + value +
+ " is not a valid value for the attribute "
+ "<concurrency-checks-enabled>");
}
regionAttributesFactory->setConcurrencyChecksEnabled(flag);
}
@@ -1014,7 +932,8 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) {
if (isDistributed && isTCR) {
/* we don't allow DR+TCR at current stage according to sudhir */
- throw CacheXmlException("XML:endpoints cannot be defined for distributed region.\n");
+ throw CacheXmlException(
+ "XML:endpoints cannot be defined for distributed region.\n");
}
}
@@ -1051,74 +970,61 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) {
using apache::geode::internal::chrono::duration::from_string;
if (!atts) {
- std::string s = "XML:No attributes provided for <expiration-attributes> ";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:No attributes provided for <expiration-attributes> ");
}
m_flagExpirationAttribute = true;
- int attrsCount = 0;
- while (atts[attrsCount] != nullptr) ++attrsCount;
+ size_t attrsCount = 0;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
+ throw CacheXmlException(
"XML:Incorrect number of attributes provided for "
- "<expirartion-attributes>";
- throw CacheXmlException(s.c_str());
+ "<expirartion-attributes>");
}
std::string timeOut;
- std::chrono::seconds timeOutSeconds;
ExpirationAction expire = ExpirationAction::INVALID_ACTION;
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(TIMEOUT, name) == 0) {
- i++;
- timeOut = std::string(reinterpret_cast<const char*>(atts[i]));
- if (timeOut.empty()) {
- std::string s =
- "XML:Value for attribute <timeout> needs to be specified";
- throw CacheXmlException(s.c_str());
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (TIMEOUT == name) {
+ if (value.empty()) {
+ throw CacheXmlException(
+ "XML:Value for attribute <timeout> needs to be specified");
}
- timeOutSeconds = from_string<std::chrono::seconds>(timeOut);
- } else if (strcmp(ACTION, name) == 0) {
- i++;
- auto action = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(action, "") == 0)
-
- {
- std::string s =
+ timeOut = value;
+ } else if (ACTION == name) {
+ if (value.empty()) {
+ throw CacheXmlException(
"XML:The attribute <action> of <expiration-attributes> cannot be "
"set to empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default "
- "value "
- "will be set";
- throw CacheXmlException(s.c_str());
- } else if (strcmp(INVALIDATE, action) == 0) {
+ "attribute should be removed. In the latter case the default value "
+ "will be set");
+ } else if (INVALIDATE == value) {
expire = ExpirationAction::INVALIDATE;
- } else if (strcmp(DESTROY, action) == 0) {
+ } else if (DESTROY == value) {
expire = ExpirationAction::DESTROY;
- } else if (strcmp(LOCAL_INVALIDATE, action) == 0) {
+ } else if (LOCAL_INVALIDATE == value) {
expire = ExpirationAction::LOCAL_INVALIDATE;
- } else if (strcmp(LOCAL_DESTROY, action) == 0) {
+ } else if (LOCAL_DESTROY == value) {
expire = ExpirationAction::LOCAL_DESTROY;
} else {
- std::string temp(action);
- std::string s =
- "XML: " + temp + " is not a valid value for the attribute <action>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: " + value +
+ " is not a valid value for the attribute <action>");
}
} else {
- std::string temp(name);
- std::string s =
+ throw CacheXmlException(
"XML:Incorrect attribute name specified in "
"<expiration-attributes>: " +
- temp;
- throw CacheXmlException(s.c_str());
+ value);
}
}
if (timeOut.empty()) {
- std::string s =
+ throw CacheXmlException(
"XML:The attribute <timeout> not specified in "
- "<expiration-attributes>.";
- throw CacheXmlException(s.c_str());
+ "<expiration-attributes>.");
}
+ auto timeOutSeconds = from_string<std::chrono::seconds>(timeOut);
auto expireAttr =
std::make_shared<ExpirationAttributes>(timeOutSeconds, expire);
@@ -1133,78 +1039,47 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) {
void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
int attrsCount = 0;
if (!atts) {
- std::string s = "XML:No attributes provided for <persistence-manager>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:No attributes provided for <persistence-manager>");
}
- while (atts[attrsCount] != nullptr) ++attrsCount;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
+ throw CacheXmlException(
"XML:Incorrect number of attributes provided for "
- "<persistence-manager>";
- throw CacheXmlException(s.c_str());
- }
- char* libraryName = nullptr;
- char* libraryFunctionName = nullptr;
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (std::strcmp(LIBRARY_NAME, name) == 0) {
- i++;
- auto value = reinterpret_cast<const char*>(atts[i]);
- size_t len = strlen(value) + 1;
- libraryName = new char[len];
-
- if (libraryName == nullptr) {
- std::string s = "Memory allocation fails";
- throw CacheXmlException(s.c_str());
- }
- std::strncpy(libraryName, value, len);
-
- if (libraryName == nullptr) {
- std::string s =
- "XML:The attribute <library-name> of <persistence-manager> "
- "cannot "
- "be set to an empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default "
- "value "
- "will be set";
- throw CacheXmlException(s.c_str());
- }
- } else if (std::strcmp(LIBRARY_FUNCTION_NAME, name) == 0) {
- i++;
- auto value = reinterpret_cast<const char*>(atts[i]);
- size_t len = strlen(value) + 1;
- libraryFunctionName = new char[len];
-
- if (libraryFunctionName == nullptr) {
- std::string s = "Memory allocation fails";
- throw CacheXmlException(s.c_str());
- }
+ "<persistence-manager>");
+ }
+ std::string libraryName;
+ std::string libraryFunctionName;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+ if (value.empty()) {
+ throw CacheXmlException("XML:Value for attribute <" + name +
+ "> needs to be specified in the "
+ "<persistence-manager>");
+ }
- std::strncpy(libraryFunctionName, value, len);
- if (libraryFunctionName == nullptr) {
- throw CacheXmlException("XML:Value for the <library-function-name> needs to be provided");
- }
+ if (LIBRARY_NAME == name) {
+ libraryName = std::move(value);
+ } else if (LIBRARY_FUNCTION_NAME == name) {
+ libraryFunctionName = std::move(value);
} else {
- std::string temp(name);
- std::string s =
- "XML:Incorrect attribute name specified in "
- "<persistence-manager>: " +
- temp;
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect attribute name specified in <persistence-manager>: " +
+ value);
}
}
- if (libraryFunctionName == nullptr) {
- std::string s =
- "XML:Library function name not specified in the "
- "<persistence-manager>";
- throw CacheXmlException(s.c_str());
+ if (libraryFunctionName.empty()) {
+ throw CacheXmlException(
+ "XML:Library function name not specified in the <persistence-manager>");
}
try {
- if (managedPersistenceManagerFn != nullptr &&
- strchr(libraryFunctionName, '.') != nullptr) {
+ if (managedPersistenceManagerFn &&
+ libraryFunctionName.find('.') != std::string::npos) {
// this is a managed library
- (*managedPersistenceManagerFn)(libraryName, libraryFunctionName);
+ (*managedPersistenceManagerFn)(libraryName.c_str(),
+ libraryFunctionName.c_str());
} else {
getFactoryFunc(libraryName, libraryFunctionName);
}
@@ -1212,117 +1087,98 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) {
throw CacheXmlException(ex.what());
}
- _stack.push(std::make_shared<std::string>(std::string(libraryName)));
- _stack.push(std::make_shared<std::string>(std::string(libraryFunctionName)));
+ _stack.emplace(std::make_shared<std::string>(std::move(libraryName)));
+ _stack.emplace(std::make_shared<std::string>(std::move(libraryFunctionName)));
}
void CacheXmlParser::startPersistenceProperties(const xmlChar** atts) {
if (!atts) {
- std::string s = "XML:No attributes provided for <property> ";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:No attributes provided for <property>");
}
int attrsCount = 0;
- while (atts[attrsCount] != nullptr) ++attrsCount;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
- "XML:Incorrect number of attributes provided for <property>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect number of attributes provided for <property>");
} else {
if (m_config == nullptr) {
m_config = Properties::create();
}
}
- const char* propName = nullptr;
- const char* propValue = nullptr;
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (std::strcmp("name", name) == 0) {
- i++;
- propName = reinterpret_cast<const char*>(atts[i]);
- if (propName == nullptr || std::strcmp(propName, "") == 0) {
- throw CacheXmlException("XML:Value for attribute <name> needs to be specified in the "
- "<property>");
- }
- } else if (strcmp("value", name) == 0) {
- i++;
- propValue = reinterpret_cast<const char*>(atts[i]);
- if (propValue == nullptr || strcmp(propValue, "") == 0) {
- throw CacheXmlException("XML:Value for attribute <value> needs to be "
- "specified in the <property>");
- }
+ std::string propName;
+ std::string propValue;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+
+ if (value.empty()) {
+ throw CacheXmlException("XML:Value for attribute <" + name +
+ "> needs to be specified in the "
+ "<property>");
+ }
+
+ if ("name" == name) {
+ propName = value;
+ } else if ("value" == name) {
+ propValue = value;
} else {
- std::string temp(name);
- std::string s =
- "XML:Incorrect attribute name specified in <property>: " + temp;
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect attribute name specified in <property>: " + name);
}
}
- if (propName == nullptr || strcmp(propName, "") == 0) {
- std::string s =
- "XML:attribute <name> needs to be specified in the <property>";
- throw CacheXmlException(s.c_str());
+ if (propName.empty()) {
+ throw CacheXmlException(
+ "XML:attribute <name> needs to be specified in the <property>");
}
- if (propValue == nullptr || strcmp(propValue, "") == 0) {
- std::string s =
- "XML:attribute <value> needs to be specified in the <property>";
- throw CacheXmlException(s.c_str());
+ if (propValue.empty()) {
+ throw CacheXmlException(
+ "XML:attribute <value> needs to be specified in the <property>");
}
m_config->insert(propName, propValue);
}
void CacheXmlParser::startCacheLoader(const xmlChar** atts) {
- const char* libraryName = nullptr;
- const char* libraryFunctionName = nullptr;
+ std::string libraryName;
+ std::string libraryFunctionName;
int attrsCount = 0;
if (!atts) {
- std::string s = "XML:No attributes provided for <cache-loader>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:No attributes provided for <cache-loader>");
}
- while (atts[attrsCount] != nullptr) ++attrsCount;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
- "XML:Incorrect number of attributes provided for <cache-loader>";
- throw CacheXmlException(s.c_str());
- }
-
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(LIBRARY_NAME, name) == 0) {
- i++;
- libraryName = reinterpret_cast<const char*>(atts[i]);
- if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
- throw CacheXmlException("XML:The attribute <library-name> of <cache-loader> cannot be "
- "set "
- "to an empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default "
- "value "
- "will be set");
- }
- } else if (strcmp(LIBRARY_FUNCTION_NAME, name) == 0) {
- i++;
- libraryFunctionName = reinterpret_cast<const char*>(atts[i]);
- if (libraryFunctionName == nullptr ||
- strcmp(libraryFunctionName, "") == 0) {
- throw CacheXmlException("XML:Value for the <library-function-name> needs to be provided");
- }
+ throw CacheXmlException(
+ "XML:Incorrect number of attributes provided for <cache-loader>");
+ }
+
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+
+ if (value.empty()) {
+ throw CacheXmlException("XML:Value for attribute <" + name +
+ "> needs to be specified in the "
+ "<cache-loader>");
+ }
+
+ if (LIBRARY_NAME == name) {
+ libraryName = std::move(value);
+ } else if (LIBRARY_FUNCTION_NAME == name) {
+ libraryFunctionName = std::move(value);
} else {
- std::string temp(name);
- std::string s =
- "XML:Incorrect attribute name specified in <cache-loader> : " + temp;
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect attribute name specified in <cache-loader> : " + name);
}
}
- if (libraryFunctionName == nullptr || strcmp(libraryFunctionName, "") == 0) {
- std::string s =
- "XML:<library-function-name> not specified in <cache-loader> ";
- throw CacheXmlException(s.c_str());
+ if (libraryFunctionName.empty()) {
+ throw CacheXmlException(
+ "XML:<library-function-name> not specified in <cache-loader>");
}
try {
- if (managedCacheLoaderFn != nullptr &&
- strchr(libraryFunctionName, '.') != nullptr) {
+ if (managedCacheLoaderFn &&
+ libraryFunctionName.find('.') != std::string::npos) {
// this is a managed library
- (*managedCacheLoaderFn)(libraryName, libraryFunctionName);
+ (*managedCacheLoaderFn)(libraryName.c_str(), libraryFunctionName.c_str());
} else {
getFactoryFunc(libraryName, libraryFunctionName);
}
@@ -1336,57 +1192,49 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) {
}
void CacheXmlParser::startCacheListener(const xmlChar** atts) {
- const char* libraryName = nullptr;
- const char* libraryFunctionName = nullptr;
+ std::string libraryName;
+ std::string libraryFunctionName;
int attrsCount = 0;
if (!atts) {
- std::string s = "XML:No attributes provided for <cache-listener> ";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:No attributes provided for <cache-listener>");
}
- while (atts[attrsCount] != nullptr) ++attrsCount;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
- "XML:Incorrect number of attributes provided for <cache-listener>";
- throw CacheXmlException(s.c_str());
- }
-
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(LIBRARY_NAME, name) == 0) {
- i++;
- libraryName = reinterpret_cast<const char*>(atts[i]);
- if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
- throw CacheXmlException("XML:The attribute <library-name> of the <cache-listener> tag "
- "cannot be set to an empty string. It should either have a value "
- "or the attribute should be removed. In the latter case the "
- "default value will be set");
- }
- } else if (strcmp(LIBRARY_FUNCTION_NAME, name) == 0) {
- i++;
- libraryFunctionName = reinterpret_cast<const char*>(atts[i]);
- if (libraryFunctionName == nullptr ||
- strcmp(libraryFunctionName, "") == 0) {
- throw CacheXmlException("XML:Value for <library-function-name> needs to be provided");
- }
+ throw CacheXmlException(
+ "XML:Incorrect number of attributes provided for <cache-listener>");
+ }
+
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+
+ if (value.empty()) {
+ throw CacheXmlException("XML:Value for attribute <" + name +
+ "> needs to be specified in the "
+ "<cache-listener>");
+ }
+
+ if (LIBRARY_NAME == name) {
+ libraryName = std::move(value);
+ } else if (LIBRARY_FUNCTION_NAME == name) {
+ libraryFunctionName = std::move(value);
} else {
- std::string temp(name);
- std::string s =
+ throw CacheXmlException(
"XML:Incorrect attribute name specified in <cache-listener> : " +
- temp;
- throw CacheXmlException(s.c_str());
+ name);
}
}
- if (libraryFunctionName == nullptr || strcmp(libraryFunctionName, "") == 0) {
- std::string s =
- "XML:Library function name not specified in <cache-listener> ";
- throw CacheXmlException(s.c_str());
+ if (libraryFunctionName.empty()) {
+ throw CacheXmlException(
+ "XML:Library function name not specified in <cache-listener>");
}
try {
- if (managedCacheListenerFn != nullptr &&
- strchr(libraryFunctionName, '.') != nullptr) {
+ if (managedCacheListenerFn &&
+ libraryFunctionName.find('.') != std::string::npos) {
// this is a managed library
- (*managedCacheListenerFn)(libraryName, libraryFunctionName);
+ (*managedCacheListenerFn)(libraryName.c_str(),
+ libraryFunctionName.c_str());
} else {
getFactoryFunc(libraryName, libraryFunctionName);
}
@@ -1400,58 +1248,52 @@ void CacheXmlParser::startCacheListener(const xmlChar** atts) {
}
void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
- const char* libraryName = nullptr;
- const char* libraryFunctionName = nullptr;
- int attrsCount = 0;
if (!atts) {
- std::string s = "XML:No attributes provided for <partition-resolver> ";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:No attributes provided for <partition-resolver> ");
}
- while (atts[attrsCount] != nullptr) ++attrsCount;
+
+ int attrsCount = 0;
+ while (atts[attrsCount]) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
+ throw CacheXmlException(
"XML:Incorrect number of attributes provided for "
- "<partition-resolver>";
- throw CacheXmlException(s.c_str());
- }
-
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(LIBRARY_NAME, name) == 0) {
- i++;
- libraryName = reinterpret_cast<const char*>(atts[i]);
- if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
- throw CacheXmlException("XML:The attribute <library-name> of the <partition-resolver> "
- "tag "
- "cannot be set to an empty string. It should either have a value "
- "or the attribute should be removed. In the latter case the "
- "default value will be set");
- }
- } else if (strcmp(LIBRARY_FUNCTION_NAME, name) == 0) {
- i++;
- libraryFunctionName = reinterpret_cast<const char*>(atts[i]);
- if (libraryFunctionName == nullptr ||
- strcmp(libraryFunctionName, "") == 0) {
- throw CacheXmlException("XML:Value for <library-function-name> needs to be provided");
- }
+ "<partition-resolver>");
+ }
+
+ std::string libraryName;
+ std::string libraryFunctionName;
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+
+ if (value.empty()) {
+ throw CacheXmlException("XML:Value for attribute <" + name +
+ "> needs to be specified in the "
+ "<cache-listener>");
+ }
+
+ if (LIBRARY_NAME == name) {
+ libraryName = std::move(value);
+ } else if (LIBRARY_FUNCTION_NAME == name) {
+ libraryFunctionName = std::move(value);
} else {
- std::string temp(name);
- std::string s =
- "XML:Incorrect attribute name specified in <partition-resolver> "
- ": " +
- temp;
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect attribute name specified in <partition-resolver>: " +
+ value);
}
}
- if (libraryFunctionName == nullptr || strcmp(libraryFunctionName, "") == 0) {
- throw CacheXmlException("XML:Library function name not specified in <partition-resolver> ");
+ if (libraryFunctionName.empty()) {
+ throw CacheXmlException(
+ "XML:Library function name not specified in <partition-resolver> ");
}
try {
if (managedPartitionResolverFn != nullptr &&
- strchr(libraryFunctionName, '.') != nullptr) {
+ libraryFunctionName.find('.') != std::string::npos) {
// this is a managed library
- (*managedPartitionResolverFn)(libraryName, libraryFunctionName);
+ (*managedPartitionResolverFn)(libraryName.c_str(),
+ libraryFunctionName.c_str());
} else {
getFactoryFunc(libraryName, libraryFunctionName);
}
@@ -1466,56 +1308,48 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) {
}
void CacheXmlParser::startCacheWriter(const xmlChar** atts) {
- const char* libraryName = nullptr;
- const char* libraryFunctionName = nullptr;
- int attrsCount = 0;
if (!atts) {
- std::string s = "XML:No attributes provided for <cache-writer>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("XML:No attributes provided for <cache-writer>");
}
+
+ int attrsCount = 0;
while (atts[attrsCount] != nullptr) ++attrsCount;
if (attrsCount > 4) {
- std::string s =
- "XML:Incorrect number of attributes provided for <cache-writer>";
- throw CacheXmlException(s.c_str());
- }
-
- for (int i = 0; (atts[i] != nullptr); i++) {
- auto name = reinterpret_cast<const char*>(atts[i]);
- if (strcmp(LIBRARY_NAME, name) == 0) {
- i++;
- libraryName = reinterpret_cast<const char*>(atts[i]);
- if (libraryName == nullptr || strcmp(libraryName, "") == 0) {
- throw CacheXmlException("XML:The attribute <library-name> of <cache-writer> cannot be "
- "set "
- "to an empty string. It should either have a value or the "
- "attribute should be removed. In the latter case the default "
- "value "
- "will be set");
- }
- } else if (strcmp(LIBRARY_FUNCTION_NAME, name) == 0) {
- i++;
- libraryFunctionName = reinterpret_cast<const char*>(atts[i]);
- if (libraryFunctionName == nullptr ||
- strcmp(libraryFunctionName, "") == 0) {
- throw CacheXmlException("XML:Value for the <library-function-name> needs to be provided");
- }
+ throw CacheXmlException(
+ "XML:Incorrect number of attributes provided for <cache-writer>");
+ }
+
+ std::string libraryName;
+ std::string libraryFunctionName;
+
+ for (size_t i = 0; atts[i] && atts[i + 1]; i += 2) {
+ auto name = std::string(reinterpret_cast<const char*>(atts[i]));
+ auto value = std::string(reinterpret_cast<const char*>(atts[i + 1]));
+
+ if (value.empty()) {
+ throw CacheXmlException("XML:Value for attribute <" + name +
+ "> needs to be specified in the <cache-writer>");
+ }
+
+ if (LIBRARY_NAME == name) {
+ libraryName = std::move(value);
+ } else if (LIBRARY_FUNCTION_NAME == name) {
+ libraryFunctionName = std::move(value);
} else {
- std::string temp(name);
- std::string s =
- "XML:Incorrect attribute name specified in <cache-writer>: " + temp;
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML:Incorrect attribute name specified in <cache-writer>: " + value);
}
}
- if (strcmp(libraryFunctionName, "") == 0) {
- throw CacheXmlException("XML:Library function name not specified in the <cache-writer>");
+ if (libraryFunctionName.empty()) {
+ throw CacheXmlException(
+ "XML:Library function name not specified in the <cache-writer>");
}
try {
- if (managedCacheWriterFn != nullptr &&
- strchr(libraryFunctionName, '.') != nullptr) {
+ if (managedCacheWriterFn &&
+ libraryFunctionName.find('.') != std::string::npos) {
// this is a managed library
- (*managedCacheWriterFn)(libraryName, libraryFunctionName);
+ (*managedCacheWriterFn)(libraryName.c_str(), libraryFunctionName.c_str());
} else {
getFactoryFunc(libraryName, libraryFunctionName);
}
@@ -1538,8 +1372,7 @@ void CacheXmlParser::endRegion(bool isRoot) {
_stack.pop();
if (isRoot) {
if (!_stack.empty()) {
- std::string s = "Xml file has incorrectly nested region tags";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("Xml file has incorrectly nested region tags");
}
if (!m_cacheCreation) {
throw CacheXmlException(
@@ -1549,8 +1382,7 @@ void CacheXmlParser::endRegion(bool isRoot) {
m_cacheCreation->addRootRegion(regionPtr);
} else {
if (_stack.empty()) {
- std::string s = "Xml file has incorrectly nested region tags";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException("Xml file has incorrectly nested region tags");
}
auto parent = std::static_pointer_cast<RegionXmlCreation>(_stack.top());
parent->addSubregion(regionPtr);
@@ -1574,10 +1406,9 @@ void CacheXmlParser::endCache() {}
*/
void CacheXmlParser::endRegionTimeToLive() {
if (!m_flagExpirationAttribute) {
- std::string s =
+ throw CacheXmlException(
"XML: <region-time-to-live> cannot be without a "
- "<expiration-attributes>";
- throw CacheXmlException(s.c_str());
+ "<expiration-attributes>");
}
auto expireAttr =
@@ -1599,9 +1430,8 @@ void CacheXmlParser::endRegionTimeToLive() {
*/
void CacheXmlParser::endRegionIdleTime() {
if (!m_flagExpirationAttribute) {
- std::string s =
- "XML: <region-idle-time> cannot be without <expiration-attributes>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: <region-idle-time> cannot be without <expiration-attributes>");
}
auto expireAttr =
std::static_pointer_cast<ExpirationAttributes>(_stack.top());
@@ -1622,10 +1452,8 @@ void CacheXmlParser::endRegionIdleTime() {
*/
void CacheXmlParser::endEntryTimeToLive() {
if (!m_flagExpirationAttribute) {
- std::string s =
- "XML: <entry-time-to-live> cannot be without "
- "<expiration-attributes>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: <entry-time-to-live> cannot be without <expiration-attributes>");
}
auto expireAttr =
std::static_pointer_cast<ExpirationAttributes>(_stack.top());
@@ -1646,9 +1474,8 @@ void CacheXmlParser::endEntryTimeToLive() {
*/
void CacheXmlParser::endEntryIdleTime() {
if (!m_flagExpirationAttribute) {
- std::string s =
- "XML: <entry-idle-time> cannot be without <expiration-attributes>";
- throw CacheXmlException(s.c_str());
+ throw CacheXmlException(
+ "XML: <entry-idle-time> cannot be without <expiration-attributes>");
}
auto expireAttr =
std::static_pointer_cast<ExpirationAttributes>(_stack.top());
diff --git a/cppcache/src/ClientMetadataService.cpp b/cppcache/src/ClientMetadataService.cpp
index 6965772..6a4556b 100644
--- a/cppcache/src/ClientMetadataService.cpp
+++ b/cppcache/src/ClientMetadataService.cpp
@@ -29,9 +29,10 @@
namespace apache {
namespace geode {
namespace client {
+
const char* ClientMetadataService::NC_CMDSvcThread = "NC CMDSvcThread";
+
ClientMetadataService::~ClientMetadataService() {
- delete m_regionQueue;
if (m_bucketWaitTimeout > std::chrono::milliseconds::zero()) {
try {
std::map<std::string, PRbuckets*>::iterator bi;
@@ -46,14 +47,13 @@ ClientMetadataService::~ClientMetadataService() {
}
ClientMetadataService::ClientMetadataService(Pool* pool)
- : m_run(false)
+ : m_run(false),
+ m_pool(pool),
+ m_regionQueue(false)
{
- m_regionQueue = new Queue<std::string>(false);
- m_pool = pool;
-
- ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
- CacheImpl* cacheImpl = tcrdm->getConnectionManager().getCacheImpl();
+ auto tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
+ auto cacheImpl = tcrdm->getConnectionManager().getCacheImpl();
m_bucketWaitTimeout = cacheImpl->getDistributedSystem()
.getSystemProperties()
.bucketWaitTimeout();
@@ -64,22 +64,21 @@ int ClientMetadataService::svc() {
LOGINFO("ClientMetadataService started for pool " + m_pool->getName());
while (m_run) {
m_regionQueueSema.acquire();
- ThinClientPoolDM* tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
- CacheImpl* cache = tcrdm->getConnectionManager().getCacheImpl();
+ auto tcrdm = dynamic_cast<ThinClientPoolDM*>(m_pool);
+ auto&& cache = tcrdm->getConnectionManager().getCacheImpl();
while (true) {
- std::string* regionFullPath = m_regionQueue->get();
+ auto&& regionFullPath = m_regionQueue.get();
- if (regionFullPath != nullptr && regionFullPath->c_str() != nullptr) {
+ if (regionFullPath) {
while (true) {
- if (m_regionQueue->size() > 0) {
- std::string* nextRegionFullPath = m_regionQueue->get();
+ if (m_regionQueue.size() > 0) {
+ auto&& nextRegionFullPath = m_regionQueue.get();
if (nextRegionFullPath != nullptr &&
nextRegionFullPath->c_str() != nullptr &&
regionFullPath->compare(nextRegionFullPath->c_str()) == 0) {
- delete nextRegionFullPath; // we are going for same
} else {
// different region; put it back
- m_regionQueue->put(nextRegionFullPath);
+ m_regionQueue.put(nextRegionFullPath);
break;
}
} else {
@@ -88,14 +87,9 @@ int ClientMetadataService::svc() {
}
}
- if (!cache->isCacheDestroyPending() && regionFullPath != nullptr &&
- regionFullPath->c_str() != nullptr) {
+ if (!cache->isCacheDestroyPending() && regionFullPath) {
getClientPRMetadata(regionFullPath->c_str());
- delete regionFullPath;
- regionFullPath = nullptr;
} else {
- delete regionFullPath;
- regionFullPath = nullptr;
break;
}
}
@@ -329,8 +323,8 @@ void ClientMetadataService::enqueueForMetadataRefresh(
LOGFINE("Network hop so fetching single hop metadata from the server");
cache->setNetworkHopFlag(true);
tcrRegion->setMetaDataRefreshed(true);
- std::string* tempRegionPath = new std::string(regionFullPath);
- m_regionQueue->put(tempRegionPath);
+ auto tempRegionPath = std::make_shared<std::string>(regionFullPath);
+ m_regionQueue.put(tempRegionPath);
m_regionQueueSema.release();
}
}
@@ -665,7 +659,7 @@ ClientMetadataService::pruneNodes(
"ClientMetadataService::pruneNodes Total size of serverToBucketsMap = "
"%d ",
size);
- for (size_t idx = 0; idx < (rand() % size); idx++) {
+ for (size_t idx = 0; idx < RandGen{}(size); idx++) {
itrRes++;
}
randomFirstServer = itrRes->first;
diff --git a/cppcache/src/ClientMetadataService.hpp b/cppcache/src/ClientMetadataService.hpp
index cb85c18..88cbce2 100644
--- a/cppcache/src/ClientMetadataService.hpp
+++ b/cppcache/src/ClientMetadataService.hpp
@@ -211,7 +211,8 @@ class ClientMetadataService : public ACE_Task_Base,
std::shared_ptr<ClientMetadata> SendClientPRMetadata(
const char* regionPath, std::shared_ptr<ClientMetadata> cptr);
- std::shared_ptr<ClientMetadata> getClientMetadata(const std::shared_ptr<Region>& region);
+ std::shared_ptr<ClientMetadata> getClientMetadata(
+ const std::shared_ptr<Region>& region);
private:
// ACE_Recursive_Thread_Mutex m_regionMetadataLock;
@@ -221,7 +222,7 @@ class ClientMetadataService : public ACE_Task_Base,
RegionMetadataMapType m_regionMetaDataMap;
volatile bool m_run;
Pool* m_pool;
- Queue<std::string>* m_regionQueue;
+ Queue<std::shared_ptr<std::string>> m_regionQueue;
ACE_RW_Thread_Mutex m_PRbucketStatusLock;
std::map<std::string, PRbuckets*> m_bucketStatus;
diff --git a/cppcache/src/CqService.cpp b/cppcache/src/CqService.cpp
index 2d113d1..fc380e7 100644
--- a/cppcache/src/CqService.cpp
+++ b/cppcache/src/CqService.cpp
@@ -136,7 +136,7 @@ std::shared_ptr<CqQuery> CqService::newCq(
shared_from_this(), cqName, queryString, cqAttributes,
m_statisticsFactory, isDurable, ua);
cQuery->initCq();
- return cQuery;
+ return std::move(cQuery);
}
/**
diff --git a/cppcache/src/ExpiryTaskManager.cpp b/cppcache/src/ExpiryTaskManager.cpp
index 336abd9..79414c0 100644
--- a/cppcache/src/ExpiryTaskManager.cpp
+++ b/cppcache/src/ExpiryTaskManager.cpp
@@ -38,16 +38,17 @@ namespace client {
const char* ExpiryTaskManager::NC_ETM_Thread = "NC ETM Thread";
ExpiryTaskManager::ExpiryTaskManager() : m_reactorEventLoopRunning(false) {
+ auto timer = std::unique_ptr<GF_Timer_Heap_ImmediateReset>(new GF_Timer_Heap_ImmediateReset());
#if defined(_WIN32)
- m_reactor = new ACE_Reactor(
- new ACE_WFMO_Reactor(nullptr, new GF_Timer_Heap_ImmediateReset()), 1);
+ m_reactor = new ACE_Reactor(new ACE_WFMO_Reactor(nullptr, timer.get()), 1);
#elif defined(WITH_ACE_Select_Reactor)
m_reactor = new ACE_Reactor(
- new ACE_Select_Reactor(nullptr, new GF_Timer_Heap_ImmediateReset()), 1);
+ new ACE_Select_Reactor(nullptr, timer.get()), 1);
#else
m_reactor = new ACE_Reactor(
- new ACE_Dev_Poll_Reactor(nullptr, new GF_Timer_Heap_ImmediateReset()), 1);
+ new ACE_Dev_Poll_Reactor(nullptr, timer.get()) 1);
#endif
+ timer.release();
}
ExpiryTaskManager::id_type ExpiryTaskManager::scheduleExpiryTask(
diff --git a/cppcache/src/FarSideEntryOp.cpp b/cppcache/src/FarSideEntryOp.cpp
index 05e15b5..138d922 100644
--- a/cppcache/src/FarSideEntryOp.cpp
+++ b/cppcache/src/FarSideEntryOp.cpp
@@ -55,12 +55,10 @@ void FarSideEntryOp::fromData(DataInput& input, bool largeModCount,
m_modSerialNum = input.read();
}
- if (input.read() != static_cast<int8_t>(DSCode::NullObj)) {
- input.rewindCursor(1);
- input.readObject(m_callbackArg);
- }
+ m_callbackArg = input.readObject();
skipFilterRoutingInfo(input);
+
m_versionTag =
TcrMessage::readVersionTagPart(input, memId, m_memberListForVersionStamp);
// std::shared_ptr<Serializable> sPtr;
@@ -122,47 +120,34 @@ void FarSideEntryOp::skipFilterRoutingInfo(DataInput& input) {
return;
} else if (structType == DSCode::DataSerializable) {
input.read(); // ignore classbyte
- input.readObject(tmp);
+ input.readObject(); // ignore object
int32_t size = input.readInt32();
for (int i = 0; i < size; i++) {
+ // ignore ClientProxyMembershipID
ClientProxyMembershipID memId;
- // memId.fromData(input);
memId.readEssentialData(input);
- int32_t len = input.readArrayLength();
-
+ // Ignore filter info
if (input.readBoolean()) {
- len = input.readArrayLength();
+ auto len = input.readArrayLength();
for (int j = 0; j < len; j++) {
input.readUnsignedVL();
input.readUnsignedVL();
}
}
- len = input.readInt32();
+ // ignore interestedClients
+ auto len = input.readInt32();
if (len != -1) {
const auto isLong = input.readBoolean();
-
- for (int j = 0; j < len; j++) {
- if (isLong) {
- input.readInt64();
- } else {
- input.readInt32();
- }
- }
+ input.advanceCursor(len * (isLong ? sizeof(int64_t) : sizeof(int32_t)));
}
+ // ignore interestedClientsInv
len = input.readInt32();
if (len != -1) {
const auto isLong = input.readBoolean();
-
- for (int j = 0; j < len; j++) {
- if (isLong) {
- input.readInt64();
- } else {
- input.readInt32();
- }
- }
+ input.advanceCursor(len * (isLong ? sizeof(int64_t) : sizeof(int32_t)));
}
}
} else {
diff --git a/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp b/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
index 9167e6e..cdfe8a3 100644
--- a/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
+++ b/cppcache/src/InternalCacheTransactionManager2PCImpl.cpp
@@ -40,16 +40,17 @@ InternalCacheTransactionManager2PCImpl::
void InternalCacheTransactionManager2PCImpl::prepare() {
try {
- TSSTXStateWrapper* txStateWrapper = TSSTXStateWrapper::s_geodeTSSTXState;
- TXState* txState = txStateWrapper->getTXState();
+ auto& txStateWrapper = TSSTXStateWrapper::s_geodeTSSTXState;
+ auto txState = txStateWrapper->getTXState();
- if (txState == nullptr) {
+ if (!txState) {
GfErrTypeThrowException(
"Transaction is null, cannot prepare of a null transaction",
GF_CACHE_ILLEGAL_STATE_EXCEPTION);
+ return; // never called
}
- ThinClientPoolDM* tcr_dm = getDM();
+ auto tcr_dm = getDM();
// This is for the case when no cache operation/s is performed between
// tx->begin() and tx->commit()/rollback(),
// simply return without sending COMMIT message to server. tcr_dm is nullptr
@@ -116,23 +117,23 @@ void InternalCacheTransactionManager2PCImpl::rollback() {
void InternalCacheTransactionManager2PCImpl::afterCompletion(int32_t status) {
try {
- TSSTXStateWrapper* txStateWrapper = TSSTXStateWrapper::s_geodeTSSTXState;
- TXState* txState = txStateWrapper->getTXState();
+ auto txState = TSSTXStateWrapper::s_geodeTSSTXState->getTXState();
- if (txState == nullptr) {
+ if (!txState) {
GfErrTypeThrowException(
"Transaction is null, cannot commit a null transaction",
GF_CACHE_ILLEGAL_STATE_EXCEPTION);
+ return; // never called
}
- ThinClientPoolDM* tcr_dm = getDM();
+ auto tcr_dm = getDM();
// This is for the case when no cache operation/s is performed between
// tx->begin() and tx->commit()/rollback(),
// simply return without sending COMMIT message to server. tcr_dm is nullptr
// implies no cache operation is performed.
// Theres no need to call txCleaner.clean(); here, because TXCleaner
// destructor is called which cleans ThreadLocal.
- if (tcr_dm == nullptr) {
+ if (!tcr_dm) {
return;
}
diff --git a/cppcache/src/LocalRegion.cpp b/cppcache/src/LocalRegion.cpp
index 9b88901..b55611d 100644
--- a/cppcache/src/LocalRegion.cpp
+++ b/cppcache/src/LocalRegion.cpp
@@ -967,8 +967,6 @@ GfErrType LocalRegion::getNoThrow(
value = oldValue;
}
}
- // signal no explicit removal of tracking to the RemoveTracking object
- updateCount = -1;
}
if (CacheableToken::isInvalid(value) || CacheableToken::isTombstone(value)) {
@@ -3127,10 +3125,11 @@ std::shared_ptr<Cacheable> LocalRegion::handleReplay(
if (err == GF_TRANSACTION_DATA_REBALANCED_EXCEPTION ||
err == GF_TRANSACTION_DATA_NODE_HAS_DEPARTED_EXCEPTION) {
bool isRollBack = (err == GF_TRANSACTION_DATA_REBALANCED_EXCEPTION);
- TXState* txState = getTXState();
- if (txState == nullptr) {
+ auto txState = getTXState();
+ if (!txState) {
GfErrTypeThrowException("TXState is nullptr",
GF_CACHE_ILLEGAL_STATE_EXCEPTION);
+ throw ""; // never reached
}
auto ret = txState->replay(isRollBack);
diff --git a/cppcache/src/MapSegment.hpp b/cppcache/src/MapSegment.hpp
index b3ccb74..5978f4f 100644
--- a/cppcache/src/MapSegment.hpp
+++ b/cppcache/src/MapSegment.hpp
@@ -66,7 +66,8 @@ class ACE_Equal_To<std::shared_ptr<apache::geode::client::CacheableKey>> {
}
};
-} // namespace ACE_VERSIONED_NAMESPACE_NAME NOLINT
+// NOLINTNEXTLINE(google-readability-namespace-comments)
+} // namespace ACE_VERSIONED_NAMESPACE_NAME
namespace apache {
namespace geode {
diff --git a/cppcache/src/PdxHelper.cpp b/cppcache/src/PdxHelper.cpp
index b12caf2..2a329c2 100644
--- a/cppcache/src/PdxHelper.cpp
+++ b/cppcache/src/PdxHelper.cpp
@@ -303,7 +303,7 @@ std::shared_ptr<PdxSerializable> PdxHelper::deserializePdx(
dataInput.advanceCursor(len);
- return pdxObject;
+ return std::move(pdxObject);
}
}
diff --git a/cppcache/src/PdxInstanceFactory.cpp b/cppcache/src/PdxInstanceFactory.cpp
index 2584839..c154ac0 100644
--- a/cppcache/src/PdxInstanceFactory.cpp
+++ b/cppcache/src/PdxInstanceFactory.cpp
@@ -52,7 +52,7 @@ std::shared_ptr<PdxInstance> PdxInstanceFactory::create() {
auto dataOutput = m_cacheImpl.createDataOutput();
PdxHelper::serializePdx(dataOutput, pi);
- return pi;
+ return std::move(pi);
}
PdxInstanceFactory& PdxInstanceFactory::writeChar(const std::string& fieldName,
char16_t value) {
diff --git a/cppcache/src/PdxTypeRegistry.cpp b/cppcache/src/PdxTypeRegistry.cpp
index 40c5e91..f9fc2bd 100644
--- a/cppcache/src/PdxTypeRegistry.cpp
+++ b/cppcache/src/PdxTypeRegistry.cpp
@@ -241,7 +241,7 @@ std::shared_ptr<EnumInfo> PdxTypeRegistry::getEnum(int32_t enumVal) {
if (entry != tmp->end()) {
auto&& ret = std::dynamic_pointer_cast<EnumInfo>(entry->second);
if (ret) {
- return ret;
+ return std::move(ret);
}
}
}
@@ -253,7 +253,7 @@ std::shared_ptr<EnumInfo> PdxTypeRegistry::getEnum(int32_t enumVal) {
if (entry != tmp->end()) {
auto&& ret = std::dynamic_pointer_cast<EnumInfo>(entry->second);
if (ret) {
- return ret;
+ return std::move(ret);
}
}
}
@@ -265,7 +265,7 @@ std::shared_ptr<EnumInfo> PdxTypeRegistry::getEnum(int32_t enumVal) {
tmp = intToEnum;
(*tmp)[enumValPtr] = ret;
intToEnum = tmp;
- return ret;
+ return std::move(ret);
}
} // namespace client
} // namespace geode
diff --git a/cppcache/src/PoolFactory.cpp b/cppcache/src/PoolFactory.cpp
index 46c93c4..78f92a5 100644
--- a/cppcache/src/PoolFactory.cpp
+++ b/cppcache/src/PoolFactory.cpp
@@ -301,7 +301,7 @@ std::shared_ptr<Pool> PoolFactory::create(std::string name) {
poolDM->init();
}
- return poolDM;
+ return std::move(poolDM);
}
PoolFactory& PoolFactory::addCheck(const std::string& host, int port) {
diff --git a/cppcache/src/PoolXmlCreation.cpp b/cppcache/src/PoolXmlCreation.cpp
index d203962..48d6717 100644
--- a/cppcache/src/PoolXmlCreation.cpp
+++ b/cppcache/src/PoolXmlCreation.cpp
@@ -38,11 +38,11 @@ void PoolXmlCreation::addServer(const char * host, const char * port)
}
*/
std::shared_ptr<Pool> PoolXmlCreation::create() {
- return poolFactory->create(poolName.c_str());
+ return poolFactory->create(poolName);
}
-PoolXmlCreation::PoolXmlCreation(const char* name, std::shared_ptr<PoolFactory> factory) {
- poolName = name;
+PoolXmlCreation::PoolXmlCreation(std::string name, std::shared_ptr<PoolFactory> factory) {
+ poolName = std::move(name);
poolFactory = factory;
}
diff --git a/cppcache/src/PoolXmlCreation.hpp b/cppcache/src/PoolXmlCreation.hpp
index fe373e0..4663d5f 100644
--- a/cppcache/src/PoolXmlCreation.hpp
+++ b/cppcache/src/PoolXmlCreation.hpp
@@ -47,25 +47,13 @@ class APACHE_GEODE_EXPORT PoolXmlCreation {
/** The name of this pool */
std::string poolName;
- /*
- std::vector<std::string> locatorhosts;
- std::vector<std::string> locatorports;
- std::vector<std::string> serverhosts;
- std::vector<std::string> serverports;
- */
public:
~PoolXmlCreation();
/**
* Creates a new <code>PoolXmlCreation</code> with the given pool name.
*/
- PoolXmlCreation(const char* name, std::shared_ptr<PoolFactory> factory);
-
- /** Add a locator */
- // void addLocator(const char * host, const char * port);
-
- /** Add a server */
- // void addServer(const char * host, const char * port);
+ PoolXmlCreation(std::string name, std::shared_ptr<PoolFactory> factory);
/**
* Creates a {@link Pool} using the
diff --git a/cppcache/src/ProxyRegion.hpp b/cppcache/src/ProxyRegion.hpp
index 539124c..c22852d 100644
--- a/cppcache/src/ProxyRegion.hpp
+++ b/cppcache/src/ProxyRegion.hpp
@@ -110,7 +110,9 @@ class APACHE_GEODE_EXPORT ProxyRegion final : public Region {
auto rPtr = std::static_pointer_cast<RegionInternal>(
m_realRegion->getSubregion(path));
- if (rPtr == nullptr) return rPtr;
+ if (rPtr == nullptr) {
+ return std::move(rPtr);
+ }
return std::make_shared<ProxyRegion>(*m_authenticatedView, rPtr);
}
diff --git a/cppcache/src/Queue.hpp b/cppcache/src/Queue.hpp
index 4f6a356..e550279 100644
--- a/cppcache/src/Queue.hpp
+++ b/cppcache/src/Queue.hpp
@@ -45,14 +45,14 @@ class APACHE_GEODE_EXPORT Queue {
~Queue() { close(); }
- T* get() {
+ T get() {
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
return getNoLock();
}
/** wait "sec" secs, "usec" micros time until notified */
- T* getUntil(uint32_t sec, uint32_t usec = 0) {
- T* mp = get();
+ T getUntil(uint32_t sec, uint32_t usec = 0) {
+ auto&& mp = get();
if (mp == nullptr) {
ACE_Time_Value interval(sec + usec / 1000000, usec % 1000000);
@@ -67,7 +67,7 @@ class APACHE_GEODE_EXPORT Queue {
return mp;
}
- bool put(T* mp) {
+ bool put(T mp) {
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
if (m_maxSize > 0 && m_queue.size() >= m_maxSize) {
return false;
@@ -75,7 +75,7 @@ class APACHE_GEODE_EXPORT Queue {
return putNoLock(mp);
}
- bool putUntil(T* mp, uint32_t sec, uint32_t usec = 0) {
+ bool putUntil(T mp, uint32_t sec, uint32_t usec = 0) {
if (m_maxSize > 0) {
{
ACE_Guard<ACE_Recursive_Thread_Mutex> _guard(m_mutex);
@@ -111,9 +111,8 @@ class APACHE_GEODE_EXPORT Queue {
if (m_deleteObjs) {
while (m_queue.size() > 0) {
- T* mp = m_queue.back();
+ auto&& mp = m_queue.back();
m_queue.pop_back();
- delete mp;
}
} else {
m_queue.clear();
@@ -130,8 +129,8 @@ class APACHE_GEODE_EXPORT Queue {
bool empty() { return (size() == 0); }
private:
- inline T* getNoLock() {
- T* mp = nullptr;
+ inline T getNoLock() {
+ T mp = nullptr;
uint32_t queueSize = static_cast<uint32_t>(m_queue.size());
if (queueSize > 0) {
@@ -145,7 +144,7 @@ class APACHE_GEODE_EXPORT Queue {
return mp;
}
- inline bool putNoLock(T* mp) {
+ inline bool putNoLock(T mp) {
if (!m_closed) {
m_queue.push_front(mp);
// signal the waiting getter threads, if any
@@ -157,7 +156,7 @@ class APACHE_GEODE_EXPORT Queue {
return false;
}
- std::deque<T*> m_queue;
+ std::deque<T> m_queue;
ACE_Recursive_Thread_Mutex m_mutex;
ACE_Condition<ACE_Recursive_Thread_Mutex> m_cond;
bool m_deleteObjs;
diff --git a/cppcache/src/RegionAttributesFactory.cpp b/cppcache/src/RegionAttributesFactory.cpp
index 96cef04..e279881 100644
--- a/cppcache/src/RegionAttributesFactory.cpp
+++ b/cppcache/src/RegionAttributesFactory.cpp
@@ -115,7 +115,7 @@ RegionAttributesFactory& RegionAttributesFactory::setRegionTimeToLive(
}
RegionAttributesFactory& RegionAttributesFactory::setInitialCapacity(
- int initialCapacity) {
+ int32_t initialCapacity) {
m_regionAttributes.m_initialCapacity = initialCapacity;
return *this;
}
diff --git a/cppcache/src/RegionCommit.cpp b/cppcache/src/RegionCommit.cpp
index 7dd8ee3..6a9bda7 100644
--- a/cppcache/src/RegionCommit.cpp
+++ b/cppcache/src/RegionCommit.cpp
@@ -31,14 +31,14 @@ void RegionCommit::fromData(DataInput& input) {
m_regionPath = std::dynamic_pointer_cast<CacheableString>(input.readObject());
m_parentRegionPath =
std::dynamic_pointer_cast<CacheableString>(input.readObject());
- int32_t size = input.readInt32();
+ auto size = input.readInt32();
if (size > 0) {
const auto largeModCount = input.readBoolean();
auto dsMember =
std::dynamic_pointer_cast<DSMemberForVersionStamp>(input.readObject());
auto memId = m_memberListForVersionStamp.add(dsMember);
- for (int i = 0; i < size; i++) {
+ for (int32_t i = 0; i < size; i++) {
auto entryOp =
std::make_shared<FarSideEntryOp>(m_memberListForVersionStamp);
entryOp->fromData(input, largeModCount, memId);
diff --git a/cppcache/src/RegionXmlCreation.cpp b/cppcache/src/RegionXmlCreation.cpp
index de88fe4..9959d47 100644
--- a/cppcache/src/RegionXmlCreation.cpp
+++ b/cppcache/src/RegionXmlCreation.cpp
@@ -50,7 +50,7 @@ void RegionXmlCreation::createRoot(Cache* cache) {
std::shared_ptr<Region> rootRegPtr = nullptr;
CacheImpl* cacheImpl = CacheRegionHelper::getCacheImpl(cache);
- cacheImpl->createRegion(regionName.c_str(), regionAttributes, rootRegPtr);
+ cacheImpl->createRegion(regionName, regionAttributes, rootRegPtr);
fillIn(rootRegPtr);
}
@@ -58,13 +58,12 @@ void RegionXmlCreation::create(std::shared_ptr<Region> parent) {
GF_D_ASSERT(!(this->isRoot));
std::shared_ptr<Region> subRegPtr = nullptr;
- subRegPtr = parent->createSubregion(regionName.c_str(), regionAttributes);
+ subRegPtr = parent->createSubregion(regionName, regionAttributes);
fillIn(subRegPtr);
}
-RegionXmlCreation::RegionXmlCreation(const char* name, bool isRootRegion) {
- std::string tempName(name);
- regionName = tempName;
+RegionXmlCreation::RegionXmlCreation(std::string name, bool isRootRegion) {
+ regionName = std::move(name);
isRoot = isRootRegion;
attrId = "";
}
diff --git a/cppcache/src/RegionXmlCreation.hpp b/cppcache/src/RegionXmlCreation.hpp
index fead376..31fac09 100644
--- a/cppcache/src/RegionXmlCreation.hpp
+++ b/cppcache/src/RegionXmlCreation.hpp
@@ -73,7 +73,7 @@ class APACHE_GEODE_EXPORT RegionXmlCreation {
/**
* Creates a new <code>RegionCreation</code> with the given name.
*/
- explicit RegionXmlCreation(const char* name, bool isRoot = false);
+ explicit RegionXmlCreation(std::string name, bool isRoot = false);
/**
* Adds a subregion with the given name to this region
diff --git a/cppcache/src/RemoteQuery.cpp b/cppcache/src/RemoteQuery.cpp
index 9e24b91..d1efc40 100644
--- a/cppcache/src/RemoteQuery.cpp
+++ b/cppcache/src/RemoteQuery.cpp
@@ -54,7 +54,7 @@ std::shared_ptr<SelectResults> RemoteQuery::execute(
std::chrono::milliseconds timeout) {
util::PROTOCOL_OPERATION_TIMEOUT_BOUNDS(timeout);
GuardUserAttributes gua;
- if (m_authenticatedView != nullptr) {
+ if (m_authenticatedView) {
gua.setAuthenticatedView(m_authenticatedView);
}
return execute(timeout, "Query::execute", m_tccdm, paramList);
@@ -63,12 +63,12 @@ std::shared_ptr<SelectResults> RemoteQuery::execute(
std::shared_ptr<SelectResults> RemoteQuery::execute(
std::chrono::milliseconds timeout, const char* func, ThinClientBaseDM* tcdm,
std::shared_ptr<CacheableVector> paramList) {
- auto* pool = dynamic_cast<ThinClientPoolDM*>(tcdm);
- if (pool != nullptr) {
+ auto pool = dynamic_cast<ThinClientPoolDM*>(tcdm);
+ if (pool) {
pool->getStats().incQueryExecutionId();
}
/*get the start time for QueryExecutionTime stat*/
- bool enableTimeStatistics = pool->getConnectionManager()
+ bool enableTimeStatistics = tcdm->getConnectionManager()
.getCacheImpl()
->getDistributedSystem()
.getSystemProperties()
@@ -108,7 +108,7 @@ std::shared_ptr<SelectResults> RemoteQuery::execute(
}
/*update QueryExecutionTime stat */
- if (pool != nullptr && enableTimeStatistics) {
+ if (pool && enableTimeStatistics) {
Utils::updateStatOpTime(pool->getStats().getStats(),
pool->getStats().getQueryExecutionTimeId(),
sampleStartNanos);
diff --git a/cppcache/src/SerializationRegistry.cpp b/cppcache/src/SerializationRegistry.cpp
index ea2b5ad..febb022 100644
--- a/cppcache/src/SerializationRegistry.cpp
+++ b/cppcache/src/SerializationRegistry.cpp
@@ -173,7 +173,7 @@ std::shared_ptr<Serializable> SerializationRegistry::deserialize(
case DSCode::CacheableEnum: {
auto enumObject = CacheableEnum::create(" ", " ", 0);
enumObject->fromData(input);
- return enumObject;
+ return std::move(enumObject);
}
case DSCode::CacheableUserData:
case DSCode::CacheableUserData2:
diff --git a/cppcache/src/SerializationRegistry.hpp b/cppcache/src/SerializationRegistry.hpp
index ca4a431..1eddbcf 100644
--- a/cppcache/src/SerializationRegistry.hpp
+++ b/cppcache/src/SerializationRegistry.hpp
@@ -48,15 +48,17 @@
#include "MemberListForVersionStamp.hpp"
#include "config.h"
-namespace ACE_VERSIONED_NAMESPACE_NAME { // NOLINT
+namespace ACE_VERSIONED_NAMESPACE_NAME {
#if defined(_MACOSX)
// TODO CMake check type int64_t
template <>
class ACE_Export ACE_Hash<int64_t> {
public:
- inline unsigned long operator()(int64_t t) const { // NOLINT
- return static_cast<unsigned long>(t); // NOLINT
+ // NOLINTNEXTLINE(google-runtime-int)
+ inline unsigned long operator()(int64_t t) const {
+ // NOLINTNEXTLINE(google-runtime-int)
+ return static_cast<unsigned long>(t);
}
};
@@ -71,7 +73,8 @@ class ACE_Hash<DSCode> {
}
};
-} // namespace ACE_VERSIONED_NAMESPACE_NAME NOLINT
+// NOLINTNEXTLINE(google-readability-namespace-comments)
+} // namespace ACE_VERSIONED_NAMESPACE_NAME
namespace apache {
namespace geode {
diff --git a/cppcache/src/TXCommitMessage.cpp b/cppcache/src/TXCommitMessage.cpp
index b2ffe34..2975d40 100644
--- a/cppcache/src/TXCommitMessage.cpp
+++ b/cppcache/src/TXCommitMessage.cpp
@@ -43,25 +43,21 @@ void TXCommitMessage::fromData(DataInput& input) {
// read and ignore txIdent
input.readInt32();
-
ClientProxyMembershipID memId;
memId.fromData(input);
if (input.readBoolean()) {
- memId.fromData(input);
// read and ignore lockId
+ memId.fromData(input);
input.readInt32();
}
// read and ignore totalMaxSize
input.readInt32();
- int8_t* m_farsideBaseMembershipId;
- int32_t m_farsideBaseMembershipIdLen;
- input.readBytes(&m_farsideBaseMembershipId, &m_farsideBaseMembershipIdLen);
-
- if (m_farsideBaseMembershipId != nullptr) {
- _GEODE_SAFE_DELETE_ARRAY(m_farsideBaseMembershipId);
- m_farsideBaseMembershipId = nullptr;
+ // ignore farsideBaseMembershipId
+ auto ignoreLength = input.readArrayLength();
+ if (ignoreLength > 0) {
+ input.advanceCursor(ignoreLength);
}
input.readInt64(); // ignore tid
@@ -69,7 +65,7 @@ void TXCommitMessage::fromData(DataInput& input) {
input.readBoolean(); // ignore needsLargeModCount
- int32_t regionSize = input.readInt32();
+ auto regionSize = input.readInt32();
for (int32_t i = 0; i < regionSize; i++) {
auto rc = std::make_shared<RegionCommit>(m_memberListForVersionStamp);
rc->fromData(input);
diff --git a/cppcache/src/TcrConnectionManager.hpp b/cppcache/src/TcrConnectionManager.hpp
index b6078d2..20b7838 100644
--- a/cppcache/src/TcrConnectionManager.hpp
+++ b/cppcache/src/TcrConnectionManager.hpp
@@ -167,9 +167,9 @@ class APACHE_GEODE_EXPORT TcrConnectionManager {
ExpiryTaskManager::id_type m_pingTaskId;
ExpiryTaskManager::id_type m_servermonitorTaskId;
- Queue<Task<TcrEndpoint> > m_receiverReleaseList;
- Queue<TcrConnection> m_connectionReleaseList;
- Queue<ACE_Semaphore> m_notifyCleanupSemaList;
+ Queue<Task<TcrEndpoint>*> m_receiverReleaseList;
+ Queue<TcrConnection*> m_connectionReleaseList;
+ Queue<ACE_Semaphore*> m_notifyCleanupSemaList;
ACE_Semaphore m_redundancySema;
Task<TcrConnectionManager>* m_redundancyTask;
diff --git a/cppcache/src/TcrMessage.cpp b/cppcache/src/TcrMessage.cpp
index 83c4a2b..d884234 100644
--- a/cppcache/src/TcrMessage.cpp
+++ b/cppcache/src/TcrMessage.cpp
@@ -1221,18 +1221,18 @@ void TcrMessage::handleByteArrayResponse(
m_metadata =
new std::vector<std::vector<std::shared_ptr<BucketServerLocation>>>();
for (int32_t i = 0; i < numparts; i++) {
- int32_t bits32 = input.readInt32(); // partlen;
- input.read(); // isObj;
- auto bits8 = input.read(); // cacheable vector typeid
+ input.readInt32(); // ignore partlen
+ input.read(); // ignore isObj;
+ auto bits8 = input.read(); // cacheable vector typeid
LOGDEBUG("Expected typeID %d, got %d", DSCode::CacheableArrayList,
bits8);
- bits32 = input.readArrayLength(); // array length
- LOGDEBUG("Array length = %d ", bits32);
- if (bits32 > 0) {
+ auto arrayLength = input.readArrayLength(); // array length
+ LOGDEBUG("Array length = %d ", arrayLength);
+ if (arrayLength > 0) {
std::vector<std::shared_ptr<BucketServerLocation>>
bucketServerLocations;
- for (int32_t index = 0; index < bits32; index++) {
+ for (int32_t index = 0; index < arrayLength; index++) {
// ignore DS typeid, CLASS typeid, and string typeid
input.advanceCursor(3);
uint16_t classLen = input.readInt16(); // Read classLen
@@ -1258,39 +1258,39 @@ void TcrMessage::handleByteArrayResponse(
}
case TcrMessage::RESPONSE_CLIENT_PARTITION_ATTRIBUTES: {
- int32_t bits32 = input.readInt32(); // partlen;
- input.read(); // ignore isObj;
+ input.readInt32(); // ignore partlen;
+ input.read(); // ignore isObj;
// PART1 = bucketCount
m_bucketCount = input.readNativeInt32();
- bits32 = input.readInt32(); // partlen;
- input.read(); // ignore isObj;
- if (bits32 > 0) {
+ auto partLength = input.readInt32(); // partlen;
+ input.read(); // ignore isObj;
+ if (partLength > 0) {
// PART2 = colocatedwith
m_colocatedWith = input.readString();
}
if (numparts == 4) {
- bits32 = input.readInt32(); // partlen;
- input.read(); // ignore isObj;
- if (bits32 > 0) {
+ partLength = input.readInt32(); // partlen;
+ input.read(); // ignore isObj;
+ if (partLength > 0) {
// PART3 = partitionresolvername
m_partitionResolverName = input.readString();
}
- bits32 = input.readInt32(); // partlen;
- input.read(); // ignore isObj;
- input.read(); // ignore cacheable CacheableHashSet typeid
+ input.readInt32(); // ignore partlen;
+ input.read(); // ignore isObj;
+ input.read(); // ignore cacheable CacheableHashSet typeid
- bits32 = input.readArrayLength(); // array length
- if (bits32 > 0) {
+ auto arrayLength = input.readArrayLength(); // array length
+ if (arrayLength > 0) {
m_fpaSet =
new std::vector<std::shared_ptr<FixedPartitionAttributesImpl>>();
- for (int32_t index = 0; index < bits32; index++) {
+ for (int32_t index = 0; index < arrayLength; index++) {
input.advanceCursor(
3); // ignore DS typeid, CLASS typeid, string typeid
- uint16_t classLen = input.readInt16(); // Read classLen
+ auto classLen = input.readInt16(); // Read classLen
input.advanceCursor(classLen);
auto fpa = std::make_shared<FixedPartitionAttributesImpl>();
fpa->fromData(input); // PART4 = set of FixedAttributes.
diff --git a/cppcache/src/ThinClientBaseDM.hpp b/cppcache/src/ThinClientBaseDM.hpp
index 56406e1..7a235b9 100644
--- a/cppcache/src/ThinClientBaseDM.hpp
+++ b/cppcache/src/ThinClientBaseDM.hpp
@@ -192,7 +192,7 @@ class ThinClientBaseDM {
bool m_initDone;
bool m_clientNotification;
- Queue<TcrChunkedContext> m_chunks;
+ Queue<TcrChunkedContext*> m_chunks;
Task<ThinClientBaseDM>* m_chunkProcessor;
private:
diff --git a/cppcache/src/ThinClientLocatorHelper.cpp b/cppcache/src/ThinClientLocatorHelper.cpp
index df7d5e9..573c9de 100644
--- a/cppcache/src/ThinClientLocatorHelper.cpp
+++ b/cppcache/src/ThinClientLocatorHelper.cpp
@@ -52,12 +52,11 @@ class ConnectionWrapper {
};
ThinClientLocatorHelper::ThinClientLocatorHelper(
- std::vector<std::string> locHostPort, const ThinClientPoolDM* poolDM)
+ const std::vector<std::string>& locatorAddresses,
+ const ThinClientPoolDM* poolDM)
: m_poolDM(poolDM) {
- for (std::vector<std::string>::iterator it = locHostPort.begin();
- it != locHostPort.end(); it++) {
- ServerLocation sl(*it);
- m_locHostPort.push_back(sl);
+ for (auto&& locatorAddress : locatorAddresses) {
+ m_locHostPort.emplace_back(locatorAddress);
}
}
@@ -69,7 +68,7 @@ Connector* ThinClientLocatorHelper::createConnection(
.getCacheImpl()
->getDistributedSystem()
.getSystemProperties();
- if (m_poolDM && systemProperties.sslEnabled()) {
+ if (systemProperties.sslEnabled()) {
socket = new TcpSslConn(hostname, port, waitSeconds, maxBuffSizePool,
systemProperties.sslTrustStore().c_str(),
systemProperties.sslKeyStore().c_str(),
@@ -91,35 +90,30 @@ GfErrType ThinClientLocatorHelper::getAllServers(
.getCacheImpl()
->getDistributedSystem()
.getSystemProperties();
- for (unsigned i = 0; i < m_locHostPort.size(); i++) {
- ServerLocation loc = m_locHostPort[i];
+ for (size_t i = 0; i < m_locHostPort.size(); i++) {
+ auto& loc = m_locHostPort[i];
try {
LOGDEBUG("getAllServers getting servers from server = %s ",
loc.getServerName().c_str());
- int32_t buffSize = 0;
- if (m_poolDM) {
- buffSize = static_cast<int32_t>(m_poolDM->getSocketBufferSize());
- }
+ auto buffSize = m_poolDM->getSocketBufferSize();
Connector* conn = nullptr;
ConnectionWrapper cw(conn);
createConnection(conn, loc.getServerName().c_str(), loc.getPort(),
sysProps.connectTimeout(), buffSize);
- std::shared_ptr<GetAllServersRequest> request =
- std::make_shared<GetAllServersRequest>(serverGrp);
+ auto request = std::make_shared<GetAllServersRequest>(serverGrp);
auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
data.writeInt(static_cast<int32_t>(1001)); // GOSSIPVERSION
data.writeObject(request);
auto sentLength = conn->send(
- reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())), data.getBufferLength(),
- m_poolDM ? m_poolDM->getReadTimeout() : std::chrono::seconds(10));
+ reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
+ data.getBufferLength(), m_poolDM->getReadTimeout());
if (sentLength <= 0) {
continue;
}
char buff[BUFF_SIZE];
- auto receivedLength = conn->receive(
- buff, BUFF_SIZE,
- m_poolDM ? m_poolDM->getReadTimeout() : std::chrono::seconds(10));
+ auto receivedLength =
+ conn->receive(buff, BUFF_SIZE, m_poolDM->getReadTimeout());
if (receivedLength <= 0) {
continue;
}
@@ -182,31 +176,26 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewCallBackConn(
try {
LOGFINER("Querying locator at [%s:%d] for queue server from group [%s]",
loc.getServerName().c_str(), loc.getPort(), serverGrp.c_str());
- int32_t buffSize = 0;
- if (m_poolDM) {
- buffSize = static_cast<int32_t>(m_poolDM->getSocketBufferSize());
- }
+ auto buffSize = m_poolDM->getSocketBufferSize();
Connector* conn = nullptr;
ConnectionWrapper cw(conn);
createConnection(conn, loc.getServerName().c_str(), loc.getPort(),
sysProps.connectTimeout(), buffSize);
- std::shared_ptr<QueueConnectionRequest> request =
- std::make_shared<QueueConnectionRequest>(
- memId, exclEndPts, redundancy, false, serverGrp);
+ auto request = std::make_shared<QueueConnectionRequest>(
+ memId, exclEndPts, redundancy, false, serverGrp);
auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
data.writeInt(static_cast<int32_t>(1001)); // GOSSIPVERSION
data.writeObject(request);
auto sentLength = conn->send(
- reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())), data.getBufferLength(),
- m_poolDM ? m_poolDM->getReadTimeout() : sysProps.connectTimeout());
+ reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
+ data.getBufferLength(), m_poolDM->getReadTimeout());
if (sentLength <= 0) {
continue;
}
char buff[BUFF_SIZE];
- auto receivedLength = conn->receive(
- buff, BUFF_SIZE,
- m_poolDM ? m_poolDM->getReadTimeout() : sysProps.connectTimeout());
+ auto receivedLength =
+ conn->receive(buff, BUFF_SIZE, m_poolDM->getReadTimeout());
if (receivedLength <= 0) {
continue;
}
@@ -241,17 +230,14 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
const std::set<ServerLocation>& exclEndPts, const std::string& serverGrp,
const TcrConnection* currentServer) {
bool locatorFound = false;
- int locatorsRetry = 3;
ACE_Guard<ACE_Thread_Mutex> guard(m_locatorLock);
auto& sysProps = m_poolDM->getConnectionManager()
.getCacheImpl()
->getDistributedSystem()
.getSystemProperties();
- if (m_poolDM) {
- int poolRetry = m_poolDM->getRetryAttempts();
- locatorsRetry = poolRetry <= 0 ? locatorsRetry : poolRetry;
- }
+ auto poolRetry = m_poolDM->getRetryAttempts();
+ auto locatorsRetry = poolRetry <= 0 ? 3 : poolRetry;
LOGFINER(
"ThinClientLocatorHelper::getEndpointForNewFwdConn locatorsRetry = %d ",
locatorsRetry);
@@ -269,10 +255,7 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
LOGFINE("Querying locator at [%s:%d] for server from group [%s]",
serLoc.getServerName().c_str(), serLoc.getPort(),
serverGrp.c_str());
- int32_t buffSize = 0;
- if (m_poolDM) {
- buffSize = static_cast<int32_t>(m_poolDM->getSocketBufferSize());
- }
+ auto buffSize = m_poolDM->getSocketBufferSize();
Connector* conn = nullptr;
ConnectionWrapper cw(conn);
createConnection(conn, serLoc.getServerName().c_str(), serLoc.getPort(),
@@ -295,15 +278,14 @@ GfErrType ThinClientLocatorHelper::getEndpointForNewFwdConn(
data.writeObject(request);
}
auto sentLength = conn->send(
- reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())), data.getBufferLength(),
- m_poolDM ? m_poolDM->getReadTimeout() : sysProps.connectTimeout());
+ reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
+ data.getBufferLength(), m_poolDM->getReadTimeout());
if (sentLength <= 0) {
continue;
}
char buff[BUFF_SIZE];
- auto receivedLength = conn->receive(
- buff, BUFF_SIZE,
- m_poolDM ? m_poolDM->getReadTimeout() : sysProps.connectTimeout());
+ auto receivedLength =
+ conn->receive(buff, BUFF_SIZE, m_poolDM->getReadTimeout());
if (receivedLength <= 0) {
continue; // return GF_EUNDEF;
}
@@ -355,37 +337,32 @@ GfErrType ThinClientLocatorHelper::updateLocators(
->getDistributedSystem()
.getSystemProperties();
- for (unsigned attempts = 0; attempts < m_locHostPort.size(); attempts++) {
- ServerLocation serLoc = m_locHostPort[attempts];
+ for (size_t attempts = 0; attempts < m_locHostPort.size(); attempts++) {
+ auto&& serLoc = m_locHostPort[attempts];
Connector* conn = nullptr;
try {
- int32_t buffSize = 0;
- if (m_poolDM) {
- buffSize = static_cast<int32_t>(m_poolDM->getSocketBufferSize());
- }
+ auto buffSize = m_poolDM->getSocketBufferSize();
LOGFINER("Querying locator list at: [%s:%d] for update from group [%s]",
serLoc.getServerName().c_str(), serLoc.getPort(),
serverGrp.c_str());
ConnectionWrapper cw(conn);
createConnection(conn, serLoc.getServerName().c_str(), serLoc.getPort(),
sysProps.connectTimeout(), buffSize);
- std::shared_ptr<LocatorListRequest> request =
- std::make_shared<LocatorListRequest>(serverGrp);
+ auto request = std::make_shared<LocatorListRequest>(serverGrp);
auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
data.writeInt(static_cast<int32_t>(1001)); // GOSSIPVERSION
data.writeObject(request);
auto sentLength = conn->send(
- reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())), data.getBufferLength(),
- m_poolDM ? m_poolDM->getReadTimeout() : sysProps.connectTimeout());
+ reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
+ data.getBufferLength(), m_poolDM->getReadTimeout());
if (sentLength <= 0) {
conn = nullptr;
continue;
}
char buff[BUFF_SIZE];
- auto receivedLength = conn->receive(
- buff, BUFF_SIZE,
- m_poolDM ? m_poolDM->getReadTimeout() : sysProps.connectTimeout());
+ auto receivedLength =
+ conn->receive(buff, BUFF_SIZE, m_poolDM->getReadTimeout());
if (receivedLength <= 0) {
continue;
}
diff --git a/cppcache/src/ThinClientLocatorHelper.hpp b/cppcache/src/ThinClientLocatorHelper.hpp
index 84866e1..e852e41 100644
--- a/cppcache/src/ThinClientLocatorHelper.hpp
+++ b/cppcache/src/ThinClientLocatorHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_THINCLIENTLOCATORHELPER_H_
-#define GEODE_THINCLIENTLOCATORHELPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,11 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_THINCLIENTLOCATORHELPER_H_
+#define GEODE_THINCLIENTLOCATORHELPER_H_
+
#include <string>
#include <geode/internal/geode_globals.hpp>
#include "TcrEndpoint.hpp"
@@ -37,7 +37,7 @@ class TcrEndpoint;
class ThinClientPoolDM;
class ThinClientLocatorHelper {
public:
- ThinClientLocatorHelper(std::vector<std::string> locHostPort,
+ ThinClientLocatorHelper(const std::vector<std::string>& locatorAddresses,
const ThinClientPoolDM* poolDM);
GfErrType getEndpointForNewFwdConn(
ServerLocation& outEndpoint, std::string& additionalLoc,
diff --git a/cppcache/src/ThinClientPoolDM.cpp b/cppcache/src/ThinClientPoolDM.cpp
index cc90da0..b154dcb 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -275,16 +275,14 @@ void ThinClientPoolDM::startBackgroundThreads() {
m_cliCallbackTask->start();
}
- LOGDEBUG("ThinClientPoolDM::startBackgroundThreads: Creating ping task");
- ACE_Event_Handler* pingHandler =
- new ExpiryHandler_T<ThinClientPoolDM>(this, &ThinClientPoolDM::doPing);
-
auto pingInterval =
static_cast<int32_t>(getPingInterval().count() / (1000 * 2));
if (pingInterval > 0) {
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Scheduling ping task at %ld",
pingInterval);
+ auto pingHandler =
+ new ExpiryHandler_T<ThinClientPoolDM>(this, &ThinClientPoolDM::doPing);
m_pingTaskId =
m_connManager.getCacheImpl()->getExpiryTaskManager().scheduleExpiryTask(
pingHandler, 1, pingInterval, false);
@@ -307,9 +305,8 @@ void ThinClientPoolDM::startBackgroundThreads() {
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Creating updateLocatorList "
"task");
- ACE_Event_Handler* updateLocatorListHandler =
- new ExpiryHandler_T<ThinClientPoolDM>(
- this, &ThinClientPoolDM::doUpdateLocatorList);
+ auto updateLocatorListHandler = new ExpiryHandler_T<ThinClientPoolDM>(
+ this, &ThinClientPoolDM::doUpdateLocatorList);
LOGDEBUG(
"ThinClientPoolDM::startBackgroundThreads: Scheduling updater Locator "
@@ -718,10 +715,7 @@ const std::shared_ptr<CacheableStringArray> ThinClientPoolDM::getServers() {
std::vector<std::shared_ptr<CacheableString>>(ptrArr, ptrArr + i));
} else if (!m_attrs->m_initLocList.empty()) {
std::vector<std::shared_ptr<ServerLocation>> vec;
- // TODO thread - why is this member volatile?
- const_cast<ThinClientLocatorHelper*>(
- reinterpret_cast<volatile ThinClientLocatorHelper*>(m_locHelper))
- ->getAllServers(vec, m_attrs->m_serverGrp);
+ m_locHelper->getAllServers(vec, m_attrs->m_serverGrp);
auto ptrArr = new std::shared_ptr<CacheableString>[vec.size()];
int32_t i = 0;
@@ -1105,7 +1099,7 @@ GfErrType ThinClientPoolDM::sendUserCredentials(
bool isBGThread, bool& isServerException) {
LOGDEBUG("ThinClientPoolDM::sendUserCredentials:");
- GfErrType err = GF_NOERR;
+ auto err = GF_NOERR;
TcrMessageUserCredential request(
new DataOutput(m_connManager.getCacheImpl()->createDataOutput()),
@@ -1116,7 +1110,9 @@ GfErrType ThinClientPoolDM::sendUserCredentials(
err =
conn->getEndpointObject()->sendRequestConnWithRetry(request, reply, conn);
- if (conn) err = handleEPError(conn->getEndpointObject(), reply, err);
+ if (conn) {
+ err = handleEPError(conn->getEndpointObject(), reply, err);
+ }
LOGDEBUG(
"ThinClientPoolDM::sendUserCredentials: Error after sending cred request "
@@ -1130,7 +1126,7 @@ GfErrType ThinClientPoolDM::sendUserCredentials(
break;
}
case TcrMessage::EXCEPTION: {
- if (err == GF_NOERR) {
+ if (err == GF_NOERR && conn) {
putInQueue(
conn, isBGThread); // connFound is only relevant for Sticky conn.
}
@@ -1142,7 +1138,7 @@ GfErrType ThinClientPoolDM::sendUserCredentials(
break;
}
default: {
- if (err == GF_NOERR) {
+ if (err == GF_NOERR && conn) {
putInQueue(
conn, isBGThread); // connFound is only relevant for Sticky conn.
}
@@ -1639,13 +1635,13 @@ GfErrType ThinClientPoolDM::getConnectionToAnEndPoint(std::string epNameStr,
conn = nullptr;
GfErrType error = GF_NOERR;
- TcrEndpoint* theEP = getEndPoint(epNameStr);
+ auto theEP = getEndPoint(epNameStr);
LOGFINE(
"ThinClientPoolDM::getConnectionToAnEndPoint( ): Getting endpoint object "
"for %s",
epNameStr.c_str());
- if (theEP != nullptr && theEP->connected()) {
+ if (theEP && theEP->connected()) {
LOGFINE(
"ThinClientPoolDM::getConnectionToAnEndPoint( ): Getting connection "
"for endpoint %s",
@@ -1666,7 +1662,7 @@ GfErrType ThinClientPoolDM::getConnectionToAnEndPoint(std::string epNameStr,
// if connection is null, it has failed to get a connection to the specified
// endpoint. Get a connection to any other server and failover the transaction
// to that server.
- if (conn == nullptr) {
+ if (!conn) {
std::set<ServerLocation> excludeServers;
bool maxConnLimit = false;
LOGFINE(
@@ -1674,14 +1670,14 @@ GfErrType ThinClientPoolDM::getConnectionToAnEndPoint(std::string epNameStr,
"available for endpoint %s. Create connection to any endpoint.",
epNameStr.c_str());
conn = getConnectionFromQueue(true, &error, excludeServers, maxConnLimit);
- if (conn != nullptr && error == GF_NOERR) {
+ if (conn && error == GF_NOERR) {
if (conn->getEndpointObject()->name() != epNameStr) {
LOGFINE(
"ThinClientPoolDM::getConnectionToAnEndPoint( ): Endpoint %s "
"different than the endpoint %s. New connection created and "
"failing over.",
epNameStr.c_str(), conn->getEndpointObject()->name().c_str());
- GfErrType failoverErr = doFailover(conn);
+ auto failoverErr = doFailover(conn);
if (failoverErr != GF_NOERR) {
LOGFINE(
"ThinClientPoolDM::getConnectionToAnEndPoint( ):Failed to "
@@ -1694,11 +1690,13 @@ GfErrType ThinClientPoolDM::getConnectionToAnEndPoint(std::string epNameStr,
}
}
- if (conn == nullptr || error != GF_NOERR) {
+ if (!(conn && error == GF_NOERR)) {
LOGFINE(
"ThinClientPoolDM::getConnectionToAEndPoint( ):Failed to connect to %s",
- theEP->name().c_str());
- if (conn != nullptr) _GEODE_SAFE_DELETE(conn);
+ epNameStr.c_str());
+ if (conn) {
+ _GEODE_SAFE_DELETE(conn);
+ }
}
return error;
diff --git a/cppcache/src/ThinClientRedundancyManager.cpp b/cppcache/src/ThinClientRedundancyManager.cpp
index ad180b7..bbe688c 100644
--- a/cppcache/src/ThinClientRedundancyManager.cpp
+++ b/cppcache/src/ThinClientRedundancyManager.cpp
@@ -915,19 +915,18 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestRegisterInterest(
TcrMessage& request, TcrMessageReply& reply, bool, TcrEndpoint* endpoint,
ThinClientBaseDM* theHADM, ThinClientRegion* region) {
LOGDEBUG("ThinClientRedundancyManager::sendSyncRequestRegisterInterest ");
- if (endpoint == nullptr) {
+ if (!endpoint) {
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(m_redundantEndpointsLock);
- GfErrType err = GF_NOERR;
- GfErrType opErr = GF_NOERR;
+ auto err = GF_NOERR;
+ auto opErr = GF_NOERR;
TcrEndpoint* primaryEndpoint = nullptr;
- if (m_redundantEndpoints.size() >= 1) {
- std::vector<TcrEndpoint*>::iterator iter = m_redundantEndpoints.begin();
- for (++iter; iter != m_redundantEndpoints.end(); ++iter) {
- (*iter)->setDM(request.getDM());
- opErr = theHADM->sendSyncRequestRegisterInterestEP(request, reply,
- false, *iter);
+ if (!m_redundantEndpoints.empty()) {
+ for (auto&& redundantEndpoint : m_redundantEndpoints) {
+ redundantEndpoint->setDM(request.getDM());
+ opErr = theHADM->sendSyncRequestRegisterInterestEP(
+ request, reply, false, redundantEndpoint);
if (err == GF_NOERR) {
err = opErr;
}
@@ -954,7 +953,7 @@ GfErrType ThinClientRedundancyManager::sendSyncRequestRegisterInterest(
if (m_redundantEndpoints.empty()) {
err = GF_NOTCON;
- } else if (primaryEndpoint == m_redundantEndpoints[0]) {
+ } else if (primaryEndpoint && primaryEndpoint == m_redundantEndpoints[0]) {
for (size_t count = 0;
count < m_redundantEndpoints.size() + m_nonredundantEndpoints.size();
count++) {
@@ -1193,8 +1192,8 @@ void ThinClientRedundancyManager::doPeriodicAck() {
if (endpoint != m_redundantEndpoints.end()) {
TcrMessagePeriodicAck request(
- new DataOutput(m_theTcrConnManager->getCacheImpl()
- ->createDataOutput()),
+ new DataOutput(
+ m_theTcrConnManager->getCacheImpl()->createDataOutput()),
entries);
TcrMessageReply reply(true, nullptr);
@@ -1259,9 +1258,11 @@ void ThinClientRedundancyManager::startPeriodicAck() {
"notify-dupcheck-life = %ld, periodic ack is %sabled",
m_processEventIdMapTaskId,
(m_poolHADM ? m_poolHADM->getSubscriptionAckInterval()
- : props.notifyAckInterval()).count(),
+ : props.notifyAckInterval())
+ .count(),
(m_poolHADM ? m_poolHADM->getSubscriptionMessageTrackingTimeout()
- : props.notifyDupCheckLife()).count(),
+ : props.notifyDupCheckLife())
+ .count(),
m_HAenabled ? "en" : "dis");
}
diff --git a/cppcache/src/ThinClientRegion.cpp b/cppcache/src/ThinClientRegion.cpp
index 2629685..6fc96b7 100644
--- a/cppcache/src/ThinClientRegion.cpp
+++ b/cppcache/src/ThinClientRegion.cpp
@@ -419,8 +419,8 @@ void ThinClientRegion::registerKeys(
}
if (getInitialValues && !m_regionAttributes.getCachingEnabled()) {
LOGERROR(
- "Register keys getInitialValues flag is only applicable for caching"
- "clients");
+ "Register keys getInitialValues flag is only applicable for caching"
+ "clients");
throw IllegalStateException(
"getInitialValues flag only applicable for caching clients");
}
@@ -500,8 +500,8 @@ void ThinClientRegion::registerAllKeys(bool isDurable, bool getInitialValues,
if (getInitialValues && !m_regionAttributes.getCachingEnabled()) {
LOGERROR(
- "Register all keys getInitialValues flag is only applicable for caching"
- "clients");
+ "Register all keys getInitialValues flag is only applicable for caching"
+ "clients");
throw IllegalStateException(
"getInitialValues flag only applicable for caching clients");
}
@@ -2304,7 +2304,8 @@ GfErrType ThinClientRegion::registerKeysNoThrow(
request, *reply, attemptFailover, this, endpoint);
if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) {
- if (reply->getMessageType() == TcrMessage::RESPONSE_FROM_SECONDARY) {
+ if (reply->getMessageType() == TcrMessage::RESPONSE_FROM_SECONDARY &&
+ endpoint) {
LOGFINER(
"registerKeysNoThrow - got response from secondary for "
"endpoint %s, ignoring.",
@@ -2492,7 +2493,8 @@ GfErrType ThinClientRegion::registerRegexNoThrow(
request, *reply, attemptFailover, this, endpoint);
}
if (err == GF_NOERR /*|| err == GF_CACHE_REDUNDANCY_FAILURE*/) {
- if (reply->getMessageType() == TcrMessage::RESPONSE_FROM_SECONDARY) {
+ if (reply->getMessageType() == TcrMessage::RESPONSE_FROM_SECONDARY &&
+ endpoint) {
LOGFINER(
"registerRegexNoThrow - got response from secondary for "
"endpoint %s, ignoring.",
@@ -3462,25 +3464,21 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
auto input = cacheImpl->createDataInput(chunk, chunkLen, m_msg.getPool());
uint32_t partLen;
- TcrMessageHelper::ChunkObjectType objType =
- TcrMessageHelper::readChunkPartHeader(
- m_msg, input, DSCode::FixedIDByte,
- static_cast<int32_t>(DSFid::CollectionTypeImpl),
- "ChunkedQueryResponse", partLen, isLastChunkWithSecurity);
+ auto objType = TcrMessageHelper::readChunkPartHeader(
+ m_msg, input, DSCode::FixedIDByte,
+ static_cast<int32_t>(DSFid::CollectionTypeImpl), "ChunkedQueryResponse",
+ partLen, isLastChunkWithSecurity);
if (objType == TcrMessageHelper::ChunkObjectType::EXCEPTION) {
// encountered an exception part, so return without reading more
m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
return;
} else if (objType == TcrMessageHelper::ChunkObjectType::NULL_OBJECT) {
// special case for scalar result
- partLen = input.readInt32();
- input.read();
+ input.readInt32(); // ignored part length
+ input.read(); // ignored is object
auto intVal = std::dynamic_pointer_cast<CacheableInt32>(input.readObject());
m_queryResults->push_back(intVal);
-
- // TODO:
m_msg.readSecureObjectPart(input, false, true, isLastChunkWithSecurity);
-
return;
}
@@ -3520,7 +3518,7 @@ void ChunkedQueryResponse::handleChunk(const uint8_t* chunk, int32_t chunkLen,
// skip the whole part including partLen and isObj (4+1)
input.advanceCursor(partLen + 5);
- partLen = input.readInt32();
+ input.readInt32(); // skip part length
if (!input.read()) {
LOGERROR(
@@ -3674,7 +3672,7 @@ void ChunkedFunctionExecutionResponse::handleChunk(
// Since it is contained as a part of other results, read arrayType which
// is arrayList = 65.
- int8_t ignored = input.read();
+ input.read();
// read and ignore its len which is 2
input.readArrayLength();
diff --git a/cppcache/src/Utils.cpp b/cppcache/src/Utils.cpp
index 671086f..d1a0bbe 100644
--- a/cppcache/src/Utils.cpp
+++ b/cppcache/src/Utils.cpp
@@ -30,12 +30,6 @@ namespace apache {
namespace geode {
namespace client {
-int RandGen::operator()(size_t max) {
- unsigned int seed = static_cast<unsigned int>(
- std::chrono::system_clock::now().time_since_epoch().count());
- return ACE_OS::rand_r(&seed) % max;
-}
-
int32_t Utils::getLastError() { return ACE_OS::last_error(); }
std::string Utils::getEnv(const char* varName) {
#ifdef _WIN32
@@ -104,7 +98,6 @@ std::string Utils::convertHostToCanonicalForm(const char* endpoints) {
endpointsStr = endpointsStr.substr(pos, length);
} else {
hostString = "";
- port = 0;
return "";
}
hostString = endpoint;
diff --git a/cppcache/src/Utils.hpp b/cppcache/src/Utils.hpp
index b81320d..ca7fd16 100644
--- a/cppcache/src/Utils.hpp
+++ b/cppcache/src/Utils.hpp
@@ -20,10 +20,6 @@
#ifndef GEODE_INTERNAL_UTILS_H_
#define GEODE_INTERNAL_UTILS_H_
-/**
- * @file
- */
-
#include <typeinfo>
#include <string>
#include <unordered_set>
@@ -33,6 +29,7 @@
#include <unordered_set>
#include <memory>
#include <chrono>
+#include <random>
#include <geode/internal/geode_globals.hpp>
#include <geode/internal/geode_base.hpp>
@@ -189,8 +186,19 @@ class APACHE_GEODE_EXPORT Utils {
// Generate random numbers 0 to max-1
class RandGen {
public:
- int operator()(size_t max);
+ template <typename T, class G = std::default_random_engine>
+ inline T operator()(T max) {
+ return std::uniform_int_distribution<T>{0, max - 1}(generator<G>());
+ }
+
+ private:
+ template <class G>
+ inline G& generator() {
+ static thread_local G generator(std::random_device{}());
+ return generator;
+ }
};
+
} // namespace client
} // namespace geode
} // namespace apache
diff --git a/cppcache/src/statistics/HostStatSampler.cpp b/cppcache/src/statistics/HostStatSampler.cpp
index e9f9c32..5aa7be6 100644
--- a/cppcache/src/statistics/HostStatSampler.cpp
+++ b/cppcache/src/statistics/HostStatSampler.cpp
@@ -19,6 +19,7 @@
#include <vector>
#include <chrono>
#include <thread>
+#include <exception>
#include <ace/ACE.h>
#include <ace/Thread_Mutex.h>
@@ -264,10 +265,6 @@ HostStatSampler::~HostStatSampler() {
delete m_samplerStats;
m_samplerStats = nullptr;
}
- if (m_archiver != nullptr) {
- delete m_archiver;
- m_archiver = nullptr;
- }
}
std::string HostStatSampler::createArchiveFileName() {
@@ -379,23 +376,9 @@ void HostStatSampler::changeArchive(std::string filename) {
m_archiver->closeFile();
}
// create new file only when tis file has some data; otherwise reuse it
- if (rollArchive(filename) != 0) {
- delete m_archiver;
- m_archiver = nullptr;
- // throw exception
- return;
- } else {
- /*
- if (m_archiver != nullptr) {
- m_archiver->openFile(filename);
- m_archiver->close();
- }
- */
- delete m_archiver;
- m_archiver = nullptr;
- }
+ rollArchive(filename);
- m_archiver = new StatArchiveWriter(filename, this, m_cache);
+ m_archiver.reset(new StatArchiveWriter(filename, this, m_cache));
}
std::string HostStatSampler::chkForGFSExt(std::string filename) {
@@ -703,7 +686,7 @@ int32_t HostStatSampler::svc(void) {
// createArchiveFileName instead of getArchiveFileName here because
// for the first time the sampler needs to add the pid to the filename
// passed to it.
- std::string archivefilename = createArchiveFileName();
+ auto archivefilename = createArchiveFileName();
if (!m_isStatDiskSpaceEnabled) {
changeArchive(archivefilename);
}
diff --git a/cppcache/src/statistics/HostStatSampler.hpp b/cppcache/src/statistics/HostStatSampler.hpp
index a6997b6..c4f83ef 100644
--- a/cppcache/src/statistics/HostStatSampler.hpp
+++ b/cppcache/src/statistics/HostStatSampler.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_STATISTICS_HOSTSTATSAMPLER_H_
-#define GEODE_STATISTICS_HOSTSTATSAMPLER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,9 +15,16 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_STATISTICS_HOSTSTATSAMPLER_H_
+#define GEODE_STATISTICS_HOSTSTATSAMPLER_H_
+
+
#include <string>
#include <vector>
#include <chrono>
+#include <memory>
#include <ace/Task.h>
#include <ace/Recursive_Thread_Mutex.h>
@@ -196,7 +198,7 @@ class APACHE_GEODE_EXPORT HostStatSampler : public ACE_Task_Base,
bool m_running;
bool m_stopRequested;
volatile bool m_isStatDiskSpaceEnabled;
- StatArchiveWriter* m_archiver;
+ std::unique_ptr<StatArchiveWriter> m_archiver;
StatSamplerStats* m_samplerStats;
const char* m_durableClientId;
std::chrono::seconds m_durableTimeout;
diff --git a/cppcache/test/ByteArray.cpp b/cppcache/test/ByteArray.cpp
index d134f24..3127f7b 100644
--- a/cppcache/test/ByteArray.cpp
+++ b/cppcache/test/ByteArray.cpp
@@ -22,19 +22,6 @@
#include <cstdlib> // For wcstombs()
#include <cstring>
-namespace {
-std::string convertWstringToString(const wchar_t* wstr) {
- if (wstr) {
- const std::size_t len = ::wcslen(wstr);
- char* dst = new char[len + 1];
- ::wcstombs(dst, wstr, len);
- delete[] dst;
- return dst;
- }
- return std::string();
-}
-} // namespace
-
namespace apache {
namespace geode {
namespace client {
@@ -70,9 +57,6 @@ ByteArray ByteArray::fromString(const std::string& str) {
return ba;
}
-ByteArray ByteArray::fromString(const wchar_t* wstr) {
- return fromString(convertWstringToString(wstr));
-}
std::string ByteArray::toString(const ByteArray& ba) {
std::string str;
diff --git a/cppcache/test/CacheableKeyCreateTests.cpp b/cppcache/test/CacheableKeyCreateTests.cpp
index 3457195..eac5aa7 100644
--- a/cppcache/test/CacheableKeyCreateTests.cpp
+++ b/cppcache/test/CacheableKeyCreateTests.cpp
@@ -46,8 +46,7 @@ TEST(CacheableKeyCreateTests, forArrayOf_constchar) {
}
TEST(CacheableKeyCreateTests, forArrayOf_char) {
- char* test = new char[10];
- strcpy(test, "test");
+ char* test = new char[5]{'t', 'e', 's', 't', '\0'};
const auto cacheableKey = CacheableKey::create(test);
ASSERT_TRUE(nullptr != cacheableKey);
auto&& cacheableString =
diff --git a/cppcache/test/SerializableCreateTests.cpp b/cppcache/test/SerializableCreateTests.cpp
index 7484198..f176743 100644
--- a/cppcache/test/SerializableCreateTests.cpp
+++ b/cppcache/test/SerializableCreateTests.cpp
@@ -44,9 +44,9 @@ TEST(SerializableCreateTests, forArrayOf_constchar) {
ASSERT_TRUE(nullptr != cacheableString);
ASSERT_EQ(cacheableString->value(), "test");
}
+
TEST(SerializableCreateTests, forArrayOf_char) {
- char* test = new char[10];
- strcpy(test, "test");
+ char* test = new char[5]{'t', 'e', 's', 't', '\0'};
const auto serializable = Serializable::create(test);
ASSERT_TRUE(nullptr != serializable);
auto&& cacheableString =
diff --git a/cryptoimpl/DHImpl.cpp b/cryptoimpl/DHImpl.cpp
index fe7e754..c4acbdb 100644
--- a/cryptoimpl/DHImpl.cpp
+++ b/cryptoimpl/DHImpl.cpp
@@ -17,6 +17,10 @@
#include "DHImpl.hpp"
+#include <cstring>
+#include <cctype>
+#include <memory>
+
#include <openssl/objects.h>
#include <openssl/stack.h>
#include <openssl/aes.h>
@@ -27,8 +31,6 @@
#include <openssl/pem.h>
#include <openssl/pkcs12.h>
#include <openssl/rsa.h>
-#include <cstring>
-#include <cctype>
#include <geode/internal/geode_globals.hpp>
@@ -351,8 +353,8 @@ unsigned char *gf_encryptDH(void *dhCtx, const unsigned char *cleartext,
LOGDH(" DH: gf_encryptDH using sk algo: %s, Keysize: %d",
dhimpl->m_skAlgo.c_str(), dhimpl->m_keySize);
- unsigned char *ciphertext =
- new unsigned char[len + 50]; // give enough room for padding
+ auto ciphertext = std::unique_ptr<unsigned char[]>(
+ new unsigned char[len + 50]); // give enough room for padding
int outlen, tmplen;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
@@ -375,7 +377,7 @@ unsigned char *gf_encryptDH(void *dhCtx, const unsigned char *cleartext,
dhimpl->m_key + 24);
}
- if (!EVP_EncryptUpdate(ctx, ciphertext, &outlen, cleartext, len)) {
+ if (!EVP_EncryptUpdate(ctx, ciphertext.get(), &outlen, cleartext, len)) {
LOGDH(" DHencrypt: enc update ret nullptr");
return nullptr;
}
@@ -384,7 +386,7 @@ unsigned char *gf_encryptDH(void *dhCtx, const unsigned char *cleartext,
*/
tmplen = 0;
- if (!EVP_EncryptFinal_ex(ctx, ciphertext + outlen, &tmplen)) {
+ if (!EVP_EncryptFinal_ex(ctx, ciphertext.get() + outlen, &tmplen)) {
LOGDH("DHencrypt: enc final ret nullptr");
return nullptr;
}
@@ -396,7 +398,7 @@ unsigned char *gf_encryptDH(void *dhCtx, const unsigned char *cleartext,
LOGDH("DHencrypt: in len is %d, out len is %d", len, outlen);
*retLen = outlen;
- return ciphertext;
+ return ciphertext.release();
}
unsigned char *gf_decryptDH(void *dhCtx, const unsigned char *cleartext,
@@ -411,8 +413,8 @@ unsigned char *gf_decryptDH(void *dhCtx, const unsigned char *cleartext,
LOGDH(" DH: gf_encryptDH using sk algo: %s, Keysize: %d",
dhimpl->m_skAlgo.c_str(), dhimpl->m_keySize);
- auto ciphertext =
- new unsigned char[len + 50]; // give enough room for padding
+ auto ciphertext = std::unique_ptr<unsigned char[]>(
+ new unsigned char[len + 50]); // give enough room for padding
int outlen, tmplen;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
@@ -435,7 +437,7 @@ unsigned char *gf_decryptDH(void *dhCtx, const unsigned char *cleartext,
dhimpl->m_key + 24);
}
- if (!EVP_DecryptUpdate(ctx, ciphertext, &outlen, cleartext, len)) {
+ if (!EVP_DecryptUpdate(ctx, ciphertext.get(), &outlen, cleartext, len)) {
LOGDH(" DHencrypt: enc update ret nullptr");
return nullptr;
}
@@ -444,7 +446,7 @@ unsigned char *gf_decryptDH(void *dhCtx, const unsigned char *cleartext,
*/
tmplen = 0;
- if (!EVP_DecryptFinal_ex(ctx, ciphertext + outlen, &tmplen)) {
+ if (!EVP_DecryptFinal_ex(ctx, ciphertext.get() + outlen, &tmplen)) {
LOGDH("DHencrypt: enc final ret nullptr");
return nullptr;
}
@@ -456,7 +458,7 @@ unsigned char *gf_decryptDH(void *dhCtx, const unsigned char *cleartext,
LOGDH("DHencrypt: in len is %d, out len is %d", len, outlen);
*retLen = outlen;
- return ciphertext;
+ return ciphertext.release();
}
// std::shared_ptr<CacheableBytes> decrypt(const uint8_t * ciphertext, int len)
diff --git a/dependencies/boost/CMakeLists.txt b/dependencies/boost/CMakeLists.txt
index 1fbe65a..2f6d7a8 100644
--- a/dependencies/boost/CMakeLists.txt
+++ b/dependencies/boost/CMakeLists.txt
@@ -4,9 +4,9 @@
# The ASF licenses this file to You 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.
@@ -15,8 +15,8 @@
project( boost LANGUAGES NONE )
-set( ${PROJECT_NAME}_VERSION 1.66.0 )
-set( ${PROJECT_NAME}_SHA265 bd0df411efd9a585e5a2212275f8762079fed8842264954675a4fddc46cfcf60 )
+set( ${PROJECT_NAME}_VERSION 1.68.0 )
+set( ${PROJECT_NAME}_SHA265 da3411ea45622579d419bfda66f45cd0f8c32a181d84adfa936f5688388995cf )
string(REPLACE "." "_" _VERSION_UNDERSCORE ${${PROJECT_NAME}_VERSION})
set( ${PROJECT_NAME}_URL "https://dl.bintray.com/boostorg/release/${${PROJECT_NAME}_VERSION}/source/boost_${_VERSION_UNDERSCORE}.tar.gz" )
set( ${PROJECT_NAME}_EXTERN ${PROJECT_NAME}-extern )
@@ -75,31 +75,26 @@ ExternalProject_Add( ${${PROJECT_NAME}_EXTERN}
STAMP_DIR ./stamp
)
-ExternalProject_Get_Property( ${${PROJECT_NAME}_EXTERN} SOURCE_DIR )
-set( ${PROJECT_NAME}_SOURCE_DIR ${SOURCE_DIR} )
-ExternalProject_Get_Property( ${${PROJECT_NAME}_EXTERN} INSTALL_DIR )
-set( ${PROJECT_NAME}_INSTALL_DIR ${INSTALL_DIR} )
-
-if ("SunOS" STREQUAL ${CMAKE_SYSTEM_NAME})
- #
- # Solaris patch is to workaround issue of dladdr function signature
- # mismatching the signature boost stacktrace expects. Following boost ticket
- # tracks this issue:
- #
- # https://svn.boost.org/trac10/ticket/13300#ticket
- #
- set( PATCH_FILE ${CMAKE_CURRENT_SOURCE_DIR}/solaris.patch )
+if (NOT WIN32)
+# https://github.com/boostorg/process/issues/51
+ set( PATCH_FILE ${CMAKE_CURRENT_SOURCE_DIR}/patches)
ExternalProject_Add_Step( ${${PROJECT_NAME}_EXTERN} patches
ALWAYS 0
DEPENDEES download
DEPENDERS patch
DEPENDS ${PATCH_FILE}
- WORKING_DIRECTORY ${${PROJECT_NAME}_SOURCE_DIR}
+ WORKING_DIRECTORY ${${PROJECT_NAME}_INSTALL_DIR}
COMMAND ${PATCH} -u -N -p1 < ${PATCH_FILE}
)
endif()
+ExternalProject_Get_Property( ${${PROJECT_NAME}_EXTERN} SOURCE_DIR )
+set( ${PROJECT_NAME}_SOURCE_DIR ${SOURCE_DIR} )
+ExternalProject_Get_Property( ${${PROJECT_NAME}_EXTERN} INSTALL_DIR )
+set( ${PROJECT_NAME}_INSTALL_DIR ${INSTALL_DIR} )
+
+
function(ADD_BOOST_LIBRARY)
set(options)
set(oneValueArgs)
diff --git a/dependencies/boost/patches b/dependencies/boost/patches
new file mode 100644
index 0000000..21bef7f
--- /dev/null
+++ b/dependencies/boost/patches
@@ -0,0 +1,16 @@
+--- a/src/boost/process/detail/posix/is_running.hpp
++++ b/src/boost/process/detail/posix/is_running.hpp
+@@ -16,8 +16,11 @@ namespace boost { namespace process { namespace detail { namespace posix {
+ // Use the "stopped" state (WIFSTOPPED) to indicate "not terminated".
+ // This bit arrangement of status codes is not guaranteed by POSIX, but (according to comments in
+ // the glibc <bits/waitstatus.h> header) is the same across systems in practice.
+-constexpr int still_active = 0x7F;
+-static_assert(!WIFEXITED(still_active) && !WIFSIGNALED(still_active), "Internal Error");
++constexpr int still_active = 0x017f;
++static_assert(WIFSTOPPED(still_active), "Expected still_active to indicate WIFSTOPPED");
++static_assert(!WIFEXITED(still_active), "Expected still_active to not indicate WIFEXITED");
++static_assert(!WIFSIGNALED(still_active), "Expected still_active to not indicate WIFSIGNALED");
++static_assert(!WIFCONTINUED(still_active), "Expected still_active to not indicate WIFCONTINUED");
+
+ inline bool is_running(int code)
+ {
diff --git a/dependencies/boost/solaris.patch b/dependencies/boost/solaris.patch
deleted file mode 100644
index d8a631b..0000000
--- a/dependencies/boost/solaris.patch
+++ /dev/null
@@ -1,25 +0,0 @@
-diff -ru a/boost/stacktrace/detail/frame_unwind.ipp b/boost/stacktrace/detail/frame_unwind.ipp
---- a/boost/stacktrace/detail/frame_unwind.ipp Sat Aug 19 16:49:49 2017
-+++ b/boost/stacktrace/detail/frame_unwind.ipp Fri Sep 15 20:12:08 2017
-@@ -84,7 +84,7 @@
- std::string frame::name() const {
- #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
- ::Dl_info dli;
-- const bool dl_ok = !!::dladdr(addr_, &dli);
-+ const bool dl_ok = !!::dladdr(const_cast<void *>(addr_), &dli);
- if (dl_ok && dli.dli_sname) {
- return boost::core::demangle(dli.dli_sname);
- }
-diff -ru a/boost/stacktrace/detail/location_from_symbol.hpp b/boost/stacktrace/detail/location_from_symbol.hpp
---- a/boost/stacktrace/detail/location_from_symbol.hpp Sat Aug 19 16:49:49 2017
-+++ b/boost/stacktrace/detail/location_from_symbol.hpp Fri Sep 15 20:12:51 2017
-@@ -28,7 +28,7 @@
- explicit location_from_symbol(const void* addr) BOOST_NOEXCEPT
- : dli_()
- {
-- if (!::dladdr(addr, &dli_)) {
-+ if (!::dladdr(const_cast<void *>(addr), &dli_)) {
- dli_.dli_fname = 0;
- }
- }
-
diff --git a/dhimpl/DHImpl.cpp b/dhimpl/DHImpl.cpp
index 8e5e4b3..beed2d9 100644
--- a/dhimpl/DHImpl.cpp
+++ b/dhimpl/DHImpl.cpp
@@ -17,6 +17,11 @@
#include "DHImpl.hpp"
+#include <cstring>
+#include <cctype>
+#include <cstdint>
+#include <memory>
+
#include <openssl/objects.h>
#include <openssl/stack.h>
#include <openssl/aes.h>
@@ -27,9 +32,6 @@
#include <openssl/pem.h>
#include <openssl/pkcs12.h>
#include <openssl/rsa.h>
-#include <cstring>
-#include <cctype>
-#include <cstdint>
static DH *m_dh = nullptr;
static std::string m_skAlgo;
@@ -322,8 +324,8 @@ unsigned char *gf_encryptDH(const unsigned char *cleartext, int len,
LOGDH(" DH: gf_encryptDH using sk algo: %s, Keysize: %d", m_skAlgo.c_str(),
m_keySize);
- unsigned char *ciphertext =
- new unsigned char[len + 50]; // give enough room for padding
+ auto ciphertext = std::unique_ptr<unsigned char[]>(
+ new unsigned char[len + 50]); // give enough room for padding
int outlen, tmplen;
auto ctx = EVP_CIPHER_CTX_new();
@@ -343,7 +345,7 @@ unsigned char *gf_encryptDH(const unsigned char *cleartext, int len,
EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, m_key, m_key + 24);
}
- if (!EVP_EncryptUpdate(ctx, ciphertext, &outlen, cleartext, len)) {
+ if (!EVP_EncryptUpdate(ctx, ciphertext.get(), &outlen, cleartext, len)) {
LOGDH(" DHencrypt: enc update ret nullptr");
return nullptr;
}
@@ -352,7 +354,7 @@ unsigned char *gf_encryptDH(const unsigned char *cleartext, int len,
*/
tmplen = 0;
- if (!EVP_EncryptFinal_ex(ctx, ciphertext + outlen, &tmplen)) {
+ if (!EVP_EncryptFinal_ex(ctx, ciphertext.get() + outlen, &tmplen)) {
LOGDH("DHencrypt: enc final ret nullptr");
return nullptr;
}
@@ -364,7 +366,7 @@ unsigned char *gf_encryptDH(const unsigned char *cleartext, int len,
LOGDH("DHencrypt: in len is %d, out len is %d", len, outlen);
*retLen = outlen;
- return ciphertext;
+ return ciphertext.release();
}
// std::shared_ptr<CacheableBytes> decrypt(const uint8_t * ciphertext, int
@@ -545,8 +547,7 @@ EVP_PKEY *DH_PUBKEY_get(DH_PUBKEY *key) {
ASN1_INTEGER *asn1int = nullptr;
if (key == nullptr) {
- EVP_PKEY_up_ref(key->pkey);
- return (key->pkey);
+ return (nullptr);
}
if (key->pkey != nullptr) {
diff --git a/tests/cpp/fwklib/FwkLog.cpp b/tests/cpp/fwklib/FwkLog.cpp
index 170a75c..2ccdf05 100644
--- a/tests/cpp/fwklib/FwkLog.cpp
+++ b/tests/cpp/fwklib/FwkLog.cpp
@@ -67,7 +67,7 @@ void plog(const char* l, const char* s, const char* filename, int32_t lineno) {
pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val);
pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRId64 " ",
static_cast<int64_t>(clock.usec()));
- pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
+ ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
static bool needInit = true;
if (needInit) {
ACE_OS::uname(&u);
diff --git a/tests/cpp/fwklib/IpcHandler.cpp b/tests/cpp/fwklib/IpcHandler.cpp
index 43d19c6..6b09fca 100644
--- a/tests/cpp/fwklib/IpcHandler.cpp
+++ b/tests/cpp/fwklib/IpcHandler.cpp
@@ -243,7 +243,7 @@ bool IpcHandler::sendBuffer(IpcMsg msg, const char *str) {
char *buffer = checkBuffer(length);
*reinterpret_cast<IpcMsg *>(buffer) = static_cast<IpcMsg>(htonl(msg));
*reinterpret_cast<int32_t *>(buffer + 4) = htonl(length);
- strcpy((buffer + 8), str);
+ strncpy((buffer + 8), str, length - 8);
// FWKDEBUG( "Sending " << ( int32_t )msg << " and string: " << str );
length += 8;
diff --git a/tests/cpp/security/PkcsAuthInit.cpp b/tests/cpp/security/PkcsAuthInit.cpp
index 1407b44..7f3548c 100644
--- a/tests/cpp/security/PkcsAuthInit.cpp
+++ b/tests/cpp/security/PkcsAuthInit.cpp
@@ -69,13 +69,13 @@ uint8_t* createSignature(EVP_PKEY* key, X509* cert,
X509_ALGOR_get0(&macobj, nullptr, nullptr, algorithm);
const EVP_MD* signatureDigest = EVP_get_digestbyobj(macobj);
EVP_MD_CTX* signatureCtx = EVP_MD_CTX_new();
- uint8_t* signatureData = new uint8_t[EVP_PKEY_size(key)];
+ auto signatureData = std::unique_ptr<uint8_t[]>(new uint8_t[EVP_PKEY_size(key)]);
bool result = (EVP_SignInit_ex(signatureCtx, signatureDigest, nullptr) &&
EVP_SignUpdate(signatureCtx, inputBuffer, inputBufferLen) &&
- EVP_SignFinal(signatureCtx, signatureData, signatureLen, key));
+ EVP_SignFinal(signatureCtx, signatureData.get(), signatureLen, key));
EVP_MD_CTX_free(signatureCtx);
if (result) {
- return signatureData;
+ return signatureData.release();
}
return nullptr;
}
@@ -183,9 +183,9 @@ std::shared_ptr<Properties> PKCSAuthInitInternal::getCredentials(
fclose(keyStoreFP);
unsigned int lengthEncryptedData = 0;
- uint8_t* signatureData = createSignature(
+ auto signatureData = std::unique_ptr<uint8_t[]>(createSignature(
privateKey, cert, reinterpret_cast<const unsigned char*>(alias),
- static_cast<uint32_t>(strlen(alias)), &lengthEncryptedData);
+ static_cast<uint32_t>(strlen(alias)), &lengthEncryptedData));
EVP_PKEY_free(privateKey);
X509_free(cert);
if (!signatureData) {
@@ -197,12 +197,12 @@ std::shared_ptr<Properties> PKCSAuthInitInternal::getCredentials(
if (m_stringCredentials) {
// convert signature bytes to base64
signatureValPtr =
- convertBytesToString(signatureData, lengthEncryptedData, 2048);
+ convertBytesToString(signatureData.get(), lengthEncryptedData, 2048);
LOGINFO(" Converting CREDS to STRING: %s",
signatureValPtr->toString().c_str());
} else {
signatureValPtr = CacheableBytes::create(std::vector<int8_t>(
- signatureData, signatureData + lengthEncryptedData));
+ signatureData.get(), signatureData.get() + lengthEncryptedData));
LOGINFO(" Converting CREDS to BYTES: %s",
signatureValPtr->toString().c_str());
}
diff --git a/tests/cpp/security/PkcsCredentialGenerator.hpp b/tests/cpp/security/PkcsCredentialGenerator.hpp
index 2e86ed3..efb3717 100644
--- a/tests/cpp/security/PkcsCredentialGenerator.hpp
+++ b/tests/cpp/security/PkcsCredentialGenerator.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_SECURITY_PKCSCREDENTIALGENERATOR_H_
-#define GEODE_SECURITY_PKCSCREDENTIALGENERATOR_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -20,6 +15,13 @@
* limitations under the License.
*/
+#pragma once
+
+#ifndef GEODE_SECURITY_PKCSCREDENTIALGENERATOR_H_
+#define GEODE_SECURITY_PKCSCREDENTIALGENERATOR_H_
+
+#include <random>
+
#include "CredentialGenerator.hpp"
#include "XmlAuthzCredentialGenerator.hpp"
@@ -37,6 +39,13 @@ namespace client {
namespace testframework {
namespace security {
+template <typename T>
+T randomValue(T minValue, T maxValue) {
+ static thread_local std::default_random_engine generator(
+ std::random_device{}());
+ return std::uniform_int_distribution<T>{minValue, maxValue}(generator);
+}
+
class PKCSCredentialGenerator : public CredentialGenerator {
public:
PKCSCredentialGenerator() : CredentialGenerator(ID_PKI, "PKCS"){};
@@ -57,10 +66,9 @@ class PKCSCredentialGenerator : public CredentialGenerator {
}
char* authzXmlUri = ACE_OS::getenv("AUTHZ_XML_URI");
- additionalArgs =
- std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
- std::string(workingDir) +
- std::string(authzXmlUri ? authzXmlUri : "authz-pkcs.xml");
+ additionalArgs = std::string(" --J=-Dgemfire.security-authz-xml-uri=") +
+ std::string(workingDir) +
+ std::string(authzXmlUri ? authzXmlUri : "authz-pkcs.xml");
return additionalArgs;
}
@@ -111,7 +119,7 @@ class PKCSCredentialGenerator : public CredentialGenerator {
void getValidCredentials(std::shared_ptr<Properties>& p) override {
char username[20] = {'\0'};
- sprintf(username, "geode%d", (rand() % 10) + 1);
+ sprintf(username, "geode%d", randomValue(1, 10));
setPKCSProperties(p, username);
FWKINFO("inserted valid security-username "
<< p->find("security-username")->value().c_str());
@@ -119,7 +127,7 @@ class PKCSCredentialGenerator : public CredentialGenerator {
void getInvalidCredentials(std::shared_ptr<Properties>& p) override {
char username[20] = {'\0'};
- sprintf(username, "%dgeode", (rand() % 11) + 1);
+ sprintf(username, "%dgeode", randomValue(1, 11));
setPKCSProperties(p, username);
FWKINFO("inserted invalid security-username "
<< p->find("security-username")->value().c_str());
@@ -134,9 +142,9 @@ class PKCSCredentialGenerator : public CredentialGenerator {
insertKeyStorePath(p, username);
}
- void getDisallowedCredentialsForOps(opCodeList& opCodes,
- std::shared_ptr<Properties>& p,
- stringList* regionNames = nullptr) override {
+ void getDisallowedCredentialsForOps(
+ opCodeList& opCodes, std::shared_ptr<Properties>& p,
+ stringList* regionNames = nullptr) override {
XmlAuthzCredentialGenerator authz(id());
authz.getDisallowedCredentials(opCodes, p, regionNames);
const char* username = p->find("security-alias")->value().c_str();
diff --git a/tests/cpp/security/XmlAuthzCredentialGenerator.hpp b/tests/cpp/security/XmlAuthzCredentialGenerator.hpp
index a123fb0..1a0f0de 100644
--- a/tests/cpp/security/XmlAuthzCredentialGenerator.hpp
+++ b/tests/cpp/security/XmlAuthzCredentialGenerator.hpp
@@ -23,6 +23,7 @@
#include <algorithm>
#include <ctime>
#include <cstdlib>
+#include <random>
#include <geode/Properties.hpp>
#include <geode/CacheableString.hpp>
@@ -35,6 +36,13 @@ namespace client {
namespace testframework {
namespace security {
+template <typename T>
+T randomValue(T maxValue) {
+ static thread_local std::default_random_engine generator(
+ std::random_device{}());
+ return std::uniform_int_distribution<T>{0, maxValue}(generator);
+}
+
const opCodeList::value_type RArr[] = {
OP_GET, OP_GETALL, OP_REGISTER_INTEREST, OP_UNREGISTER_INTEREST,
OP_KEY_SET, OP_CONTAINS_KEY};
@@ -124,12 +132,16 @@ class XmlAuthzCredentialGenerator {
switch (role) {
case READER_ROLE:
role = WRITER_ROLE;
+ break;
case WRITER_ROLE:
role = READER_ROLE;
+ break;
case QUERY_ROLE:
role = WRITER_ROLE;
+ break;
case ADMIN_ROLE:
role = QUERY_ROLE;
+ break;
default:
/* UNNECESSARY role = role*/ break;
};
@@ -168,19 +180,19 @@ class XmlAuthzCredentialGenerator {
char userName[100];
switch (role) {
case READER_ROLE:
- sprintf(userName, PRiUsnm, "reader", rand() % 3);
+ sprintf(userName, PRiUsnm, "reader", randomValue(2));
break;
case WRITER_ROLE:
- sprintf(userName, PRiUsnm, "writer", rand() % 3);
+ sprintf(userName, PRiUsnm, "writer", randomValue(2));
break;
case QUERY_ROLE:
- sprintf(userName, PRiUsnm, "reader", (rand() % 2) + 3);
+ sprintf(userName, PRiUsnm, "reader", randomValue(1) + 3);
break;
case ADMIN_ROLE:
- sprintf(userName, "%s", adminUsers[rand() % adminUsrSz]);
+ sprintf(userName, "%s", adminUsers[randomValue(adminUsrSz)]);
break;
default:
- sprintf(userName, PRiUsnm, "user", rand() % 3);
+ sprintf(userName, PRiUsnm, "user", randomValue(2));
break;
};
@@ -217,20 +229,20 @@ class XmlAuthzCredentialGenerator {
switch (role) {
case READER_ROLE:
sprintf(userName, PRiUsnm, userPrefix.c_str(),
- readerIndices[rand() % readerIndSz]);
+ readerIndices[randomValue(readerIndSz)]);
break;
case WRITER_ROLE:
sprintf(userName, PRiUsnm, userPrefix.c_str(),
- writerIndices[rand() % writerIndSz]);
+ writerIndices[randomValue(writerIndSz)]);
break;
case QUERY_ROLE:
sprintf(userName, PRiUsnm, userPrefix.c_str(),
- queryIndices[rand() % queryIndSz]);
+ queryIndices[randomValue(queryIndSz)]);
break;
case ADMIN_ROLE:
default:
sprintf(userName, PRiUsnm, userPrefix.c_str(),
- adminIndices[rand() % adminIndSz]);
+ adminIndices[randomValue(adminIndSz)]);
break;
};
FWKINFO("inserted " << validity << " username " << userName);
diff --git a/tests/cpp/testobject/DeltaFastAssetAccount.hpp b/tests/cpp/testobject/DeltaFastAssetAccount.hpp
index 023aaad..6ef47b8 100644
--- a/tests/cpp/testobject/DeltaFastAssetAccount.hpp
+++ b/tests/cpp/testobject/DeltaFastAssetAccount.hpp
@@ -136,7 +136,7 @@ class TESTOBJECT_EXPORT DeltaFastAssetAccount : public DataSerializable,
auto asset = std::dynamic_pointer_cast<FastAsset>(item.second);
clonePtr->assets->emplace(key, asset->copy());
}
- return clonePtr;
+ return std::move(clonePtr);
}
static apache::geode::client::Serializable* createDeserializable() {
diff --git a/tests/cpp/testobject/PdxClassV1.hpp b/tests/cpp/testobject/PdxClassV1.hpp
index 43f5de2..1f0eff1 100644
--- a/tests/cpp/testobject/PdxClassV1.hpp
+++ b/tests/cpp/testobject/PdxClassV1.hpp
@@ -435,7 +435,7 @@ class TestPdxSerializerForV1 : public PdxSerializer {
try {
auto tkv1 = std::make_shared<PdxTests::TestKeyV1>();
tkv1->_id = pr.readString("_id");
- return tkv1;
+ return std::move(tkv1);
} catch (...) {
return nullptr;
}
@@ -459,7 +459,7 @@ class TestPdxSerializerForV1 : public PdxSerializer {
auto dtpv1 = std::make_shared<PdxTests::TestDiffTypePdxSV1>();
dtpv1->_id = pr.readString("_id");
dtpv1->_name = pr.readString("_name");
- return dtpv1;
+ return std::move(dtpv1);
} catch (...) {
return nullptr;
}
diff --git a/tests/cpp/testobject/PdxClassV2.hpp b/tests/cpp/testobject/PdxClassV2.hpp
index 3c10180..0caf020 100644
--- a/tests/cpp/testobject/PdxClassV2.hpp
+++ b/tests/cpp/testobject/PdxClassV2.hpp
@@ -463,7 +463,7 @@ class TestPdxSerializerForV2 : public PdxSerializer {
try {
auto tkv1 = std::shared_ptr<PdxTests::TestKeyV2>();
tkv1->_id = pr.readString("_id");
- return tkv1;
+ return std::move(tkv1);
} catch (...) {
return nullptr;
}
@@ -488,7 +488,7 @@ class TestPdxSerializerForV2 : public PdxSerializer {
dtpv1->_id = pr.readString("_id");
dtpv1->_name = pr.readString("_name");
dtpv1->_count = pr.readInt("_count");
- return dtpv1;
+ return std::move(dtpv1);
} catch (...) {
return nullptr;
}
diff --git a/tests/cpp/testobject/TestObject1.cpp b/tests/cpp/testobject/TestObject1.cpp
index 364f906..571ec58 100644
--- a/tests/cpp/testobject/TestObject1.cpp
+++ b/tests/cpp/testobject/TestObject1.cpp
@@ -58,7 +58,7 @@ void TestObject1::fromData(DataInput& input) {
int32_t len;
input.readBytes(&bytes, &len);
arr = CacheableBytes::create(std::vector<int8_t>(bytes, bytes + len));
- delete bytes;
+ delete[] bytes;
name = std::dynamic_pointer_cast<CacheableString>(input.readObject());
identifier = input.readInt32();
}
[geode-native] 03/03: GEODE-5839: Fixes explicit constructor
definition.
Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git
commit cdcb703ed46e06318a074c90f137842c739ef5ae
Author: Jacob Barrett <jb...@pivotal.io>
AuthorDate: Tue Oct 9 13:34:07 2018 -0700
GEODE-5839: Fixes explicit constructor definition.
* Cleanup .clang-tidy files.
---
.clang-tidy | 2 +-
cppcache/include/geode/internal/CacheableBuiltinTemplates.hpp | 2 +-
cppcache/integration-test-2/framework/.clang-tidy | 6 ++++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 0968e48..6d39ded 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,6 +1,6 @@
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-optin.cplusplus.VirtualCall'
-WarningsAsErrors: 'clang-analyzer-optin.performance.*,clang-analyzer-core.*,clang-analyzer-unix.*,clang-diagnostic-*,google-*,clang-analyzer-cplusplus.*,clang-analyzer-security.insecureAPI.*,clang-analyzer-deadcode.*'
+WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
FormatStyle: file
...
diff --git a/cppcache/include/geode/internal/CacheableBuiltinTemplates.hpp b/cppcache/include/geode/internal/CacheableBuiltinTemplates.hpp
index 792687d..fb50a9f 100644
--- a/cppcache/include/geode/internal/CacheableBuiltinTemplates.hpp
+++ b/cppcache/include/geode/internal/CacheableBuiltinTemplates.hpp
@@ -120,7 +120,7 @@ class APACHE_GEODE_EXPORT CacheableArrayPrimitive
inline CacheableArrayPrimitive() = default;
template <typename TT>
- CacheableArrayPrimitive(TT&& value) : m_value(std::forward<TT>(value)) {}
+ explicit CacheableArrayPrimitive(TT&& value) : m_value(std::forward<TT>(value)) {}
~CacheableArrayPrimitive() noexcept override = default;
diff --git a/cppcache/integration-test-2/framework/.clang-tidy b/cppcache/integration-test-2/framework/.clang-tidy
index 07eb839..1c4ed27 100644
--- a/cppcache/integration-test-2/framework/.clang-tidy
+++ b/cppcache/integration-test-2/framework/.clang-tidy
@@ -1,12 +1,14 @@
---
-Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-clang-analyzer-unix.cstring.NullArg'
-WarningsAsErrors: '*,-google-default-arguments'
+Checks: '-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments,-clang-analyzer-unix.cstring.NullArg'
+WarningsAsErrors: '*'
HeaderFilterRegex: '.*'
FormatStyle: file
+...
# Disable Checks
# google-runtime-references - We have diverged from this rule due to both legacy and disagreement with the rule.
# google-readability-todo - Adds current user name when fix applied.
# TODO - Fix these checks
+# google-default-arguments
# clang-analyzer-unix.cstring.NullArg - Generates errors in Boost, how do we ignore?