(celix) branch feature/dfi-cleanup updated (ba398d32 -> 86249373)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch feature/dfi-cleanup in repository https://gitbox.apache.org/repos/asf/celix.git from ba398d32 Remove unnecessary calloc and fix crash caused by pointer reference in jsonRpc_call. add 797e9755 Add some type checking to dyn_function. add 86249373 Update codecov-action. No new revisions were added by this update. Summary of changes: .github/workflows/coverage.yml| 4 ++-- libs/dfi/gtest/src/dyn_function_tests.cpp | 10 ++ libs/dfi/src/dyn_function.c | 5 + 3 files changed, 17 insertions(+), 2 deletions(-)
(celix) branch feature/674-improve-properties updated (96019472 -> 4841034b)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git from 96019472 Update CHANGES.md add 4841034b Update codecov-action. No new revisions were added by this update. Summary of changes: .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
(celix) branch hotfix/codecov-fix deleted (was 9b4501d2)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch hotfix/codecov-fix in repository https://gitbox.apache.org/repos/asf/celix.git was 9b4501d2 Update codecov-action. The revisions that were on this branch are still contained in other references; therefore, this change does not discard any commits from the repository.
(celix) branch master updated (5afee1eb -> 29fa7d0f)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/celix.git from 5afee1eb Merge pull request #720 from apache/hotfix/ci-build add 9b4501d2 Update codecov-action. new 29fa7d0f Merge pull request #722 from apache/hotfix/codecov-fix The 1 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: .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
(celix) 01/01: Merge pull request #722 from apache/hotfix/codecov-fix
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/celix.git commit 29fa7d0f7f15ffb7e5fcbc08cc4319894452f094 Merge: 5afee1eb 9b4501d2 Author: PengZheng AuthorDate: Tue Jan 23 13:35:43 2024 +0800 Merge pull request #722 from apache/hotfix/codecov-fix Update codecov-action. .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
(celix) 01/01: Update codecov-action.
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch hotfix/codecov-fix in repository https://gitbox.apache.org/repos/asf/celix.git commit 9b4501d2b14c473023b10bbe68bd98de45a8517e Author: PengZheng AuthorDate: Tue Jan 23 13:26:35 2024 +0800 Update codecov-action. --- .github/workflows/coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 76601a2e..be94b289 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -67,7 +67,7 @@ jobs: source deactivate_conanrun.sh lcx="lcov --output-file=coverage.info " && for i in `find . -name "*.info.cleaned"`; do lcx+=" --add-tracefile=$i"; done && $lcx - name: Codecov -uses: codecov/codecov-action@e156083f13aff6830c92fc5faa23505779fbf649 +uses: codecov/codecov-action@v3 with: - file: build/coverage.info + files: build/coverage.info name: codecov-celix
(celix) branch hotfix/codecov-fix created (now 9b4501d2)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch hotfix/codecov-fix in repository https://gitbox.apache.org/repos/asf/celix.git at 9b4501d2 Update codecov-action. This branch includes the following new commits: new 9b4501d2 Update codecov-action. The 1 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.
(celix) 01/02: Update NOTICE (2019->2024)
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit 234ccc06d3ae7c40a3e8e65d3a32433fe362d61e Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:58:05 2024 +0100 Update NOTICE (2019->2024) --- NOTICE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NOTICE b/NOTICE index ffb146db..2695bd0a 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ Apache Celix -Copyright [2010-2019] The Apache Software Foundation +Copyright [2010-2024] The Apache Software Foundation This product includes software developed at The Apache Software Foundation (http://www.apache.org/).
(celix) branch feature/674-improve-properties updated (e2373dfa -> 96019472)
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a change to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git from e2373dfa Fix memleak in properties setStrings and setVersions new 234ccc06 Update NOTICE (2019->2024) new 96019472 Update CHANGES.md The 2 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: CHANGES.md | 4 +++- NOTICE | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-)
(celix) 02/02: Update CHANGES.md
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit 96019472ba6985144ab0074753ea547cf427f6a5 Author: Pepijn Noltes AuthorDate: Mon Jan 22 20:00:32 2024 +0100 Update CHANGES.md --- CHANGES.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 4dd00c48..4b42b913 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -58,10 +58,12 @@ limitations under the License. - linked_list.h is removed and no longer supported. Use celix_array_list.h instead. - ip_utils.h is removed and no longer supported. - array_list.h is removed and no longer supported. Use celix_array_list.h instead. +- Apache Celix filter now use the underlying properties value types for matching. This means that it is more important + to add service properties with the correct type. ## New Features -- Basic type support for value in celix Properties. +- Type support for value in celix Properties, including support for arrays. # Noteworthy Changes for 2.4.0 (2023-09-27)
(celix) 03/03: Fix memleak in properties setStrings and setVersions
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit e2373dfa0cd023ef9e6a9828339fc78eb716a0f9 Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:56:37 2024 +0100 Fix memleak in properties setStrings and setVersions --- libs/utils/src/properties.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c index 1fd9753e..b478bf7d 100644 --- a/libs/utils/src/properties.c +++ b/libs/utils/src/properties.c @@ -1223,6 +1223,7 @@ celix_properties_setStrings(celix_properties_t* properties, const char* key, con celix_status_t status = celix_arrayList_addString(list, copy); if (status != CELIX_SUCCESS) { celix_err_push("Failed to add string to array list"); +free(copy); return status; } } @@ -1354,6 +1355,7 @@ celix_properties_setVersions(celix_properties_t* properties, const char* key, co celix_status_t status = celix_arrayList_add(list, copy); if (status != CELIX_SUCCESS) { celix_err_push("Failed to add version to array list"); +celix_version_destroy(copy); return status; } }
(celix) branch feature/674-improve-properties updated (7047b644 -> e2373dfa)
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a change to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git from 7047b644 Add properties and filter introduction documentation add 2070f583 [CID 339894]Remove dead code. add 41aad66a Merge pull request #716 from apache/hotfix/coverity add 7e050ed1 container: Remove incorrect comment in Gitpod container add 2fa08300 container: Rename 'start' script to 'run' script add 99e9b7b0 container: Update README to advise using 'build' directory add 171db15e container: Fix variable globbing in run script add d99179a7 container: Add container build workflow add a800c426 Merge pull request #717 from apache/feature/add-build-job-for-dev-container add 86db9e4e Upgrade to conan 1.62. add 62b42f2a Remove unnecessary find_dependency from CelixDeps.cmake.in. add 5afee1eb Merge pull request #720 from apache/hotfix/ci-build new e448d007 Merge branch 'master' into feature/674-improve-properties new dbfb90d7 Add additional properties ei tests new e2373dfa Fix memleak in properties setStrings and setVersions 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: .github/workflows/containers.yml | 38 +++ .github/workflows/coverage.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- cmake/CelixDeps.cmake.in | 1 - container/Containerfile.gitpod | 3 - container/README.md| 11 +-- container/build-ubuntu-container.sh| 1 - ...ubuntu-container.sh => run-ubuntu-container.sh} | 3 +- container/support-scripts/build-all.sh | 1 - libs/framework/src/service_registry.c | 37 +++ .../error_injector/celix_array_list/CMakeLists.txt | 1 + .../celix_array_list/include/celix_array_list_ei.h | 2 + .../celix_array_list/src/celix_array_list_ei.cc| 7 ++ .../gtest/src/PropertiesErrorInjectionTestSuite.cc | 109 + libs/utils/src/properties.c| 2 + 15 files changed, 182 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/containers.yml rename container/{start-ubuntu-container.sh => run-ubuntu-container.sh} (96%)
(celix) 01/03: Merge branch 'master' into feature/674-improve-properties
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit e448d007c6f94515262a00401cb29912ea3526b5 Merge: 7047b644 5afee1eb Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:49:52 2024 +0100 Merge branch 'master' into feature/674-improve-properties .github/workflows/containers.yml | 38 ++ .github/workflows/coverage.yml | 2 +- .github/workflows/ubuntu.yml | 2 +- cmake/CelixDeps.cmake.in | 1 - container/Containerfile.gitpod | 3 -- container/README.md| 11 +++ container/build-ubuntu-container.sh| 1 - ...ubuntu-container.sh => run-ubuntu-container.sh} | 3 +- container/support-scripts/build-all.sh | 1 - libs/framework/src/service_registry.c | 37 + 10 files changed, 61 insertions(+), 38 deletions(-)
(celix) 02/03: Add additional properties ei tests
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit dbfb90d744d73c84704840bd1b8a3a959f1eec9b Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:50:31 2024 +0100 Add additional properties ei tests --- .../error_injector/celix_array_list/CMakeLists.txt | 1 + .../celix_array_list/include/celix_array_list_ei.h | 2 + .../celix_array_list/src/celix_array_list_ei.cc| 7 ++ .../gtest/src/PropertiesErrorInjectionTestSuite.cc | 109 + 4 files changed, 119 insertions(+) diff --git a/libs/utils/error_injector/celix_array_list/CMakeLists.txt b/libs/utils/error_injector/celix_array_list/CMakeLists.txt index 3b56face..488a0cd7 100644 --- a/libs/utils/error_injector/celix_array_list/CMakeLists.txt +++ b/libs/utils/error_injector/celix_array_list/CMakeLists.txt @@ -23,6 +23,7 @@ target_link_options(array_list_ei INTERFACE LINKER:--wrap,celix_arrayList_create LINKER:--wrap,celix_arrayList_createWithOptions LINKER:--wrap,celix_arrayList_add +LINKER:--wrap,celix_arrayList_addString LINKER:--wrap,celix_arrayList_addInt LINKER:--wrap,celix_arrayList_addLong LINKER:--wrap,celix_arrayList_addUInt diff --git a/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h b/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h index 01965ade..09de817f 100644 --- a/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h +++ b/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h @@ -32,6 +32,8 @@ CELIX_EI_DECLARE(celix_arrayList_createWithOptions, celix_array_list_t*); CELIX_EI_DECLARE(celix_arrayList_add, celix_status_t); +CELIX_EI_DECLARE(celix_arrayList_addString, celix_status_t); + CELIX_EI_DECLARE(celix_arrayList_addInt, celix_status_t); CELIX_EI_DECLARE(celix_arrayList_addLong, celix_status_t); diff --git a/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc b/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc index 45a4a184..817b6f1d 100644 --- a/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc +++ b/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc @@ -42,6 +42,13 @@ celix_status_t __wrap_celix_arrayList_add(celix_array_list_t* list, void* value) return __real_celix_arrayList_add(list, value); } +celix_status_t __real_celix_arrayList_addString(celix_array_list_t* list, const char* value); +CELIX_EI_DEFINE(celix_arrayList_addString, celix_status_t) +celix_status_t __wrap_celix_arrayList_addString(celix_array_list_t* list, const char* value) { +CELIX_EI_IMPL(celix_arrayList_addString); +return __real_celix_arrayList_addString(list, value); +} + celix_status_t __real_celix_arrayList_addInt(celix_array_list_t* list, int value); CELIX_EI_DEFINE(celix_arrayList_addInt, celix_status_t) celix_status_t __wrap_celix_arrayList_addInt(celix_array_list_t* list, int value) { diff --git a/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc b/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc index c1fa7d8b..18ec2900 100644 --- a/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc +++ b/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc @@ -345,6 +345,115 @@ TEST_F(PropertiesErrorInjectionTestSuite, GetAsArrayWithArrayListCopyFailedTest) ASSERT_EQ(nullptr, versions); } +TEST_F(PropertiesErrorInjectionTestSuite, SetArrayWithArrayListCopyFailedTest) { +//Given a properties set +celix_autoptr(celix_properties_t) props = celix_properties_create(); + +//And a (empty) array list +celix_autoptr(celix_array_list_t) list = celix_arrayList_create(); + +// When a celix_arrayList_copy error injection is set for celix_properties_setLongArrayList + celix_ei_expect_celix_arrayList_copy((void*)celix_properties_setLongArrayList, 0, nullptr); + +// Then the celix_properties_setLongArrayList call fails +EXPECT_EQ(CELIX_ENOMEM, celix_properties_setLongArrayList(props, "longArray", list)); + +// When a celix_arrayList_copy error injection is set for celix_properties_setDoubleArrayList + celix_ei_expect_celix_arrayList_copy((void*)celix_properties_setDoubleArrayList, 0, nullptr); + +// Then the celix_properties_setDoubleArrayList call fails +EXPECT_EQ(CELIX_ENOMEM, celix_properties_setDoubleArrayList(props, "doubleArray", list)); + +// When a celix_arrayList_copy error injection is set for celix_properties_setBoolArrayList + celix_ei_expect_celix_arrayList_copy((void*)celix_properties_setBoolArrayList, 0, nullptr); + +// Then the celix_properties_setBoolArrayList call fails +EXPECT_EQ(CELIX_ENOMEM, celix_properties_setBoolArrayList(props, "boolArray", list)); + +// When a celix_arrayList_createWithOptions error injection is
(celix) 01/05: Fix parse error in celix_version_parse
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit abb645669572ea16c5e9332ca31cb2f84c6388f3 Author: Pepijn Noltes AuthorDate: Mon Jan 22 18:35:36 2024 +0100 Fix parse error in celix_version_parse --- libs/utils/gtest/src/VersionTestSuite.cc | 12 libs/utils/src/version.c | 6 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/utils/gtest/src/VersionTestSuite.cc b/libs/utils/gtest/src/VersionTestSuite.cc index 6d650b57..df3668ec 100644 --- a/libs/utils/gtest/src/VersionTestSuite.cc +++ b/libs/utils/gtest/src/VersionTestSuite.cc @@ -355,4 +355,16 @@ TEST_F(VersionTestSuite, ParseTest) { parseStatus = celix_version_parse("invalid", ); EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, parseStatus); EXPECT_EQ(nullptr, result); + +parseStatus = celix_version_parse("-1", ); +EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, parseStatus); +EXPECT_EQ(nullptr, result); + +parseStatus = celix_version_parse("1.-2", ); +EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, parseStatus); +EXPECT_EQ(nullptr, result); + +parseStatus = celix_version_parse("1.2.-3", ); +EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, parseStatus); +EXPECT_EQ(nullptr, result); } diff --git a/libs/utils/src/version.c b/libs/utils/src/version.c index 31423401..92d53001 100644 --- a/libs/utils/src/version.c +++ b/libs/utils/src/version.c @@ -196,8 +196,12 @@ celix_status_t celix_version_parse(const char *versionStr, celix_version_t** ver while (token) { bool convertedToLong = false; long l = celix_utils_convertStringToLong(token, 0L, ); -if (!convertedToLong && count == 3) { //qualifier +if (!convertedToLong && count == 3) { // qualifier qualifier = token; +} else if (convertedToLong && l < 0) { +//negative version part +celix_utils_freeStringIfNotEqual(buffer, versionWrkStr); +return CELIX_ILLEGAL_ARGUMENT; } else if (convertedToLong && count < 3) { versionsParts[count] = (int)l; } else if (!convertedToLong) {
(celix) 03/05: Fix memleak in properties
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit d55c411e440bea62235db7b747ecc65c0e8a6ce0 Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:27:28 2024 +0100 Fix memleak in properties --- .../gtest/src/PropertiesErrorInjectionTestSuite.cc | 2 +- libs/utils/src/properties.c| 48 +- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc b/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc index 16778ec3..c1fa7d8b 100644 --- a/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc +++ b/libs/utils/gtest/src/PropertiesErrorInjectionTestSuite.cc @@ -129,7 +129,7 @@ TEST_F(PropertiesErrorInjectionTestSuite, SetFailureTest) { ASSERT_EQ(celix_properties_set(props, "key", "value"), CELIX_ENOMEM); // When a celix_stringHashMap_put error injection is set for celix_properties_set with level 1 (during put) -celix_ei_expect_celix_stringHashMap_put((void*)celix_properties_set, 1, CELIX_ENOMEM); +celix_ei_expect_celix_stringHashMap_put((void*)celix_properties_set, 2, CELIX_ENOMEM); // Then the celix_properties_set call fails ASSERT_EQ(celix_properties_set(props, "key", "value"), CELIX_ENOMEM); diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c index 38055b2c..1fd9753e 100644 --- a/libs/utils/src/properties.c +++ b/libs/utils/src/properties.c @@ -215,26 +215,28 @@ static celix_properties_entry_t* celix_properties_createEntryWithNoCopy(celix_pr return entry; } -static void celix_properties_freeTypedEntry(const celix_properties_entry_t* entry) { -if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_VERSION) { -celix_version_destroy((celix_version_t*)entry->typed.versionValue); -} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY) { - celix_arrayList_destroy((celix_array_list_t*)entry->typed.arrayValue); -} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY) { - celix_arrayList_destroy((celix_array_list_t*)entry->typed.arrayValue); -} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_BOOL_ARRAY) { - celix_arrayList_destroy((celix_array_list_t*)entry->typed.arrayValue); -} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_STRING_ARRAY) { - celix_arrayList_destroy((celix_array_list_t*)entry->typed.arrayValue); -} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_VERSION_ARRAY) { - celix_arrayList_destroy((celix_array_list_t*)entry->typed.arrayValue); +static void celix_properties_freeTypedEntry(celix_properties_t* properties, celix_properties_entry_t* entry) { +if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_STRING) { +celix_properties_freeString(properties, (char*)entry->typed.strValue); +entry->typed.strValue = NULL; +entry->value = NULL; +} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_VERSION) { +celix_version_destroy((celix_version_t*)entry->typed.versionValue); +entry->typed.versionValue = NULL; +} else if (entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_LONG_ARRAY || + entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_DOUBLE_ARRAY || + entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_BOOL_ARRAY || + entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_STRING_ARRAY || + entry->valueType == CELIX_PROPERTIES_VALUE_TYPE_VERSION_ARRAY) { +celix_arrayList_destroy((celix_array_list_t*)entry->typed.arrayValue); +entry->typed.arrayValue = NULL; } else { // nop } } static void celix_properties_destroyEntry(celix_properties_t* properties, celix_properties_entry_t* entry) { -celix_properties_freeTypedEntry(entry); +celix_properties_freeTypedEntry(properties, entry); celix_properties_freeString(properties, (char*)entry->value); if (entry >= properties->entriesBuffer && entry <= (properties->entriesBuffer + CELIX_PROPERTIES_OPTIMIZATION_ENTRIES_BUFFER_SIZE)) { @@ -256,10 +258,10 @@ static void celix_properties_destroyEntry(celix_properties_t* properties, celix_ * Only 1 of the types values (strValue, LongValue, etc) should be provided. */ static celix_properties_entry_t* celix_properties_createEntry(celix_properties_t* properties, - const celix_properties_entry_t* prototype) { + celix_properties_entry_t* prototype) { celix_properties_entry_t* entry = celix_properties_allocEntry(properties); if (entry == NULL) { -celix_properties_freeTypedEntry(prototype); +celix_properties_freeTypedEntry(properties,
(celix) 04/05: Improve references handling in rsa_shm_impl.c
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit 82246c13e2cc6c956aa4414df83b66faf9a3624d Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:27:55 2024 +0100 Improve references handling in rsa_shm_impl.c --- .../remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c index 1745e3f7..6cd251ec 100755 --- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c +++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c @@ -288,7 +288,7 @@ celix_status_t rsaShm_exportService(rsa_shm_t *admin, char *serviceId, return CELIX_ILLEGAL_ARGUMENT; } -celix_array_list_t *references = NULL; +celix_autoptr(celix_array_list_t) references = NULL; service_reference_pt reference = NULL; char filter[32] = {0};// It is longer than the size of "service.id" + serviceId snprintf(filter, sizeof(filter), "(%s=%s)", (char *) CELIX_FRAMEWORK_SERVICE_ID, serviceId); @@ -298,10 +298,11 @@ celix_status_t rsaShm_exportService(rsa_shm_t *admin, char *serviceId, return status; } //We get reference with serviceId, so the size of references must be less than or equal to 1. -reference = celix_arrayList_get(references, 0); -celix_arrayList_destroy(references); +if (celix_arrayList_size(references) == 1) { +reference = celix_arrayList_get(references, 0); +} if (reference == NULL) { -celix_logHelper_error(admin->logHelper, "Expect a reference for service id %s.", serviceId); +celix_logHelper_error(admin->logHelper, "Expect a exactly one reference for service id %s. Got %i", serviceId, celix_arrayList_size(references)); return CELIX_ILLEGAL_STATE; } celix_auto(celix_service_ref_guard_t) ref = celix_ServiceRefGuard_init(admin->context, reference);
(celix) branch feature/674-improve-properties updated (21731030 -> 7047b644)
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a change to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git from 21731030 Fix memleak in celix_properties_setVersions new abb64566 Fix parse error in celix_version_parse new ccd4b358 Add getString / getAsString to celix properties new d55c411e Fix memleak in properties new 82246c13 Improve references handling in rsa_shm_impl.c new 7047b644 Add properties and filter introduction documentation The 5 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: .../rsa_shm/src/rsa_shm_impl.c | 9 +- documents/README.md| 2 + documents/patterns.md | 2 +- documents/properties_and_filter.md | 121 + libs/utils/gtest/src/CxxPropertiesTestSuite.cc | 8 +- .../gtest/src/PropertiesErrorInjectionTestSuite.cc | 2 +- libs/utils/gtest/src/PropertiesTestSuite.cc| 9 +- libs/utils/gtest/src/VersionTestSuite.cc | 12 ++ libs/utils/include/celix/Properties.h | 41 ++- libs/utils/include/celix_properties.h | 78 - libs/utils/src/properties.c| 100 - libs/utils/src/version.c | 6 +- 12 files changed, 334 insertions(+), 56 deletions(-) create mode 100644 documents/properties_and_filter.md
(celix) 05/05: Add properties and filter introduction documentation
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit 7047b6444ad227f0af2bd54b9e2eac1efd9df3af Author: Pepijn Noltes AuthorDate: Mon Jan 22 19:28:15 2024 +0100 Add properties and filter introduction documentation --- documents/README.md| 2 + documents/patterns.md | 2 +- documents/properties_and_filter.md | 121 + 3 files changed, 124 insertions(+), 1 deletion(-) diff --git a/documents/README.md b/documents/README.md index 2446f457..3930498a 100644 --- a/documents/README.md +++ b/documents/README.md @@ -84,6 +84,8 @@ bundles contains binaries depending on the stdlibc++ library. * [Building and Developing Apache Celix with CLion](building/dev_celix_with_clion.md) * C Patterns * [Apache Celix C Patterns](c_patterns.md) +* Utils + * [Apache Celix Properties & Filter](properties_and_filter.md) * Framework * [Apache Celix Bundles](bundles.md) * [Apache Celix Services](services.md) diff --git a/documents/patterns.md b/documents/patterns.md index 39d16027..76efe3c7 100644 --- a/documents/patterns.md +++ b/documents/patterns.md @@ -1,5 +1,5 @@ --- -title: Apache Celix Services +title: Apache Celix Patterns --- + +# Apache Celix Properties +The Apache Celix Utils library provides a properties implementation which is used in several places in Apache Celix. +The properties are a key-value map with string keys and values with can be of a type: +- String (char*) +- Long (long) +- Double (double) +- Bool (bool) +- Version (celix_version_t*) +- String Array (celix_array_list_t*) +- Long Array (celix_array_list_t*) +- Double Array (celix_array_list_t*) +- Bool Array (celix_array_list_t*) +- Version Array (celix_array_list_t*) + +## Configuration Properties +Properties can be used - and are used in the Apache Celix framework - for runtime configuration and metadata. +In this use case the actual underlying value types are not important and the properties values can be accessed and +automatically converted to the requested type. + +In the aforementioned use case the properties value are accessed using the "getAs" functions, for example: +```c +celix_properties_t* props = celix_properties_create(); +celix_properties_set(props, "myLong", "10"); +long value = celix_properties_getAsLong(props, "myLong", 0L); +assert(value == 10L); +``` +In the above example the value of the property with key "myLong" is returned as a long and if the property is not +available or cannot be converted to a long the default value (0L) is returned. + +## Service Properties +Properties are also be used as metadata for services. In this use case the actual underlying value types are important +, because they are used to filter services. + +The only access properties values if the property value type is the expected type the "get" functions should be used, +for example: +```c +celix_properties_t* props = celix_properties_create(); +celix_properties_setLong(props, "myLong", 10); +long value = celix_properties_getLong(props, "myLong", 0L); +assert(value == 10L); +``` +In the above example the value of the property with key "myLong" is returned if the property is available and the +property value type is a long. + +## Apache Celix Properties C++ API +The Apache Celix Properties C++ API is a header only API which can be used to create and access properties. +The concept of C++ Properties is similar to the C Properties. + +Example: +```cpp +celix::Properties props{}; +props.set("myLong", 10L); +long value = props.getLong("myLong", 0L); +assert(value == 10L); +``` + +## More Information +See the `celix_properites.h` C header and `celix/Properties.h` C++ header for more information. + +## Apache Celix Filter +Apache Celix also provides a filter implementation which can be used to filter properties based on their values. +In the Apache Celix Framework the filter implementation is used to filter services based on their properties. + +Filters are created using a LDAP like syntax, for example: +```c +celix_filter_t* filter = celix_filter_create("(myLong>5)"); +``` + +Filters can be used to match properties, for example: +```c +celix_properties_t* props = celix_properties_create(); +celix_properties_setLong(props, "myLong", 10); +bool match = celix_filter_match(filter, props); +assert(match); +``` + +When matching properties with a filter, the property value types determined the matching rules. This means +that a `=` (equal) match for a long property will yield a different result than a `=` (equal) match for a string. + +For example, if a properties set contains a property "myLong" with string value "10" and a filter "(myLong>5)" is +used to match the properties set, the filter will not match. This is because the filter matching uses lexical +comparison and in that case "10" is not greater than
(celix) 02/05: Add getString / getAsString to celix properties
This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/674-improve-properties in repository https://gitbox.apache.org/repos/asf/celix.git commit ccd4b3580ad271f44109b346d7a5e88c91c9cf86 Author: Pepijn Noltes AuthorDate: Mon Jan 22 18:42:17 2024 +0100 Add getString / getAsString to celix properties --- libs/utils/gtest/src/CxxPropertiesTestSuite.cc | 8 +-- libs/utils/gtest/src/PropertiesTestSuite.cc| 9 +-- libs/utils/include/celix/Properties.h | 41 -- libs/utils/include/celix_properties.h | 78 -- libs/utils/src/properties.c| 54 ++ 5 files changed, 160 insertions(+), 30 deletions(-) diff --git a/libs/utils/gtest/src/CxxPropertiesTestSuite.cc b/libs/utils/gtest/src/CxxPropertiesTestSuite.cc index d41342a1..2370853e 100644 --- a/libs/utils/gtest/src/CxxPropertiesTestSuite.cc +++ b/libs/utils/gtest/src/CxxPropertiesTestSuite.cc @@ -44,6 +44,7 @@ TEST_F(CxxPropertiesTestSuite, FillAndLoopTest) { EXPECT_EQ(5, props.size()); EXPECT_EQ(props.get("key1"), "value1"); +EXPECT_EQ(props.getAsString("key1"), "value1"); EXPECT_EQ(props.get("key2"), "value2"); EXPECT_EQ(props.getAsDouble("key3", 0), 3.3); EXPECT_EQ(props.get("key4"), "4"); @@ -204,7 +205,7 @@ TEST_F(CxxPropertiesTestSuite, GetTest) { EXPECT_EQ(props.getAsVersion("key5", celix::Version{1, 2, 4}), checkVersion); //Test get with valid key -EXPECT_EQ(props.get("key1"), "value1"); +EXPECT_EQ(props.getString("key1"), "value1"); EXPECT_EQ(props.getLong("key2", -1), 2); EXPECT_EQ(props.getDouble("key3", -1), 3.3); EXPECT_EQ(props.getBool("key4", false), true); @@ -219,7 +220,7 @@ TEST_F(CxxPropertiesTestSuite, GetTest) { EXPECT_EQ(props.getType("non-existing"), celix::Properties::ValueType::Unset); // Test get with invalid key and default value -EXPECT_EQ(props.get("non_existent_key", "default_value"), "default_value"); +EXPECT_EQ(props.getString("non_existent_key", "default_value"), "default_value"); EXPECT_EQ(props.getLong("non_existent_key", 1), 1); EXPECT_EQ(props.getDouble("non_existent_key", 1.1), 1.1); EXPECT_EQ(props.getBool("non_existent_key", true), true); @@ -227,8 +228,7 @@ TEST_F(CxxPropertiesTestSuite, GetTest) { EXPECT_EQ(props.getVersion("non_existent_key", checkVersion2), checkVersion2); // Test get with an existing key, but invalid type and default value -EXPECT_EQ(props.get("key5", "default_value"), "1.2.3"); // Note get always returns the string value or string -// representation of the value (in this case the version) +EXPECT_EQ(props.getString("key5", "default_value"), "default_value"); //key5 is a version EXPECT_EQ(props.getLong("key1", 1), 1); //key1 is a string EXPECT_EQ(props.getDouble("key1", 1.1), 1.1); //key1 is a string EXPECT_EQ(props.getBool("key1", true), true); //key1 is a string diff --git a/libs/utils/gtest/src/PropertiesTestSuite.cc b/libs/utils/gtest/src/PropertiesTestSuite.cc index 1b02bc15..c610a5ca 100644 --- a/libs/utils/gtest/src/PropertiesTestSuite.cc +++ b/libs/utils/gtest/src/PropertiesTestSuite.cc @@ -601,7 +601,7 @@ TEST_F(PropertiesTestSuite, HasKeyTest) { TEST_F(PropertiesTestSuite, SetEntryTest) { auto* props1 = celix_properties_create(); auto* props2 = celix_properties_create(); -celix_properties_set(props1, "key1", "value1"); +celix_properties_setString(props1, "key1", "value1"); celix_properties_setLong(props1, "key2", 123); celix_properties_setBool(props1, "key3", true); celix_properties_setDouble(props1, "key4", 3.14); @@ -614,7 +614,7 @@ TEST_F(PropertiesTestSuite, SetEntryTest) { } EXPECT_EQ(5, celix_properties_size(props2)); -EXPECT_STREQ("value1", celix_properties_get(props2, "key1", nullptr)); +EXPECT_STREQ("value1", celix_properties_getAsString(props2, "key1", nullptr)); EXPECT_EQ(123, celix_properties_getAsLong(props2, "key2", -1L)); EXPECT_EQ(true, celix_properties_getAsBool(props2, "key3", false)); EXPECT_EQ(3.14, celix_properties_getAsDouble(props2, "key4", -1.0)); @@ -756,20 +756,21 @@ TEST_F(PropertiesTestSuite, GetLongDoubleBoolVersionAndStringTest) { celix_properties_assignVersion(props, "version", version); // check if the values are correctly returned -EXPECT_STREQ("value", celix_properties_get(props, "str", nullptr)); +EXPECT_STREQ("value", celix_properties_getString(props, "str", nullptr)); EXPECT_EQ(42, celix_properties_getLong(props, "long", -1L)); EXPECT_DOUBLE_EQ(3.14, celix_properties_getDouble(props, "double", -1.0)); EXPECT_EQ(true, celix_properties_getBool(props, "bool", false)); EXPECT_EQ(version, celix_properties_getVersion(props, "version", nullptr)); // check if the values are correctly returned if
(celix) branch feature/dfi-cleanup updated (6223856e -> ba398d32)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch feature/dfi-cleanup in repository https://gitbox.apache.org/repos/asf/celix.git from 6223856e Add dynType_realType for code deduplication. add ba398d32 Remove unnecessary calloc and fix crash caused by pointer reference in jsonRpc_call. No new revisions were added by this update. Summary of changes: .../{example1.descriptor => example7.descriptor} | 4 +- libs/dfi/gtest/src/json_rpc_tests.cpp | 56 +++ libs/dfi/include/json_rpc.h| 6 +- libs/dfi/src/json_rpc.c| 526 ++--- 4 files changed, 313 insertions(+), 279 deletions(-) copy libs/dfi/gtest/descriptors/{example1.descriptor => example7.descriptor} (64%)
(celix) branch feature/dfi-cleanup updated (74f1243d -> 6223856e)
This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a change to branch feature/dfi-cleanup in repository https://gitbox.apache.org/repos/asf/celix.git from 74f1243d Avoid list iteration in dynInterface_nrOfMethods. add 6223856e Add dynType_realType for code deduplication. No new revisions were added by this update. Summary of changes: libs/dfi/include/dyn_type.h| 5 libs/dfi/src/dyn_type.c| 57 +- libs/dfi/src/dyn_type_common.c | 5 +--- libs/dfi/src/json_serializer.c | 12 ++--- 4 files changed, 26 insertions(+), 53 deletions(-)