From 79ecebd55baf88670d42c87a4fc8bf8e3f303ab9 Mon Sep 17 00:00:00 2001 From: Ed Merks Date: Sun, 5 Nov 2023 15:41:29 +0100 Subject: [PATCH] Improve RepositoryHelper.getSharedBundlePools() to avoid exceptions Just log an exception and return an empty list in the unlikely event of failure. https://github.com/eclipse-equinox/p2/issues/373 --- .../repository/helpers/RepositoryHelper.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java index d884003493..c13b13fefd 100644 --- a/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java +++ b/bundles/org.eclipse.equinox.p2.repository/src/org/eclipse/equinox/internal/p2/repository/helpers/RepositoryHelper.java @@ -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; @@ -149,18 +148,19 @@ public static IRepository 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 getSharedBundlePools() throws IOException { - Path bundlePools = Path.of(System.getProperty("user.home"), ".p2/pools.info"); - if (Files.isRegularFile(bundlePools)) { - try (Stream lines = Files.lines(bundlePools, getSharedBundlePoolEncoding())) { - return lines.map(Path::of).filter(Files::isDirectory).toList(); - } + public static List getSharedBundlePools() { + Path bundlePools = Path.of(System.getProperty("user.home"), ".p2/pools.info"); + if (Files.isRegularFile(bundlePools)) { + try (Stream 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")