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

pengzheng pushed a commit to branch feature/556-osgi-uninstall
in repository https://gitbox.apache.org/repos/asf/celix.git

commit 7e0541fe6dcc5947798426482bae968501d02180
Author: PengZheng <[email protected]>
AuthorDate: Tue May 30 17:44:16 2023 +0800

    Fix logging null string in case of bundleArchive_revise error.
---
 .../src/BundleArchiveWithErrorInjectionTestSuite.cc   | 19 ++++++++++++++++++-
 libs/framework/src/bundle_archive.c                   |  4 ++--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc 
b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
index 4cccd60e..86bc39d3 100644
--- a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
+++ b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
@@ -225,4 +225,21 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, 
ArchiveCreateErrorTest) {
     teardownErrorInjectors();
 
     EXPECT_EQ(CELIX_SUCCESS, celix_bundleCache_destroy(cache));
-}
\ No newline at end of file
+}
+
+TEST_F(CelixBundleArchiveErrorInjectionTestSuite, ArchiveReviseErrorTest) {
+    celix_bundle_cache_t* cache = nullptr;
+    createCache(&cache);
+    bundle_archive_t* archive = nullptr;
+
+    // revision creation failure
+    EXPECT_EQ(CELIX_SUCCESS,
+              celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 1, 
SIMPLE_TEST_BUNDLE1_LOCATION, &archive));
+    EXPECT_NE(nullptr, archive);
+    celix_ei_expect_calloc((void*)celix_bundleRevision_create, 0, nullptr);
+    EXPECT_EQ(CELIX_ENOMEM, bundleArchive_revise(archive, 
SIMPLE_TEST_BUNDLE1_LOCATION, nullptr));
+    EXPECT_EQ(CELIX_SUCCESS, bundleArchive_destroy(archive));
+    EXPECT_EQ(CELIX_SUCCESS, celix_utils_deleteDirectory(TEST_ARCHIVE_ROOT, 
nullptr));
+
+    EXPECT_EQ(CELIX_SUCCESS, celix_bundleCache_destroy(cache));
+}
diff --git a/libs/framework/src/bundle_archive.c 
b/libs/framework/src/bundle_archive.c
index d82faf8a..dc6e7c30 100644
--- a/libs/framework/src/bundle_archive.c
+++ b/libs/framework/src/bundle_archive.c
@@ -437,7 +437,7 @@ celix_status_t bundleArchive_revise(bundle_archive_pt 
archive, const char * loca
             archive->revision = revised;
             bundleRevision_destroy(current);
         } else {
-            status = CELIX_BUNDLE_EXCEPTION;
+            status = CELIX_ENOMEM;
             reason = "bundle revision creation";
         }
     } else {
@@ -452,7 +452,7 @@ celix_status_t bundleArchive_revise(bundle_archive_pt 
archive, const char * loca
     }
 revise_finished:
     celixThreadMutex_unlock(&archive->lock);
-    framework_logIfError(archive->fw->logger, status, reason, "Cannot update 
bundle archive %s", updatedBundleUrl);
+    framework_logIfError(archive->fw->logger, status, reason, "Cannot update 
bundle archive %s", updateUrl);
     return status;
 }
 

Reply via email to