Source:
private final BundleStateSet getCurrentBundleStates(Set<Feature> features) { BundleStateSet bundleStateSet = new BundleStateSet(); BundleContext context = getContext(); for (Feature curFeature : features) { for (BundleInfo curBundleInfo : curFeature.getBundles()) { Bundle curBundle = context.getBundle(curBundleInfo.getLocation()); if (curBundle.adapt(BundleRevision.class).getTypes() != BundleRevision.TYPE_FRAGMENT) { int bundleState = curBundle.getState(); switch (bundleState) { case Bundle.RESOLVED: case Bundle.STARTING: case Bundle.STOPPING: bundleStateSet.addInactiveBundle(curBundle); break; case Bundle.INSTALLED: case Bundle.UNINSTALLED: bundleStateSet.addFailedBundle(curBundle); break; case Bundle.ACTIVE: for (BundleStateService curStateService : bundleStateServices) { LOGGER.trace( "Checking for bundle state of {}.", curStateService.getName(), curBundle.getSymbolicName()); BundleState curState = curStateService.getState(curBundle); switch (curState) { case Resolved: case Stopping: LOGGER.trace( "{} is in an inactive state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addInactiveBundle(curBundle); break; case Installed: case Failure: LOGGER.trace( "{} is in a failed state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addFailedBundle(curBundle); break; case Waiting: case Starting: case GracePeriod: LOGGER.trace( "{} is in a transitional state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addTransitionalBundle(curBundle); break; case Active: LOGGER.trace( "{} is in an active state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addActiveBundle(curBundle); break; case Unknown: default: break; } } break; default: bundleStateSet.addActiveBundle(curBundle); break; } } } } return bundleStateSet; }

Target:
private final BundleStateSet getCurrentBundleStates(Set<Feature> features) { BundleStateSet bundleStateSet = new BundleStateSet(); BundleContext context = getContext(); for (Feature curFeature : features) { for (BundleInfo curBundleInfo : curFeature.getBundles()) { Bundle curBundle = context.getBundle(curBundleInfo.getLocation()); if (curBundle != null && curBundle.adapt(BundleRevision.class).getTypes() != BundleRevision.TYPE_FRAGMENT) { int bundleState = curBundle.getState(); switch (bundleState) { case Bundle.RESOLVED: case Bundle.STARTING: case Bundle.STOPPING: bundleStateSet.addInactiveBundle(curBundle); break; case Bundle.INSTALLED: case Bundle.UNINSTALLED: bundleStateSet.addFailedBundle(curBundle); break; case Bundle.ACTIVE: for (BundleStateService curStateService : bundleStateServices) { LOGGER.trace( "Checking for bundle state of {}.", curStateService.getName(), curBundle.getSymbolicName()); BundleState curState = curStateService.getState(curBundle); switch (curState) { case Resolved: case Stopping: LOGGER.trace( "{} is in an inactive state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addInactiveBundle(curBundle); break; case Installed: case Failure: LOGGER.trace( "{} is in a failed state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addFailedBundle(curBundle); break; case Waiting: case Starting: case GracePeriod: LOGGER.trace( "{} is in a transitional state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addTransitionalBundle(curBundle); break; case Active: LOGGER.trace( "{} is in an active state. Current State: {}", curBundle.getSymbolicName(), curState); bundleStateSet.addActiveBundle(curBundle); break; case Unknown: default: break; } } break; default: bundleStateSet.addActiveBundle(curBundle); break; } } } } return bundleStateSet; }