Wait instead of calling waitFor twice when bundle is not readable
@@ -26,26 +26,24 @@ public class FileAcquirerBundleInstaller implements BundleInstaller {
@Override
public List<Bundle> installBundles(FileReference reference, Osgi osgi) throws InterruptedException {
- File file = acquireFile(reference);
+ File file = fileAcquirer.waitFor(reference, 7, TimeUnit.DAYS);
- // Retrying is added in case FileAcquirer returns right before the file is actually ready.
+ if (notReadable(file)) {
+ // Wait a few sec in case FileAcquirer returns right before the file is actually ready.
// This happened on rare occasions due to a (fixed) bug in file distribution.
+ log.warning("Unable to open bundle file with reference '" + reference + "'. Waiting for up to 5 sec.");
int retries = 0;
- while (notReadable(file) && retries < 1) {
- log.warning("Unable to open bundle file with reference '" + reference + "'. Retrying.");
- file = acquireFile(reference);
+ while (notReadable(file) && retries < 10) {
+ Thread.sleep(500);
retries++;
}
-
if (notReadable(file)) {
com.yahoo.protect.Process.logAndDie("Shutting down - unable to read bundle file with reference '" + reference
+ "' and path " + file.getAbsolutePath());
}
- return osgi.install(file.getAbsolutePath());
}
- private File acquireFile(FileReference reference) throws InterruptedException {
- return fileAcquirer.waitFor(reference, 7, TimeUnit.DAYS);
+ return osgi.install(file.getAbsolutePath());
}
private static boolean notReadable(File file) {
