From ada2aa987c7a2bfc0d094a97c512bdb0dc92f744 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 --- .../internal/p2/repository/helpers/RepositoryHelper.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 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..da8cce95a1 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,15 +148,16 @@ 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 { + 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();