diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF index 5df6b28dc4..183253da81 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.artifact.repository;singleton:=true -Bundle-Version: 1.5.500.qualifier +Bundle-Version: 1.5.600.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.artifact.repository.Activator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/DownloadJob.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/DownloadJob.java index 62627e197b..f4c5b89c99 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/DownloadJob.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/DownloadJob.java @@ -56,17 +56,12 @@ protected IStatus run(IProgressMonitor jobMonitor) { if (masterMonitor.isCanceled()) return Status.CANCEL_STATUS; // process the actual request - SubMonitor subMonitor = SubMonitor.convert(masterMonitor, 1); - subMonitor.beginTask("", 1); //$NON-NLS-1$ - try { - IStatus status = repository.getArtifact(request, subMonitor); - if (!status.isOK()) { - synchronized (overallStatus) { - overallStatus.add(status); - } + SubMonitor subMonitor = SubMonitor.convert(masterMonitor.slice(1), 1); + IStatus status = repository.getArtifact(request, subMonitor); + if (!status.isOK()) { + synchronized (overallStatus) { + overallStatus.add(status); } - } finally { - subMonitor.done(); } } while (true); diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF index 46e7c93948..c4ecf69565 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.equinox.p2.discovery.compatibility;singleton:=true -Bundle-Version: 1.3.500.qualifier +Bundle-Version: 1.3.600.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0", diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java index 6a5114060a..d6974847ff 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/BundleDiscoveryStrategy.java @@ -42,13 +42,11 @@ public void performDiscovery(IProgressMonitor monitor) throws CoreException { } IExtensionPoint extensionPoint = getExtensionRegistry().getExtensionPoint(ConnectorDiscoveryExtensionReader.EXTENSION_POINT_ID); IExtension[] extensions = extensionPoint.getExtensions(); - monitor.beginTask(Messages.BundleDiscoveryStrategy_task_loading_local_extensions, extensions.length == 0 ? 1 : extensions.length); - try { - if (extensions.length > 0) { - processExtensions(SubMonitor.convert(monitor, extensions.length), extensions); - } - } finally { - monitor.done(); + SubMonitor subMonitor = SubMonitor.convert(monitor, + Messages.BundleDiscoveryStrategy_task_loading_local_extensions, + extensions.length == 0 ? 1 : extensions.length); + if (extensions.length > 0) { + processExtensions(subMonitor.newChild(extensions.length), extensions); } } diff --git a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java index d08a5a5d7e..5dadc9b471 100644 --- a/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java +++ b/bundles/org.eclipse.equinox.p2.discovery.compatibility/src/org/eclipse/equinox/internal/p2/discovery/compatibility/RemoteBundleDiscoveryStrategy.java @@ -55,125 +55,121 @@ public void performDiscovery(IProgressMonitor monitor) throws CoreException { final int totalTicks = 100000; final int ticksTenPercent = totalTicks / 10; - monitor.beginTask(Messages.RemoteBundleDiscoveryStrategy_task_remote_discovery, totalTicks); + SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.RemoteBundleDiscoveryStrategy_task_remote_discovery, totalTicks); + File registryCacheFolder; try { - File registryCacheFolder; - try { - if (temporaryStorage != null && temporaryStorage.exists()) { - delete(temporaryStorage); - } - temporaryStorage = File.createTempFile(RemoteBundleDiscoveryStrategy.class.getSimpleName(), ".tmp"); //$NON-NLS-1$ - temporaryStorage.delete(); - if (!temporaryStorage.mkdirs()) { - throw new IOException(); - } - registryCacheFolder = new File(temporaryStorage, ".rcache"); //$NON-NLS-1$ - if (!registryCacheFolder.mkdirs()) { - throw new IOException(); - } - } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_io_failure_temp_storage, e)); + if (temporaryStorage != null && temporaryStorage.exists()) { + delete(temporaryStorage); } - if (monitor.isCanceled()) { - return; - } - - Directory directory; - try { - final Directory[] temp = new Directory[1]; - TransportUtil.readResource(new URI(directoryUrl), reader -> { - DirectoryParser parser = new DirectoryParser(); - temp[0] = parser.parse(reader); - }, SubMonitor.convert(monitor, ticksTenPercent)); - directory = temp[0]; - if (directory == null) { - throw new IllegalStateException(); - } - } catch (UnknownHostException e) { - throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.RemoteBundleDiscoveryStrategy_unknown_host_discovery_directory, e.getMessage()), e)); - } catch (URISyntaxException e) { - throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.RemoteBundleDiscoveryStrategy_Invalid_source_specified_Error, directoryUrl), e)); - } catch (IOException e) { - throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_io_failure_discovery_directory, e)); + temporaryStorage = File.createTempFile(RemoteBundleDiscoveryStrategy.class.getSimpleName(), ".tmp"); //$NON-NLS-1$ + temporaryStorage.delete(); + if (!temporaryStorage.mkdirs()) { + throw new IOException(); } - if (monitor.isCanceled()) { - return; + registryCacheFolder = new File(temporaryStorage, ".rcache"); //$NON-NLS-1$ + if (!registryCacheFolder.mkdirs()) { + throw new IOException(); } - if (directory.getEntries().isEmpty()) { - throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_empty_directory)); + } catch (IOException e) { + throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_io_failure_temp_storage, e)); + } + if (subMonitor.isCanceled()) { + return; + } + + Directory directory; + try { + final Directory[] temp = new Directory[1]; + TransportUtil.readResource(new URI(directoryUrl), reader -> { + DirectoryParser parser = new DirectoryParser(); + temp[0] = parser.parse(reader); + }, subMonitor.newChild(ticksTenPercent)); + directory = temp[0]; + if (directory == null) { + throw new IllegalStateException(); } + } catch (UnknownHostException e) { + throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.RemoteBundleDiscoveryStrategy_unknown_host_discovery_directory, e.getMessage()), e)); + } catch (URISyntaxException e) { + throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.RemoteBundleDiscoveryStrategy_Invalid_source_specified_Error, directoryUrl), e)); + } catch (IOException e) { + throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_io_failure_discovery_directory, e)); + } + if (subMonitor.isCanceled()) { + return; + } + if (directory.getEntries().isEmpty()) { + throw new CoreException(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_empty_directory)); + } - Map bundleFileToDirectoryEntry = new HashMap<>(); + Map bundleFileToDirectoryEntry = new HashMap<>(); - ExecutorService executorService = createExecutorService(directory.getEntries().size()); - try { - List> futures = new ArrayList<>(); - // submit jobs - for (Directory.Entry entry : directory.getEntries()) { - futures.add(executorService.submit(new DownloadBundleJob(entry, monitor))); - } - int futureSize = ticksTenPercent * 4 / directory.getEntries().size(); - // collect job results - for (Future job : futures) { - try { - DownloadBundleJob bundleJob; - for (;;) { - try { - bundleJob = job.get(1L, TimeUnit.SECONDS); - break; - } catch (TimeoutException e) { - if (monitor.isCanceled()) { - return; - } + ExecutorService executorService = createExecutorService(directory.getEntries().size()); + try { + List> futures = new ArrayList<>(); + // submit jobs + for (Directory.Entry entry : directory.getEntries()) { + futures.add(executorService.submit(new DownloadBundleJob(entry, subMonitor))); + } + int futureSize = ticksTenPercent * 4 / directory.getEntries().size(); + // collect job results + for (Future job : futures) { + try { + DownloadBundleJob bundleJob; + for (;;) { + try { + bundleJob = job.get(1L, TimeUnit.SECONDS); + break; + } catch (TimeoutException e) { + if (subMonitor.isCanceled()) { + return; } } - if (bundleJob.file != null) { - bundleFileToDirectoryEntry.put(bundleJob.file, bundleJob.entry); - } - monitor.worked(futureSize); - } catch (ExecutionException e) { - Throwable cause = e.getCause(); - if (cause instanceof OperationCanceledException) { - monitor.setCanceled(true); - return; - } - IStatus status; - if (cause instanceof CoreException) { - status = ((CoreException) cause).getStatus(); - } else { - status = new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_unexpectedError, cause); - } - // log errors but continue on - LogHelper.log(status); - } catch (InterruptedException e) { - monitor.setCanceled(true); + } + if (bundleJob.file != null) { + bundleFileToDirectoryEntry.put(bundleJob.file, bundleJob.entry); + } + subMonitor.worked(futureSize); + } catch (ExecutionException e) { + Throwable cause = e.getCause(); + if (cause instanceof OperationCanceledException) { + subMonitor.setCanceled(true); return; } + IStatus status; + if (cause instanceof CoreException) { + status = ((CoreException) cause).getStatus(); + } else { + status = new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, Messages.RemoteBundleDiscoveryStrategy_unexpectedError, cause); + } + // log errors but continue on + LogHelper.log(status); + } catch (InterruptedException e) { + subMonitor.setCanceled(true); + return; } - } finally { - executorService.shutdownNow(); } + } finally { + executorService.shutdownNow(); + } + try { + registryStrategy = new DiscoveryRegistryStrategy(new File[] {registryCacheFolder}, new boolean[] {false}, this); + registryStrategy.setBundles(bundleFileToDirectoryEntry); + IExtensionRegistry extensionRegistry = new ExtensionRegistry(registryStrategy, this, this); try { - registryStrategy = new DiscoveryRegistryStrategy(new File[] {registryCacheFolder}, new boolean[] {false}, this); - registryStrategy.setBundles(bundleFileToDirectoryEntry); - IExtensionRegistry extensionRegistry = new ExtensionRegistry(registryStrategy, this, this); - try { - IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ConnectorDiscoveryExtensionReader.EXTENSION_POINT_ID); - if (extensionPoint != null) { - IExtension[] extensions = extensionPoint.getExtensions(); - if (extensions.length > 0) { - processExtensions(SubMonitor.convert(monitor, ticksTenPercent * 3), extensions); - } + IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(ConnectorDiscoveryExtensionReader.EXTENSION_POINT_ID); + if (extensionPoint != null) { + IExtension[] extensions = extensionPoint.getExtensions(); + if (extensions.length > 0) { + processExtensions(subMonitor.newChild(ticksTenPercent * 3), extensions); } - } finally { - extensionRegistry.stop(this); } } finally { - registryStrategy = null; + extensionRegistry.stop(this); } } finally { - monitor.done(); + registryStrategy = null; } } diff --git a/bundles/org.eclipse.equinox.p2.discovery/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.discovery/META-INF/MANIFEST.MF index e0e2f51390..d494b0bf45 100644 --- a/bundles/org.eclipse.equinox.p2.discovery/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.discovery/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.equinox.p2.discovery;singleton:=true -Bundle-Version: 1.3.400.qualifier +Bundle-Version: 1.3.500.qualifier Bundle-Vendor: %Bundle-Vendor Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0", diff --git a/bundles/org.eclipse.equinox.p2.discovery/src/org/eclipse/equinox/internal/p2/discovery/Catalog.java b/bundles/org.eclipse.equinox.p2.discovery/src/org/eclipse/equinox/internal/p2/discovery/Catalog.java index 085f7d938b..d19e91fbe0 100644 --- a/bundles/org.eclipse.equinox.p2.discovery/src/org/eclipse/equinox/internal/p2/discovery/Catalog.java +++ b/bundles/org.eclipse.equinox.p2.discovery/src/org/eclipse/equinox/internal/p2/discovery/Catalog.java @@ -73,28 +73,24 @@ public IStatus performDiscovery(IProgressMonitor monitor) { final int totalTicks = 100000; final int discoveryTicks = totalTicks - (totalTicks / 10); - monitor.beginTask(Messages.Catalog_task_discovering_connectors, totalTicks); - try { - for (AbstractDiscoveryStrategy discoveryStrategy : discoveryStrategies) { - if (monitor.isCanceled()) { - status.add(Status.CANCEL_STATUS); - break; - } - discoveryStrategy.setCategories(newCategories); - discoveryStrategy.setItems(newItems); - discoveryStrategy.setCertifications(newCertifications); - discoveryStrategy.setTags(newTags); - try { - discoveryStrategy.performDiscovery(SubMonitor.convert(monitor, discoveryTicks / discoveryStrategies.size())); - } catch (CoreException e) { - status.add(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.Catalog_Strategy_failed_Error, discoveryStrategy.getClass().getSimpleName()), e)); - } + SubMonitor subMonitor = SubMonitor.convert(monitor, Messages.Catalog_task_discovering_connectors, totalTicks); + for (AbstractDiscoveryStrategy discoveryStrategy : discoveryStrategies) { + if (subMonitor.isCanceled()) { + status.add(Status.CANCEL_STATUS); + break; + } + discoveryStrategy.setCategories(newCategories); + discoveryStrategy.setItems(newItems); + discoveryStrategy.setCertifications(newCertifications); + discoveryStrategy.setTags(newTags); + try { + discoveryStrategy.performDiscovery(subMonitor.newChild(discoveryTicks / discoveryStrategies.size())); + } catch (CoreException e) { + status.add(new Status(IStatus.ERROR, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.Catalog_Strategy_failed_Error, discoveryStrategy.getClass().getSimpleName()), e)); } - - update(newCategories, newItems, newCertifications, newTags); - } finally { - monitor.done(); } + + update(newCategories, newItems, newCertifications, newTags); return status; } diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF index 6e526b259d..453d5aafac 100644 --- a/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.transport.ecf/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.equinox.p2.transport.ecf -Bundle-Version: 1.4.300.qualifier +Bundle-Version: 1.4.400.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.ecf;bundle-version="3.1.0", org.eclipse.ecf.filetransfer;bundle-version="4.0.0", diff --git a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java index 0d801fd5bb..62ddecdc29 100644 --- a/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java +++ b/bundles/org.eclipse.equinox.p2.transport.ecf/src/org/eclipse/equinox/internal/p2/transport/ecf/FileReader.java @@ -47,7 +47,7 @@ public final class FileReader extends FileTransferJob implements IFileTransferLi */ static class SuppressBlockedMonitor extends ProgressMonitorWrapper { public SuppressBlockedMonitor(IProgressMonitor monitor, int ticks) { - super(SubMonitor.convert(monitor, ticks)); + super(monitor.slice(ticks)); } @Override diff --git a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF index cdb0eafd64..f41eefc5ac 100644 --- a/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %bundleName Bundle-SymbolicName: org.eclipse.equinox.p2.ui;singleton:=true -Bundle-Version: 2.8.600.qualifier +Bundle-Version: 2.8.700.qualifier Bundle-Activator: org.eclipse.equinox.internal.p2.ui.ProvUIActivator Bundle-Vendor: %providerName Bundle-Localization: plugin diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java index fbab6b672b..4ae5e11d62 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/query/QueryableUpdates.java @@ -43,24 +43,21 @@ public IQueryResult query(IQuery query, IPro if (monitor == null) monitor = new NullProgressMonitor(); int totalWork = 2000; - monitor.beginTask(ProvUIMessages.QueryableUpdates_UpdateListProgress, totalWork); + SubMonitor subMonitor = SubMonitor.convert(monitor, ProvUIMessages.QueryableUpdates_UpdateListProgress, + totalWork); IPlanner planner = ui.getSession().getProvisioningAgent().getService(IPlanner.class); try { Set allUpdates = new HashSet<>(); for (IInstallableUnit unit : iusToUpdate) { - if (monitor.isCanceled()) - return Collector.emptyCollector(); IQueryResult updates = planner.updatesFor(unit, new ProvisioningContext(ui.getSession().getProvisioningAgent()), - SubMonitor.convert(monitor, totalWork / 2 / iusToUpdate.length)); + subMonitor.split(totalWork / 2 / iusToUpdate.length)); allUpdates.addAll(updates.toUnmodifiableSet()); } return query.perform(allUpdates.iterator()); } catch (OperationCanceledException e) { // Nothing more to do, return result return Collector.emptyCollector(); - } finally { - monitor.done(); } } }