Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2021-07-01 09:13:31 +0000
committerAndrey Loskutov2021-07-01 10:29:10 +0000
commit6bbe55169482d5ad66a57a0e14d974aeda314a27 (patch)
treeae2724db6dda1c7ef8f4d2ed0eb2b47349dbcee7
parenta57a0ce4a6b964c35a6172f4c043d7bf6057c6dd (diff)
downloadrt.equinox.p2-6bbe55169482d5ad66a57a0e14d974aeda314a27.tar.gz
rt.equinox.p2-6bbe55169482d5ad66a57a0e14d974aeda314a27.tar.xz
rt.equinox.p2-6bbe55169482d5ad66a57a0e14d974aeda314a27.zip
Bug 574584 - Various AutomaticUpdateScheduler issues after changing initY20210701-0800I20210703-0600I20210702-1800I20210701-1800
to Job - prevent NPE if early startup job was not executed yet - give 3rd party a chance to get the job execution status / join on it Change-Id: I39e62dfc3fee73c86335072b2607898808449570 Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.p2/+/182669 Tested-by: Equinox Bot <equinox-bot@eclipse.org>
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/pom.xml2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java45
3 files changed, 32 insertions, 17 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
index 132794346..93ad2243d 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/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.sdk.scheduler;singleton:=true
-Bundle-Version: 1.5.100.qualifier
+Bundle-Version: 1.5.200.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdatePlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/pom.xml b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/pom.xml
index df9687152..0490e86b7 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/pom.xml
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/pom.xml
@@ -9,6 +9,6 @@
</parent>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.p2.ui.sdk.scheduler</artifactId>
- <version>1.5.100-SNAPSHOT</version>
+ <version>1.5.200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
index 19833a9a0..504202512 100644
--- a/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
+++ b/bundles/org.eclipse.equinox.p2.ui.sdk.scheduler/src/org/eclipse/equinox/internal/p2/ui/sdk/scheduler/AutomaticUpdateScheduler.java
@@ -19,8 +19,7 @@ package org.eclipse.equinox.internal.p2.ui.sdk.scheduler;
import java.util.Date;
import java.util.Random;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.garbagecollector.GarbageCollector;
@@ -52,8 +51,8 @@ public class AutomaticUpdateScheduler implements IStartup {
private static final int ONE_HOUR_IN_MS = 60 * 60 * 1000;
private static final int ONE_DAY_IN_MS = 24 * ONE_HOUR_IN_MS;
- private IUpdateListener listener = null;
- private IUpdateChecker checker = null;
+ private IUpdateListener listener;
+ private IUpdateChecker checker;
private IProvisioningAgent agent;
@@ -61,21 +60,32 @@ public class AutomaticUpdateScheduler implements IStartup {
public void earlyStartup() {
AutomaticUpdatePlugin.getDefault().setScheduler(this);
- Job updateJob = Job.create("Update Job", e -> { //$NON-NLS-1$
- agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
- IProfileRegistry registry = agent.getService(IProfileRegistry.class);
- IProfile currentProfile = registry.getProfile(IProfileRegistry.SELF);
- if (currentProfile != null && new MigrationSupport().performMigration(agent, registry, currentProfile)) {
- return;
+ Job updateJob = new Job("Update Job") { //$NON-NLS-1$
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ agent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
+ IProfileRegistry registry = agent.getService(IProfileRegistry.class);
+ IProfile currentProfile = registry.getProfile(IProfileRegistry.SELF);
+ if (currentProfile != null
+ && new MigrationSupport().performMigration(agent, registry, currentProfile)) {
+ return Status.OK_STATUS;
+ }
+
+ removeUnusedPlugins(registry);
+ scheduleUpdate();
+ return Status.OK_STATUS;
+ }
+
+ @Override
+ public boolean belongsTo(Object family) {
+ return AutomaticUpdateScheduler.class == family;
}
+ };
- removeUnusedPlugins(registry);
- scheduleUpdate();
- });
updateJob.setSystem(true);
// allow the system to settle
updateJob.schedule(20000);
-
}
/**
@@ -139,7 +149,12 @@ public class AutomaticUpdateScheduler implements IStartup {
}
};
- checker = agent.getService(IUpdateChecker.class);
+ IProvisioningAgent pagent = agent;
+ if (pagent == null) {
+ // Job not executed yet
+ pagent = ServiceHelper.getService(AutomaticUpdatePlugin.getContext(), IProvisioningAgent.class);
+ }
+ checker = pagent.getService(IUpdateChecker.class);
if (checker == null) {
// Something did not initialize properly
IStatus status = new Status(IStatus.ERROR, AutomaticUpdatePlugin.PLUGIN_ID,

Back to the top