FELIX-6812 Follow-up: escape the pid in the service.pid filter (#563)

* FELIX-6812 Follow-up: escape the pid in the service.pid filter

FELIX-6812 replaced getConfiguration(pid, "?") with a listConfigurations call,
and it builds the filter by concatenating the pid. A pid is not a filter-safe
value, and the class already escapes one in findExistingConfiguration.

A pid holding an asterisk builds a substring filter. listConfigurations then
returns configurations the event was not about, and ConfigInstaller writes the
first of them back to that other configuration's file. A pid holding a
parenthesis throws InvalidSyntaxException instead, which the catch reports as a
failure to save, so the configuration is never written back.

escapeFilterValue left the backslash alone, although the OSGi filter grammar
reserves it. A pid holding a backslash therefore stayed ambiguous after the
escaping. The backslash is escaped first, or the escapes added after it would be
escaped a second time.

The method now matches literals rather than patterns. It compiled four patterns
per call, and FELIX-6812 moved it from findExistingConfiguration, called once per
file install, to doConfigurationEvent, called for every configuration event.

Two tests raise CM_UPDATED for a pid holding an asterisk and for a pid holding a
backslash, and each one fails when its escape is removed.

* FELIX-6812 Follow-up: the two tests the change left green and empty

FELIX-6812 moved the CM_UPDATED path from getConfiguration to listConfigurations,
and two tests kept the expectations of the older call. Neither test calls
EasyMock.verify, so an expectation nothing consumes fails nothing.

testUseExistingConfigAndObserveCMDeleted expects listConfigurations for any
argument and answers null. The handler then returns before it reads anything, so
the test asserts nothing at all while it passes. It now expects the filter the
handler builds and answers with a configuration.

testUseExistingConfigWithFileinstallFilenameAndObserveCMDeleted still expects
getConfiguration and update. The CM_UPDATED path writes the file and calls no
method on the configuration, and getConfiguration is reachable from setConfig
only, which this test never calls.

Both tests verify their mocks now, which is what makes an expectation
load-bearing. The dead expectations go, and the Capture that fed update goes
with them. Adding the verify call before removing the expectations fails on
Configuration.update, which is the measurement behind this commit.
2 files changed
tree: 32e99fcd20483fd18d1d717ec785d4b58ac5ea17
  1. .github/
  2. bundlerepository/
  3. bundlerepository.osgi-ct/
  4. cm.json/
  5. configadmin/
  6. configadmin-plugins/
  7. configurator/
  8. connect/
  9. coordinator/
  10. dependencymanager/
  11. doap/
  12. eventadmin/
  13. examples/
  14. features/
  15. fileinstall/
  16. framework/
  17. framework.tck/
  18. gogo/
  19. healthcheck/
  20. http/
  21. inventory/
  22. ipojo/
  23. log/
  24. log.extension/
  25. main/
  26. main.distribution/
  27. metatype/
  28. pom/
  29. resolver/
  30. rootcause/
  31. scr/
  32. scr-ext-anno/
  33. systemready/
  34. tools/
  35. utils/
  36. webconsole/
  37. webconsole-plugins/
  38. .asf.yaml
  39. .gitignore
  40. check_staged_release.sh
  41. CODE_OF_CONDUCT.md
  42. CONTRIBUTING.md
  43. LICENSE
  44. README.md
  45. stage_existing_artifact.sh
README.md

Github CI Build

Apache Felix

The Apache Felix project is a collection of semi-related OSGi sub-projects that build and release individually.

Java support

Sub-projects build and release individually and each declares its own minimum Java version, so there is no single repository-wide baseline. The CI build (.github/workflows/maven-ci.yml) compiles and tests the covered sub-projects on Java 17, 21, 25 and 27.

Security Manager

The Apache Felix Framework no longer supports the OSGi security layer. Java SE 24 permanently disabled the Security Manager (JEP 486), so permission checks can no longer be enforced and System.setSecurityManager throws. Accordingly:

  • Launching the framework with the org.osgi.framework.security property now fails with a SecurityException rather than silently starting without the requested security.
  • Bundle.hasPermission(...) returns true unless a SecurityProvider is installed.
  • The OSGi permission API (AdminPermission, ServicePermission, PackagePermission, and friends) is still exported, so bundles referring to those types keep compiling and resolving.
  • The org.apache.felix.framework.security sub-project has been removed.

If you need the security layer, stay on a release that predates this change and run it on Java 21 or earlier.

Felix Framework

The flagship project is the Apache Felix Framework which implements the OSGi Core R7 specification. The /framework directory contains the source and build tree for the OSGi-compliant framework implementation.

Directly related projects:

  • main /main* - provides an executable jar that launches the Felix framework.

OSGi Core

OSGi Compendium

Several sub-projects cover various OSGi Compendium specifications such as:

Extra Features

Several projects provide extra features to an OSGi runtime.

  • bundle repository /bundlerepository - Bundle repository service.
  • connect /connect - A service registry that enables OSGi style service registry programs without using an OSGi framework.
  • dependency manager /dependencymanager - A versatile java API, allowing to declaratively register, acquire, and manage dynamic OSGi services.
  • fileinstall /fileinstall* - A utility to automatically install bundles from a directory.
  • gogo /gogo - A command line shell, runtime and set of base commands for interacting with and introspecting an OSGi framework.
  • health checks /healthcheck/* - An extensible framework to monitor the status of the OSGi container at runtime. (contains systemready)
  • inventory /inventory - Provides some mechanisms to get the current state of the system and therefore provides an inventory of the system.
  • ipojo /ipojo - A service component runtime aiming to simplify OSGi application development.
  • jaas support /jaas - Bundle to simplify JAAS usage within OSGi environment.
  • logback /logback - A simple integration of the OSGi R7 Log (1.4) service to Logback backend.
  • OSGi metrics /metrics/osgi - Collecting and publishing metrics related to OSGi applications
  • rootcause /rootcause - Finding the root cause of problems with OSGi declarative services components.
  • utils /utils - Utility classes for OSGi (intended for embedding within other bundles.)
  • webconsole /webconsole* - Web Based Management Console for OSGi Frameworks.
  • and many other OSGi things

Build tools

The /tools directory contains various build tools.

  • maven-bundle-plugin /tools/maven-bundle-plugin - A maven plugin for building OSGi bundles.
  • osgicheck-maven-plugin /tools/osgicheck-maven-plugin - Maven plugin for checking several OSGi aspects of your project.