This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new 3718e22d Ignore character case in loaded option names in the next ABI 
version (#702)
3718e22d is described below

commit 3718e22da5d277da8789e0ef27654f2f303156ad
Author: Stephen Webb <[email protected]>
AuthorDate: Wed Jun 3 11:56:28 2026 +1000

    Ignore character case in loaded option names in the next ABI version (#702)
    
    * Fix flaky thread name test
---
 src/main/cpp/properties.cpp                    | 18 ++++++++++++++++++
 src/main/include/log4cxx/helpers/properties.h  |  7 ++++++-
 src/test/cpp/helpers/propertiestestcase.cpp    | 15 +++++++++++++++
 src/test/cpp/helpers/threadutilitytestcase.cpp |  2 ++
 4 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/src/main/cpp/properties.cpp b/src/main/cpp/properties.cpp
index 893f186c..68dd8390 100644
--- a/src/main/cpp/properties.cpp
+++ b/src/main/cpp/properties.cpp
@@ -20,10 +20,28 @@
 #include <log4cxx/helpers/inputstreamreader.h>
 #include <log4cxx/helpers/exception.h>
 #include <log4cxx/helpers/pool.h>
+#include <cctype>
+#include <algorithm>
 
 using namespace LOG4CXX_NS;
 using namespace LOG4CXX_NS::helpers;
 
+template <typename Char>
+struct Properties::Less
+{
+       bool operator()(const std::basic_string<Char>& str1, const 
std::basic_string<Char>& str2) const
+       {
+               return std::lexicographical_compare
+                       ( str1.begin(), str1.end()
+                       , str2.begin(), str2.end()
+                       , [](Char c1, Char c2)
+                               {
+                                       return 
std::tolower(static_cast<unsigned char>(c1)) < 
std::tolower(static_cast<unsigned char>(c2));
+                               }
+                       );
+       }
+};
+
 class PropertyParser
 {
        public:
diff --git a/src/main/include/log4cxx/helpers/properties.h 
b/src/main/include/log4cxx/helpers/properties.h
index 1481d2cc..2a82ad29 100644
--- a/src/main/include/log4cxx/helpers/properties.h
+++ b/src/main/include/log4cxx/helpers/properties.h
@@ -32,7 +32,12 @@ namespace helpers
 class LOG4CXX_EXPORT Properties
 {
        private:
-               typedef std::map<LogString, LogString> PropertyMap;
+               template <typename Char> struct Less;
+#if LOG4CXX_ABI_VERSION < 15
+               using PropertyMap = std::map<LogString, LogString>;
+#else
+               using PropertyMap = std::map<LogString, LogString, 
Less<logchar> >;
+#endif
                PropertyMap* properties;
 
        public: // ...structors
diff --git a/src/test/cpp/helpers/propertiestestcase.cpp 
b/src/test/cpp/helpers/propertiestestcase.cpp
index 315b6c8e..9a53f59d 100644
--- a/src/test/cpp/helpers/propertiestestcase.cpp
+++ b/src/test/cpp/helpers/propertiestestcase.cpp
@@ -44,6 +44,7 @@ LOGUNIT_CLASS(PropertiesTestCase)
        LOGUNIT_TEST(testCRLF);
        LOGUNIT_TEST(testLF);
        LOGUNIT_TEST(testMixedLineEndings);
+       LOGUNIT_TEST(testCaseSensitivity);
        LOGUNIT_TEST_SUITE_END();
 
 public:
@@ -295,6 +296,20 @@ public:
                LOGUNIT_ASSERT_EQUAL(LogString(LOG4CXX_STR("some_value")), 
value3);
        }
 
+       void testCaseSensitivity(){
+               Properties properties;
+               properties.setProperty(LOG4CXX_STR("key"), 
LOG4CXX_STR("value1"));
+               properties.setProperty(LOG4CXX_STR("Key"), 
LOG4CXX_STR("value2"));
+               auto keys = properties.propertyNames();
+               auto keyCount = static_cast<int>(keys.size());
+#if LOG4CXX_ABI_VERSION < 15
+               LOGUNIT_ASSERT_EQUAL(keyCount, 2);
+#else
+               LOGUNIT_ASSERT_EQUAL(keyCount, 1);
+               LOGUNIT_ASSERT_EQUAL(properties.get(LOG4CXX_STR("key")), 
LOG4CXX_STR("value2"));
+#endif
+       }
+
 };
 
 
diff --git a/src/test/cpp/helpers/threadutilitytestcase.cpp 
b/src/test/cpp/helpers/threadutilitytestcase.cpp
index d89d2a3b..32e1e119 100644
--- a/src/test/cpp/helpers/threadutilitytestcase.cpp
+++ b/src/test/cpp/helpers/threadutilitytestcase.cpp
@@ -163,6 +163,8 @@ public:
                auto logger = LogManager::getRootLogger();
                logger->addAppender(appender);
                std::thread t = ThreadUtility::instance()->createThread( 
LOG4CXX_STR("FooName"), [logger]() {
+                       // wait 30 ms for thread name change to be effected
+                       
std::this_thread::sleep_for(std::chrono::milliseconds(30));
                        LOG4CXX_DEBUG(logger, "Test message");
                });
                t.join();

Reply via email to