Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2021-06-10 19:15:17 +0000
committerAndrey Loskutov2021-06-10 21:26:17 +0000
commitf40c5946a22a88994be030b2031b2f4082e1d1d0 (patch)
treeee4ba21982ba1cafe80a6379b7cfc8b70d70242c
parenta3d9c7910a92d7d8387d8009039d69fdf1c5042a (diff)
downloadrt.equinox.p2-f40c5946a22a88994be030b2031b2f4082e1d1d0.tar.gz
rt.equinox.p2-f40c5946a22a88994be030b2031b2f4082e1d1d0.tar.xz
rt.equinox.p2-f40c5946a22a88994be030b2031b2f4082e1d1d0.zip
Bug 567045 - use always growing currentTimeMillis for Profile savingI20210610-1850
Change-Id: I9ac3bab1a9b70d394df50ca5dde60193ef93081c Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Reviewed-on: https://git.eclipse.org/r/c/equinox/rt.equinox.p2/+/181801 Reviewed-by: Jörg Kubitz <jkubitz-eclipse@gmx.de> Tested-by: Equinox Bot <equinox-bot@eclipse.org>
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
index 6e9da4217..3bbbc48e6 100644
--- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
+++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java
@@ -56,6 +56,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
//Internal constant used to keep track of the newly created timestamp
private static final String SERVICE_SHARED_INSTALL_NEW_TIMESTAMP = IProfileRegistry.class.getName() + '_' + "NEW_SELF_TIMESTAMP"; //$NON-NLS-1$
+ private static long lastTimeMillis = System.currentTimeMillis();
+
protected final IProvisioningAgent agent;
/**
@@ -589,9 +591,10 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
profileDirectory.mkdir();
long previousTimestamp = profile.getTimestamp();
- long currentTimestamp = System.currentTimeMillis();
- if (currentTimestamp <= previousTimestamp)
- currentTimestamp = previousTimestamp + 1;
+ long currentTimestamp = currentTimeInMillis(lastTimeMillis);
+ if (currentTimestamp <= previousTimestamp) {
+ currentTimestamp = currentTimeInMillis(previousTimestamp);
+ }
boolean shouldGzipFile = shouldGzipFile(profile);
File profileFile = new File(profileDirectory, Long.toString(currentTimestamp) + (shouldGzipFile ? PROFILE_GZ_EXT : PROFILE_EXT));
@@ -623,6 +626,16 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
}
}
+ /**
+ * Returns current time in millis that is guaranteed to grow and higher as given
+ * value
+ */
+ private static synchronized long currentTimeInMillis(long lastCurrentTime) {
+ long newTime = Math.max(lastCurrentTime + 1, lastTimeMillis + 1);
+ lastTimeMillis = Math.max(newTime, System.currentTimeMillis());
+ return lastTimeMillis;
+ }
+
public void setEventBus(IProvisioningEventBus bus) {
this.eventBus = bus;
}

Back to the top