Skip to content

Commit

Permalink
Check for null in case the framework is already shut down
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi authored and Christoph Läubrich committed Sep 28, 2022
1 parent acebd99 commit b071d3b
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,12 @@ public <T> T getService(Class<T> clazz, String filter) {
public Optional<Bundle> getBundle(Class<?> classFromBundle) {
URI location = getLocationFromClass(classFromBundle);
if (location != null) {
debug("Searching bundle for class " + classFromBundle + " and location " + location);
BundleContext bundleContext = getFramework().getBundleContext();
if (bundleContext == null) {
// already shut down
return Optional.empty();
}
debug("Searching bundle for class " + classFromBundle + " and location " + location);
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
String bundleLocation = bundle.getLocation();
Expand Down

0 comments on commit b071d3b

Please sign in to comment.