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

Improve RepositoryHelper.getSharedBundlePools() to avoid exceptions #379

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.eclipse.equinox.internal.p2.repository.helpers;

import java.io.File;
import java.io.IOException;
import java.net.*;
import java.nio.charset.Charset;
import java.nio.file.Files;
Expand Down Expand Up @@ -149,18 +148,18 @@ public static <T> IRepository<T> createMemoryComposite(IProvisioningAgent agent,
* the Eclipse Installer.
*
* @return an unmodifiable list of global shared bundle pools.
*
* @throws IOException if there are problems loading the pool information.
*/
@SuppressWarnings("nls")
public static List<Path> getSharedBundlePools() throws IOException {
Path bundlePools = Path.of(System.getProperty("user.home"), ".p2/pools.info");
if (Files.isRegularFile(bundlePools)) {
try (Stream<String> lines = Files.lines(bundlePools, getSharedBundlePoolEncoding())) {
return lines.map(Path::of).filter(Files::isDirectory).toList();
}
public static List<Path> getSharedBundlePools() {
Path bundlePools = Path.of(System.getProperty("user.home"), ".p2/pools.info");
if (Files.isRegularFile(bundlePools)) {
try (Stream<String> lines = Files.lines(bundlePools, getSharedBundlePoolEncoding())) {
return lines.map(Path::of).filter(Files::isDirectory).toList();
} catch (Exception ex) {
LogHelper.log(Status.warning("The bundle pool load failed: " + bundlePools, ex));
}
return List.of();
}
return List.of();
}

@SuppressWarnings("nls")
Expand Down
Loading