holgerfriedrich commented on code in PR #2983:
URL: https://github.com/apache/karaf/pull/2983#discussion_r4227435471
##########
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 think both the current implementation (whose comment explains that it
relies on getCapabilities(null)/getRequirements(null) returning the internal
lists rather than copies) and a reflection-based implementation would be fine.
Reflection would be a bit stronger: if the Felix internals change, it fails
explicitly and the test fails with it. With the current approach, a Felix
version returning copies would turn the clear() calls into silent no-ops, and
the old capabilities would remain next to the new ones.
--
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]