paulrutter opened a new pull request, #554:
URL: https://github.com/apache/felix-dev/pull/554
`org.apache.felix.framework.FilterImpl.WrapperCapability` has two defects,
both introduced by 466eb93f1c *"[fw] reduce warning related to types Classes"*
— a generics cleanup that changed behaviour by accident. They surfaced while
running the OSGi Core R8 TCK for #433, which reported 33 errors across
`BundleContextFilterTests` and `DivTests`; both trace back here.
### 1. `Filter.matches(Map)` throws for any non-empty map
The constructor lost its assignment into a stray empty `if` block:
```java
public WrapperCapability(Map<String, ?> map)
{
super(null, null, Collections.emptyMap(), Collections.emptyMap());
m_map = Collections.emptyMap();
if(map != null ) {
}
m_map.putAll(map);
}
```
`m_map` refers to an immutable empty map, so `putAll` throws
`UnsupportedOperationException` for any non-empty argument, and
`NullPointerException` for a null one. It previously read:
```java
m_map = (map == null) ? Collections.EMPTY_MAP : map;
```
which is restored here. **`Filter.matches(Map)` has been unusable since
April 2025**, so this affects released versions independently of any Java
version work.
### 2. `WrapperCapability(ServiceReference)` requires an OSGi Core 1.10
method
It was rewritten to `new DictionaryToMap(sr.getProperties(), false)`.
`ServiceReference.getProperties()` was only added in Core 1.10 and is not
implemented by every `ServiceReference` — the TCK's own mock throws
`UnsupportedOperationException` for it. Restored to the
`getPropertyKeys()`/`getProperty()` loop, which every implementation supports.
### Tests
Adds regression tests for both cases. They construct
`org.apache.felix.framework.FilterImpl` directly, because
`FrameworkUtil.createFilter` returns the unrelated
`org.osgi.framework.FilterImpl` and does not exercise this code at all — worth
knowing, as it is an easy trap when testing this class.
Verified both ways: the new tests fail with `UnsupportedOperationException`
against current master and pass with the fix.
@stbischof — flagging you as the author of 466eb93f1c so you can
sanity-check the intent. The generics conversion itself looks right; it just
seems the `m_map = map` assignment and the property loop were lost in the edit.
Happy to adjust if you had something else in mind for either constructor.
These are independent of the Java 25 work in #433, which is why they are
proposed separately against `master`; #433 carries the same fix so its TCK run
can pass, and that will drop out when this merges.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]