Source:
public ApplicationStatus getApplicationStatus(Application application) { Set<Feature> uninstalledFeatures = new HashSet<>(); Set<Feature> requiredFeatures = new HashSet<>(); Set<Bundle> errorBundles = new HashSet<>(); ApplicationState installState = null; try { Feature mainFeature = application.getMainFeature(); boolean isMainFeatureUninstalled = true; if (mainFeature != null) { isMainFeatureUninstalled = !featuresService.isInstalled(mainFeature); requiredFeatures.add(mainFeature); } else { Set<Feature> features = application.getFeatures(); if (features.size() == 1) { requiredFeatures.addAll(getAllDependencyFeatures(features.iterator().next())); } else { features .stream() .filter(f -> equalsIgnoreCase(Feature.DEFAULT_INSTALL_MODE, f.getInstall())) .forEach(f -> requiredFeatures.addAll(getAllDependencyFeatures(f))); } } LOGGER.debug( "{} has required features that must be started.", application.getName(), requiredFeatures.size()); BundleStateSet bundleStates = getCurrentBundleStates(requiredFeatures); errorBundles.addAll(bundleStates.getFailedBundles()); errorBundles.addAll(bundleStates.getInactiveBundles()); if (bundleStates.getNumFailedBundles() > 0) { installState = ApplicationState.FAILED; } else if ((mainFeature != null && isMainFeatureUninstalled) || bundleStates.getNumInactiveBundles() > 0) { installState = ApplicationState.INACTIVE; } else if (bundleStates.getNumTransitionalBundles() > 0) { installState = ApplicationState.UNKNOWN; } else { installState = ApplicationState.ACTIVE; } } catch (Exception e) { LOGGER.warn( "Encountered an error while trying to determine status of application {}. " + "Setting status as UNKNOWN.", application.getName(), e); installState = ApplicationState.UNKNOWN; } return new ApplicationStatusImpl(application, installState, uninstalledFeatures, errorBundles); }

Target:
public ApplicationStatus getApplicationStatus(Application application) { Set<Feature> uninstalledFeatures = new HashSet<>(); Set<Bundle> errorBundles = new HashSet<>(); ApplicationState installState = null; try { Feature mainFeature = application.getMainFeature(); boolean isMainFeatureUninstalled = (mainFeature == null) || !featuresService.isInstalled(mainFeature); Set<Feature> requiredFeatures = (mainFeature == null) ? requiredFeaturesNoMainFeature(application) : Collections.singleton(mainFeature); LOGGER.debug( "{} has required features that must be started.", application.getName(), requiredFeatures.size()); BundleStateSet bundleStates = getCurrentBundleStates(requiredFeatures); errorBundles.addAll(bundleStates.getFailedBundles()); errorBundles.addAll(bundleStates.getInactiveBundles()); if (bundleStates.getNumFailedBundles() > 0) { installState = ApplicationState.FAILED; } else if ((mainFeature != null && isMainFeatureUninstalled) || bundleStates.getNumInactiveBundles() > 0) { installState = ApplicationState.INACTIVE; } else if (bundleStates.getNumTransitionalBundles() > 0) { installState = ApplicationState.UNKNOWN; } else { installState = ApplicationState.ACTIVE; } } catch (Exception e) { LOGGER.warn( "Encountered an error while trying to determine status of application {}. " + "Setting status as UNKNOWN.", application.getName(), e); installState = ApplicationState.UNKNOWN; } return new ApplicationStatusImpl(application, installState, uninstalledFeatures, errorBundles); }