Skip to content

Commit

Permalink
Try fixing bundle location not found
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi committed Mar 23, 2023
1 parent aa7c107 commit 1a41b23
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.StringJoiner;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -497,11 +498,29 @@ private static String getStringList(Collection<String> elements) {
}

private OsgiManifest loadManifest(File bundleLocation, ArtifactDescriptor artifact) {
if (bundleLocation == null || !bundleLocation.exists()) {
if (bundleLocation == null) {
throw new IllegalArgumentException("bundleLocation can't be null for artifact " + artifact);
}
if (!checkExits(bundleLocation)) {
throw new IllegalArgumentException(
"bundleLocation not found: " + bundleLocation + " for artifact " + artifact);
}
return manifestReader.loadManifest(bundleLocation);
}

private boolean checkExits(File bundleLocation) {
if (bundleLocation.exists()) {
return true;
}
//especially on windows there can be delayed writes that ruin our day, just to be sure wait a little bit if the file really do not exits!
long deadLine = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(5);
while (System.currentTimeMillis() < deadLine) {
if (bundleLocation.exists()) {
return true;
}
Thread.onSpinWait();
}
return bundleLocation.exists();
}

}

0 comments on commit 1a41b23

Please sign in to comment.