stataru8 commented on code in PR #2983:
URL: https://github.com/apache/karaf/pull/2983#discussion_r4210657914
##########
features/core/src/test/java/org/apache/karaf/features/internal/support/TestBundle.java:
##########
@@ -56,8 +56,12 @@ public TestBundle(long bundleId, String location, int state,
Hashtable<String, S
public void update(Hashtable<String, String> headers) throws
BundleException {
this.headers.clear();
this.headers.putAll(headers);
- this.caps.clear();
- this.reqs.clear();
+ // felix-utils 1.11.10 made ResourceImpl#caps and ResourceImpl#reqs
private, the two clear()
+ // calls below rely on an implementation quirk, not to be used in real
code: with a null
+ // namespace, getCapabilities and getRequirements return the internal
lists.
+ // These calls bypass ResourceImpl's private resetHash(), which is
safe here because TestBundle overrides hashCode()
+ getCapabilities(null).clear();
Review Comment:
I'm not sure if the alternatives below are better:
- use reflection;
- add an API in
[ResourceImpl](https://github.com/apache/felix-dev/blob/868ddc6f847cf72c58d4cbfe1cbb34e6249d941f/utils/src/main/java/org/apache/felix/utils/resource/ResourceImpl.java#L34)
for this;
- [AI suggestion] split TestBundle into a bundle and a separate revision, so
update() creates a new revision instead of clearing the old one (this is how
OSGi handles updates)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]