From: Ed Warnicke Date: Mon, 22 Sep 2014 03:01:42 +0000 (-0500) Subject: Bug 2014: Workaround for karaf listFeatures bug X-Git-Tag: release/helium~24^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=1c858b6eb7e34f56ef1974f31959cafbbc5e4bd7;hp=319934e9e4af28d3a9bbe9fdee8da4fba075a788 Bug 2014: Workaround for karaf listFeatures bug karaf FeatureService.listInstalledFeatures() sometimes throws a ConcurrentModificationException, this workaround retries to make sure we succeed. Change-Id: I4e307d5daba683dfc1b44b6524ce40b3b0e59d1b Signed-off-by: Ed Warnicke --- diff --git a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java index 1c094ad2dc..57052f9d60 100644 --- a/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java +++ b/opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java @@ -26,6 +26,7 @@ import com.google.common.collect.LinkedHashMultimap; */ public class FeatureConfigPusher { private static final Logger logger = LoggerFactory.getLogger(FeatureConfigPusher.class); + private static final int MAX_RETRIES=100; private FeaturesService featuresService = null; private ConfigPusher pusher = null; /* @@ -82,7 +83,29 @@ public class FeatureConfigPusher { } private boolean isInstalled(Feature feature) { - List installedFeatures = Arrays.asList(featuresService.listInstalledFeatures()); + List installedFeatures= null; + boolean cont = true; + int retries = 0; + while(cont) { + try { + installedFeatures = Arrays.asList(featuresService.listInstalledFeatures()); + break; + } catch (Exception e) { + if(retries < MAX_RETRIES) { + logger.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e); + try { + Thread.sleep(1); + } catch (InterruptedException e1) { + throw new IllegalStateException(e1); + } + retries++; + continue; + } else { + logger.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e); + throw e; + } + } + } return installedFeatures.contains(feature); }