Skip to content

Commit

Permalink
Improve RepositoryHelper.getSharedBundlePools() to avoid exceptions
Browse files Browse the repository at this point in the history
Just log an exception and return an empty list in the unlikely event of
failure.

#373
  • Loading branch information
merks committed Nov 5, 2023
1 parent e31c371 commit 79ecebd
Showing 1 changed file with 10 additions and 10 deletions.
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,19 @@ 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(
new Status(IStatus.WARNING, Activator.ID, "The bundle pool load failed: " + bundlePools, ex));
}
return List.of();
}
return List.of();
}

@SuppressWarnings("nls")
Expand Down

0 comments on commit 79ecebd

Please sign in to comment.