-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hotfix/The Correct Bundle Update behavior #602
Conversation
Codecov Report
@@ Coverage Diff @@
## master #602 +/- ##
==========================================
+ Coverage 79.68% 79.70% +0.02%
==========================================
Files 256 256
Lines 34686 34686
==========================================
+ Hits 27640 27647 +7
+ Misses 7046 7039 -7
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small remarks, but LGTM
libs/framework/src/bundle_archive.c
Outdated
fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to stat bundle archive directory '%s'", archive->resourceCacheRoot); | ||
return status; | ||
} | ||
// assert(status == 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented-out code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
celixThreadMutex_unlock(&cache->mutex); | ||
(void) bundleArchive_destroy(archive); | ||
return status; | ||
bundleArchive_destroy(archive); | ||
} | ||
|
||
/** | ||
* Update location->bundle id lookup map. | ||
*/ | ||
static void celix_bundleCache_updateIdForLocationLookupMap(celix_bundle_cache_t* cache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just noticed that the char* bundleStateProperties = celix_utils_writeOrCreateString(..)
string at line 261 is never freed with celix_utils_freeStringIfNotEqual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
long celix_bundleCache_findBundleIdForLocation(celix_bundle_cache_t* cache, const char* location) { | ||
long bndId = -1; | ||
celixThreadMutex_lock(&cache->mutex); | ||
if (!cache->locationToBundleIdLookupMapLoaded) { | ||
celix_bundleCache_updateIdForLocationLookupMap(cache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes of course, this is only needed once.
This PR implements the correct bundle update behavior when updating from a different bundle location.
Previously if the bundle at that location is older than the bundle in cache, bundle extraction will be skipped, which will fail
the newly added
TEST_F(CelixBundleContextBundlesTestSuite, ForceUpdateUsingBundleFromDifferentLocation)
.This PR will always update the bundle cache if the external bundle comes from a different location, which is the behavior we advertise in the API documentation.
This PR also improves startup speed when starting with a clean cache.
Previously the framework will traverse the cache directory once for each newly installed bundles (with unknown bundle id).
celix_bundleCache_updateIdForLocationLookupMap
could be invoked bycelix_bundleCache_create
.But that would lead to unnecessary disk load when the launcher is just used to create bundle cache.