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.

eclipse-equinox#373
  • Loading branch information
merks committed Nov 5, 2023
1 parent e31c371 commit ada2aa9
Showing 1 changed file with 4 additions and 4 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,15 +148,16 @@ 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 {
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();
Expand Down

0 comments on commit ada2aa9

Please sign in to comment.