}
if (count == 500) {
getLog().error("Bundle stability isn't reached after 500 tries");
dumpBundles(context);
throw new MojoFailureException("Cannot reach the bundle stability");
}
boolean serviceStability = false;
count = 0;
int count1 = 0;
int count2 = 0;
while (! serviceStability && count < 500) {
try {
ServiceReference[] refs = context.getServiceReferences(null, null);
count1 = refs.length;
Thread.sleep(500);
refs = context.getServiceReferences(null, null);
count2 = refs.length;
serviceStability = count1 == count2;
} catch (Exception e) {
getLog().error(e);
serviceStability = false;
// Nothing to do, while recheck the condition
}
count++;
}
if (count == 500) {
getLog().error("Service stability isn't reached after 500 tries (" + count1 + " != " + count2);
dumpBundles(context);
throw new MojoFailureException("Cannot reach the service stability");
}
}