From a1592a0251c8f852846424ca1893e55947093750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Tue, 26 Sep 2023 18:02:51 +0200 Subject: [PATCH] fix IProgressMonitor usage #335 passing a monitor to two callees requires it to be splitted. https://github.com/eclipse-equinox/p2/issues/335 Also fixed forgotten monitor.done() in performProvisioningPlan and improved tests. --- .../artifact/repository/RawMirrorRequest.java | 94 +++++++++------- .../simple/SimpleArtifactRepository.java | 103 +++++++++-------- .../equinox/internal/p2/engine/Engine.java | 12 +- .../p2/operations/ProfileChangeOperation.java | 28 +++-- .../p2/operations/ProfileModificationJob.java | 4 +- .../p2/operations/ProvisioningSession.java | 106 ++++++++++-------- .../tests/ui/AbstractProvisioningUITest.java | 14 ++- .../p2/tests/ui/dialogs/UpdateWizardTest.java | 5 +- .../p2/tests/AbstractProvisioningTest.java | 4 +- 9 files changed, 208 insertions(+), 162 deletions(-) diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java index 823bfc6479..bb573f2c8a 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java @@ -46,39 +46,43 @@ public RawMirrorRequest(IArtifactDescriptor sourceDescriptor, IArtifactDescripto @Override public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) { - monitor.subTask(NLS.bind(Messages.downloading, getArtifactKey().getId())); - setSourceRepository(sourceRepository); - // Do we already have the descriptor in the target? - if (target.contains(targetDescriptor)) { - setResult(new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.mirror_alreadyExists, targetDescriptor, target))); - return; - } - // Does the source actually have the descriptor? - if (!source.contains(getArtifactDescriptor())) { - setResult(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.artifact_not_found, getArtifactKey()))); - return; - } - IStatus status = transfer(targetDescriptor, sourceDescriptor, monitor); + SubMonitor subMon = SubMonitor.convert(monitor,NLS.bind(Messages.downloading, getArtifactKey().getId()),1); + try { + setSourceRepository(sourceRepository); + // Do we already have the descriptor in the target? + if (target.contains(targetDescriptor)) { + setResult(new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.mirror_alreadyExists, targetDescriptor, target))); + return; + } + // Does the source actually have the descriptor? + if (!source.contains(getArtifactDescriptor())) { + setResult(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.artifact_not_found, getArtifactKey()))); + return; + } + IStatus status = transfer(targetDescriptor, sourceDescriptor, subMon.split(1)); - // if ok, cancelled or transfer has already been done with the canonical form return with status set - if (status.getSeverity() == IStatus.CANCEL) { - setResult(status); - return; - } - if (monitor.isCanceled()) { - setResult(Status.CANCEL_STATUS); - return; - } - if (status.isOK()) { - setResult(status); - return; - } + // if ok, cancelled or transfer has already been done with the canonical form return with status set + if (status.getSeverity() == IStatus.CANCEL) { + setResult(status); + return; + } + if (monitor.isCanceled()) { + setResult(Status.CANCEL_STATUS); + return; + } + if (status.isOK()) { + setResult(status); + return; + } - // failed, first remove possibly erroneously added descriptor - if (target.contains(targetDescriptor)) - target.removeDescriptor(targetDescriptor); + // failed, first remove possibly erroneously added descriptor + if (target.contains(targetDescriptor)) + target.removeDescriptor(targetDescriptor); - setResult(status); + setResult(status); + } finally { + subMon.done(); + } } public IArtifactDescriptor getArtifactDescriptor() { @@ -88,19 +92,25 @@ public IArtifactDescriptor getArtifactDescriptor() { // Perform the mirror operation without any processing steps @Override protected IStatus getArtifact(IArtifactDescriptor artifactDescriptor, OutputStream destination, IProgressMonitor monitor) { - if (SimpleArtifactRepository.CHECKSUMS_ENABLED) { - Collection steps = ChecksumUtilities.getChecksumVerifiers(artifactDescriptor, - IArtifactDescriptor.DOWNLOAD_CHECKSUM, Collections.emptySet()); - if (steps.isEmpty()) { - LogHelper.log(new Status(IStatus.WARNING, Activator.ID, - NLS.bind(Messages.noDigestAlgorithmToVerifyDownload, artifactDescriptor.getArtifactKey()))); + monitor = IProgressMonitor.nullSafe(monitor); + try { + SubMonitor subMon = SubMonitor.convert(monitor, 2); + if (SimpleArtifactRepository.CHECKSUMS_ENABLED) { + Collection steps = ChecksumUtilities.getChecksumVerifiers(artifactDescriptor, + IArtifactDescriptor.DOWNLOAD_CHECKSUM, Collections.emptySet()); + if (steps.isEmpty()) { + LogHelper.log(new Status(IStatus.WARNING, Activator.ID, + NLS.bind(Messages.noDigestAlgorithmToVerifyDownload, artifactDescriptor.getArtifactKey()))); + } + ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]); + // TODO should probably be using createAndLink here + ProcessingStepHandler handler = new ProcessingStepHandler(); + destination = handler.link(stepArray, destination, subMon.split(1)); } - ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]); - // TODO should probably be using createAndLink here - ProcessingStepHandler handler = new ProcessingStepHandler(); - destination = handler.link(stepArray, destination, monitor); + subMon.setWorkRemaining(1); + return getSourceRepository().getRawArtifact(artifactDescriptor, destination, subMon.split(1)); + } finally { + monitor.done(); } - - return getSourceRepository().getRawArtifact(artifactDescriptor, destination, monitor); } } diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java index a03cf5a08e..ed4905ef41 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java @@ -615,58 +615,63 @@ private boolean doRemoveArtifact(IArtifactDescriptor descriptor) { protected IStatus downloadArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { monitor = IProgressMonitor.nullSafe(monitor); - if (isFolderBased(descriptor)) { - File artifactFolder = getArtifactFile(descriptor); - if (artifactFolder == null) { - if (getLocation(descriptor) != null && !URIUtil.isFileURI(getLocation(descriptor))) - return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.folder_artifact_not_file_repo, descriptor.getArtifactKey()))); - return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.artifact_not_found, descriptor.getArtifactKey()))); - } - // TODO: optimize and ensure manifest is written first - File zipFile = null; - long start = System.currentTimeMillis(); - long totalArtifactSize = 0; - try { - zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null); - FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder)); - FileInputStream fis = new FileInputStream(zipFile); - totalArtifactSize += FileUtils.copyStream(fis, true, destination, false); - } catch (IOException e) { - return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e)); - } finally { - if (zipFile != null) - zipFile.delete(); - } - long end = System.currentTimeMillis(); - DownloadStatus statusWithDownloadSpeed = new DownloadStatus(IStatus.OK, Activator.ID, Status.OK_STATUS.getMessage()); - try { - statusWithDownloadSpeed.setFileSize(totalArtifactSize); - statusWithDownloadSpeed.setTransferRate(totalArtifactSize / Math.max((end - start), 1) * 1000); - } catch (NumberFormatException e) { - // ignore + try { + SubMonitor subMon = SubMonitor.convert(monitor, 2); + if (isFolderBased(descriptor)) { + File artifactFolder = getArtifactFile(descriptor); + if (artifactFolder == null) { + if (getLocation(descriptor) != null && !URIUtil.isFileURI(getLocation(descriptor))) + return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.folder_artifact_not_file_repo, descriptor.getArtifactKey()))); + return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.artifact_not_found, descriptor.getArtifactKey()))); + } + // TODO: optimize and ensure manifest is written first + File zipFile = null; + long start = System.currentTimeMillis(); + long totalArtifactSize = 0; + try { + zipFile = File.createTempFile(artifactFolder.getName(), JAR_EXTENSION, null); + FileUtils.zip(artifactFolder.listFiles(), null, zipFile, FileUtils.createRootPathComputer(artifactFolder)); + FileInputStream fis = new FileInputStream(zipFile); + totalArtifactSize += FileUtils.copyStream(fis, true, destination, false); + } catch (IOException e) { + return reportStatus(descriptor, destination, new Status(IStatus.ERROR, Activator.ID, e.getMessage(), e)); + } finally { + if (zipFile != null) + zipFile.delete(); + } + long end = System.currentTimeMillis(); + DownloadStatus statusWithDownloadSpeed = new DownloadStatus(IStatus.OK, Activator.ID, Status.OK_STATUS.getMessage()); + try { + statusWithDownloadSpeed.setFileSize(totalArtifactSize); + statusWithDownloadSpeed.setTransferRate(totalArtifactSize / Math.max((end - start), 1) * 1000); + } catch (NumberFormatException e) { + // ignore + } + return reportStatus(descriptor, destination, statusWithDownloadSpeed); } - return reportStatus(descriptor, destination, statusWithDownloadSpeed); - } - - //download from the best available mirror - URI baseLocation = getLocation(descriptor); - if (baseLocation == null) - return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.no_location, descriptor)); - URI mirrorLocation = getMirror(baseLocation, monitor); - IStatus status = downloadArtifact(mirrorLocation, destination, monitor); - IStatus result = reportStatus(descriptor, destination, status); - // if the original download went reasonably but the reportStatus found some issues - // (e..g, in the processing steps/validators) then mark the mirror as bad and return - // a retry code (assuming we have more mirrors) - if ((status.isOK() || status.matches(IStatus.INFO | IStatus.WARNING)) && result.getSeverity() == IStatus.ERROR && !artifactError(result)) { - if (mirrors != null) { - mirrors.reportResult(mirrorLocation.toString(), result); - if (mirrors.hasValidMirror()) - return new MultiStatus(Activator.ID, CODE_RETRY, new IStatus[] {result}, "Retry another mirror", null); //$NON-NLS-1$ + + //download from the best available mirror + URI baseLocation = getLocation(descriptor); + if (baseLocation == null) + return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.no_location, descriptor)); + URI mirrorLocation = getMirror(baseLocation, subMon.split(1)); + IStatus status = downloadArtifact(mirrorLocation, destination, subMon.split(1)); + IStatus result = reportStatus(descriptor, destination, status); + // if the original download went reasonably but the reportStatus found some issues + // (e..g, in the processing steps/validators) then mark the mirror as bad and return + // a retry code (assuming we have more mirrors) + if ((status.isOK() || status.matches(IStatus.INFO | IStatus.WARNING)) && result.getSeverity() == IStatus.ERROR && !artifactError(result)) { + if (mirrors != null) { + mirrors.reportResult(mirrorLocation.toString(), result); + if (mirrors.hasValidMirror()) + return new MultiStatus(Activator.ID, CODE_RETRY, new IStatus[] {result}, "Retry another mirror", null); //$NON-NLS-1$ + } } + // if the original status was a retry, don't lose that. + return status.getCode() == CODE_RETRY ? status : result; + } finally { + monitor.done(); } - // if the original status was a retry, don't lose that. - return status.getCode() == CODE_RETRY ? status : result; } /** diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java index 481705f531..3669861af9 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java @@ -71,6 +71,7 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, Profile profile = profileRegistry.validate(iprofile); profileRegistry.lockProfile(profile); + SubMonitor subMon = SubMonitor.convert(monitor, 3); try { eventBus.publishEvent(new BeginOperationEvent(profile, phaseSet, operands, this)); if (DebugHelper.DEBUG_ENGINE) @@ -91,17 +92,17 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, } context.setProperty(ProvisioningContext.CHECK_AUTHORITIES, property); } - - MultiStatus result = phaseSet.perform(session, operands, monitor); + MultiStatus result = phaseSet.perform(session, operands, subMon.split(1)); if (result.isOK() || result.matches(IStatus.INFO | IStatus.WARNING)) { if (DebugHelper.DEBUG_ENGINE) DebugHelper.debug(ENGINE, "Preparing to commit engine operation for profile=" + profile.getProfileId()); //$NON-NLS-1$ - result.merge(session.prepare(monitor)); + result.merge(session.prepare(subMon.split(1))); } + subMon.setWorkRemaining(1); if (result.matches(IStatus.ERROR | IStatus.CANCEL)) { if (DebugHelper.DEBUG_ENGINE) DebugHelper.debug(ENGINE, "Rolling back engine operation for profile=" + profile.getProfileId() + ". Reason was: " + result.toString()); //$NON-NLS-1$ //$NON-NLS-2$ - IStatus status = session.rollback(monitor, result.getSeverity()); + IStatus status = session.rollback(subMon.split(1), result.getSeverity()); if (status.matches(IStatus.ERROR)) LogHelper.log(status); eventBus.publishEvent(new RollbackOperationEvent(profile, phaseSet, operands, this, result)); @@ -110,7 +111,7 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, DebugHelper.debug(ENGINE, "Committing engine operation for profile=" + profile.getProfileId()); //$NON-NLS-1$ if (profile.isChanged()) profileRegistry.updateProfile(profile); - IStatus status = session.commit(monitor); + IStatus status = session.commit(subMon.split(1)); if (status.matches(IStatus.ERROR)) LogHelper.log(status); eventBus.publishEvent(new CommitOperationEvent(profile, phaseSet, operands, this)); @@ -121,6 +122,7 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, } finally { profileRegistry.unlockProfile(profile); profile.setChanged(false); + monitor.done(); } } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java index 48e9a7658e..4fffd5c738 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java @@ -110,18 +110,24 @@ protected ProfileChangeOperation(ProvisioningSession session) { * @return a status describing the resolution results */ public final IStatus resolveModal(IProgressMonitor monitor) { - if (monitor == null) - monitor = new NullProgressMonitor(); - prepareToResolve(); - makeResolveJob(monitor); - if (job != null) { - IStatus status = job.runModal(monitor); - if (status.getSeverity() == IStatus.CANCEL) - return Status.CANCEL_STATUS; + try { + if (monitor == null) + monitor = new NullProgressMonitor(); + prepareToResolve(); + SubMonitor subMon = SubMonitor.convert(monitor, 2); + makeResolveJob(subMon.split(1)); + if (job != null) { + IStatus status = job.runModal(subMon.split(1)); + if (status.getSeverity() == IStatus.CANCEL) + return Status.CANCEL_STATUS; + } + // For anything other than cancellation, we examine the artifacts of the + // resolution and come + // up with an overall summary. + return getResolutionResult(); + } finally { + monitor.done(); } - // For anything other than cancellation, we examine the artifacts of the resolution and come - // up with an overall summary. - return getResolutionResult(); } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java index 27e73c8405..59d85cfce3 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java @@ -71,9 +71,9 @@ public IStatus runModal(IProgressMonitor monitor) { IStatus status = Status.OK_STATUS; if (task == null) task = getName(); - monitor.beginTask(task, 1000); try { - status = getSession().performProvisioningPlan(plan, phaseSet, provisioningContext, SubMonitor.convert(monitor, 1000)); + status = getSession().performProvisioningPlan(plan, phaseSet, provisioningContext, + SubMonitor.convert(monitor, task, 1000)); } finally { monitor.done(); } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java index b597b82c6c..9be0a470ee 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java @@ -127,57 +127,69 @@ IPlanner getPlanner() { * @param monitor the progress monitor to use while performing the plan * @return a status describing the result of performing the plan */ - public IStatus performProvisioningPlan(IProvisioningPlan plan, IPhaseSet phaseSet, ProvisioningContext context, IProgressMonitor monitor) { - IPhaseSet set; - if (phaseSet == null) - set = PhaseSetFactory.createDefaultPhaseSet(); - else - set = phaseSet; - - // 300 ticks for download, 100 to install handlers, 100 to compute the plan, 100 to install the rest - SubMonitor mon = SubMonitor.convert(monitor, 600); - int ticksUsed = 0; - - // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=272355 - // The exact profile instance used in the profile change request and passed to the engine must be used for all - // of these operations, otherwise we can get profile out of synch errors. - IProfile profile = plan.getProfile(); - - if (plan.getInstallerPlan() != null) { - if (doesPhaseSetIncludeDownload(set)) { - // If the phase set calls for download, then we want to download the install plan artifacts - // at the same time as the actual install artifacts. This way, we will only install the install handler - // after already knowing we have successfully obtained the artifacts that will be installed afterward. - IProvisioningPlan downloadPlan = getEngine().createPlan(profile, context); - for (IInstallableUnit element : QueryUtil.compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()).query(QueryUtil.createIUAnyQuery(), null)) { - downloadPlan.addInstallableUnit(element); + public IStatus performProvisioningPlan(IProvisioningPlan plan, IPhaseSet phaseSet, ProvisioningContext context, + IProgressMonitor monitor) { + try { + IPhaseSet set; + if (phaseSet == null) + set = PhaseSetFactory.createDefaultPhaseSet(); + else + set = phaseSet; + + // 300 ticks for download, 100 to install handlers, 100 to compute the plan, 100 + // to install the rest + SubMonitor mon = SubMonitor.convert(monitor, 600); + int ticksUsed = 0; + + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=272355 + // The exact profile instance used in the profile change request and passed to + // the engine must be used for all + // of these operations, otherwise we can get profile out of synch errors. + IProfile profile = plan.getProfile(); + + if (plan.getInstallerPlan() != null) { + if (doesPhaseSetIncludeDownload(set)) { + // If the phase set calls for download, then we want to download the install + // plan artifacts + // at the same time as the actual install artifacts. This way, we will only + // install the install handler + // after already knowing we have successfully obtained the artifacts that will + // be installed afterward. + IProvisioningPlan downloadPlan = getEngine().createPlan(profile, context); + for (IInstallableUnit element : QueryUtil + .compoundQueryable(plan.getAdditions(), plan.getInstallerPlan().getAdditions()) + .query(QueryUtil.createIUAnyQuery(), null)) { + downloadPlan.addInstallableUnit(element); + } + IPhaseSet download = PhaseSetFactory + .createPhaseSetIncluding(new String[] { PhaseSetFactory.PHASE_COLLECT }); + IStatus downloadStatus = getEngine().perform(downloadPlan, download, mon.newChild(300)); + if (!downloadStatus.isOK()) { + return downloadStatus; + } + ticksUsed = 300; } - IPhaseSet download = PhaseSetFactory.createPhaseSetIncluding(new String[] {PhaseSetFactory.PHASE_COLLECT}); - IStatus downloadStatus = getEngine().perform(downloadPlan, download, mon.newChild(300)); - if (!downloadStatus.isOK()) { - mon.done(); - return downloadStatus; + // we pre-downloaded if necessary. Now perform the install plan against the + // original phase set. + IStatus installerPlanStatus = getEngine().perform(plan.getInstallerPlan(), set, mon.newChild(100)); + if (!installerPlanStatus.isOK()) { + return installerPlanStatus; + } + ticksUsed += 100; + // Apply the configuration + BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + Configurator configChanger = ServiceHelper.getService(bundleContext, Configurator.class); + try { + configChanger.applyConfiguration(); + } catch (IOException e) { + return new Status(IStatus.ERROR, Constants.BUNDLE_ID, + Messages.ProvisioningSession_InstallPlanConfigurationError, e); } - ticksUsed = 300; - } - // we pre-downloaded if necessary. Now perform the install plan against the original phase set. - IStatus installerPlanStatus = getEngine().perform(plan.getInstallerPlan(), set, mon.newChild(100)); - if (!installerPlanStatus.isOK()) { - mon.done(); - return installerPlanStatus; - } - ticksUsed += 100; - // Apply the configuration - BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); - Configurator configChanger = ServiceHelper.getService(bundleContext, Configurator.class); - try { - configChanger.applyConfiguration(); - } catch (IOException e) { - mon.done(); - return new Status(IStatus.ERROR, Constants.BUNDLE_ID, Messages.ProvisioningSession_InstallPlanConfigurationError, e); } + return getEngine().perform(plan, set, mon.newChild(500 - ticksUsed)); + } finally { + monitor.done(); } - return getEngine().perform(plan, set, mon.newChild(500 - ticksUsed)); } private boolean doesPhaseSetIncludeDownload(IPhaseSet set) { diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java index e68ea79d80..2d37de31b8 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java @@ -18,6 +18,7 @@ import java.util.Dictionary; import java.util.Hashtable; import org.eclipse.core.runtime.*; +import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.p2.ui.model.ProfileElement; import org.eclipse.equinox.internal.p2.ui.sdk.SimpleLicenseManager; @@ -146,12 +147,19 @@ protected IStatus install(IInstallableUnit iu, boolean root, boolean lock) { // Use an empty provisioning context to prevent repo access ProvisioningContext context = new ProvisioningContext(getAgent()); context.setMetadataRepositories(new URI[] {}); + FussyProgressMonitor monitor = new FussyProgressMonitor(); IProvisioningPlan plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(req, context, - getMonitor()); + monitor); + monitor.assertUsedUp(); if (plan.getStatus().getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL) return plan.getStatus(); - return getSession().performProvisioningPlan(plan, PhaseSetFactory.createDefaultPhaseSet(), - new ProvisioningContext(getAgent()), getMonitor()); + FussyProgressMonitor monitor2 = new FussyProgressMonitor(); + try { + return getSession().performProvisioningPlan(plan, PhaseSetFactory.createDefaultPhaseSet(), + new ProvisioningContext(getAgent()), monitor2); + } finally { + monitor2.assertUsedUp(); + } } protected IInstallableUnit createNamedIU(String id, String name, Version version, boolean isCategory) { diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java index 2b81f21f8d..1038b924fa 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java @@ -14,6 +14,7 @@ package org.eclipse.equinox.p2.tests.ui.dialogs; import java.util.ArrayList; +import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.License; import org.eclipse.equinox.internal.p2.ui.ProvUI; import org.eclipse.equinox.internal.p2.ui.dialogs.*; @@ -183,7 +184,9 @@ public void testBug277554MultipleVersions() { ArrayList iusInvolved = new ArrayList<>(); iusInvolved.add(main); UpdateOperation op = getProvisioningUI().getUpdateOperation(iusInvolved, null); - op.resolveModal(getMonitor()); + FussyProgressMonitor monitor = new FussyProgressMonitor(); + op.resolveModal(monitor); + monitor.assertUsedUp(); UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null); ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); dialog.setBlockOnOpen(false); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java index 6ba8d457b5..50d1a0947f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java @@ -55,9 +55,9 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.URIUtil; +import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; @@ -842,7 +842,7 @@ public IProfile createProfile(String name, Map properties) { } protected IProgressMonitor getMonitor() { - return new NullProgressMonitor(); + return new FussyProgressMonitor(); } protected IProfile getProfile(String profileId) {