FELIX-6327 - NoSuchElementException when services are removed

The tryInvokeBind method needs more safeguards around when the reference
that just got bound is detected that it got removed.

The previous code always assumed there was at least one other viable
reference to bind to.  That causes the NoSuchElementException when
trying to find a fallback reference.  Fixing that exposed another issue
with the previous code where the state of the DependencyManager is not
properly restored in two aspects:

1) Even when unbind is not invoked during tryInvokeBind the
currentRefPair would get set to null when it must remain set to the
previous value in cases where the invoke bind fails.  A check is needed
to be sure to only clear the currentRefPair if unbind was successfully
invoked.

2) After invoking bind/unbind there is a check to see if the reference
is still viable (not deleted).  This is where the reported problem
occurs when there is no alternative reference available and a
NoSuchElementException is thrown.  Avoiding the NoSuchElementException
and returning from tryInvokeBind would leave the DependencyManager in a
state where it thinks there is still a binding thread doing work when
that thread is really done.  Additional checks are needed to ensure we
always restore the binding thread state of the DepenencyManager on exit
of tryInvokeBind method.
4 files changed
tree: 8e14eded7c35e443676ba531a8ffbecb0a3e6147
  1. bundlerepository/
  2. bundlerepository.osgi-ct/
  3. cm.json/
  4. configadmin/
  5. configadmin-plugins/
  6. configurator/
  7. connect/
  8. converter/
  9. coordinator/
  10. dependencymanager/
  11. deploymentadmin/
  12. deviceaccess/
  13. doap/
  14. eventadmin/
  15. examples/
  16. fileinstall/
  17. fileinstall-plugins/
  18. framework/
  19. framework.security/
  20. gogo/
  21. healthcheck/
  22. http/
  23. httplite/
  24. inventory/
  25. io/
  26. ipojo/
  27. jaas/
  28. jmood/
  29. jmxintrospector/
  30. log/
  31. log.extension/
  32. logback/
  33. main/
  34. main.distribution/
  35. metatype/
  36. metrics/
  37. mishell/
  38. mosgi/
  39. org.apache.felix.daemon/
  40. org.osgi.service.obr/
  41. pom/
  42. prefs/
  43. resolver/
  44. rootcause/
  45. scr/
  46. scr-compat/
  47. scr-ext-anno/
  48. shell/
  49. shell.gui/
  50. shell.gui.plugin/
  51. shell.remote/
  52. shell.tui/
  53. systemready/
  54. threaddump/
  55. tools/
  56. transaction/
  57. upnp/
  58. useradmin/
  59. utils/
  60. webconsole/
  61. webconsole-l10n/
  62. webconsole-plugins/
  63. wireadmin/
  64. .gitignore
  65. check_staged_release.sh
  66. CODE_OF_CONDUCT.md
  67. CONTRIBUTING.md
  68. LICENSE
  69. README.md
  70. stage_existing_artifact.sh
README.md

Apache Felix

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

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 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.