Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try fixing bundle location not found #2277

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}

}