+
+ @SuppressWarnings("IllegalCatch")
+ private boolean isInstalled(final Feature feature) throws InterruptedException {
+ for (int retries = 0; retries < MAX_RETRIES; retries++) {
+ try {
+ // We process the installed features manually to handle the special "0.0.0" version
+ // which is the representation for null
+ for (Feature installedFeature : featuresService.listInstalledFeatures()) {
+ if (feature.equals(installedFeature)) {
+ return true;
+ }
+ if ("0.0.0".equals(feature.getVersion()) && feature.getName().equals(installedFeature.getName())
+ && !installedFeature.hasVersion()) {
+ return true;
+ }
+ }
+
+ LOG.debug("Karaf Feature Service has not yet finished installing feature {}/{} (retry {})", feature
+ .getName(), feature.getVersion(), retries);
+ } catch (final Exception e) {
+ LOG.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}", retries, e);
+ }
+
+ TimeUnit.MILLISECONDS.sleep(RETRY_PAUSE_MILLIS);
+ }
+
+ LOG.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet "
+ + "finished installing feature {} {}", MAX_RETRIES, feature.getName(), feature.getVersion());
+ return false;
+ }