- private boolean isInstalled(final Feature feature) {
- Exception lastException = null;
- for (int retries = 0; retries < MAX_RETRIES; retries++) {
- try {
- List<Feature> installedFeatures = Arrays.asList(featuresService.listInstalledFeatures());
- if (installedFeatures.contains(feature)) {
- return true;
- } else {
- LOG.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}", retries, feature.getName(), feature.getVersion());
- }
- // TODO This catch of ConcurrentModificationException may be able to simply be removed after
- // we're fully on Karaf 4 only, as a comment in BUG-6787 indicates that (in Karaf 4) :
- // "the 'installed' Map of FeaturesServiceImpl .. appears to be correctly synchronized/thread-safe".
- // (Or, if it's still NOK, then it could be fixed properly upstream in Karaf once we're on recent.)
- } catch (ConcurrentModificationException e) {
- // BUG-6787 experience shows that a LOG.warn (or info) here is very confusing to end-users;
- // as we have a retry loop anyway, there is no point informing (and confusing) users of this
- // intermediate state of, so ... NOOP, do not log here.
- lastException = e;
- }
- try {
- Thread.sleep(RETRY_PAUSE_MILLIS);
- } catch (InterruptedException e1) {
- throw new IllegalStateException(e1);
- }