summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault (Ericsson)2013-01-18 13:56:46 (EST)
committerPascal Rapicault2013-01-18 14:02:04 (EST)
commit8ab9410d8c797e6a8d2a97e4ba46da3d548440fa (patch)
tree4d6f2f030c76e01529c1b0b16697b775e5c78fa3
parentfefbc5bdec2ce6cdb7fd71b1790bf8abdee8737a (diff)
downloadrt.equinox.p2-8ab9410d8c797e6a8d2a97e4ba46da3d548440fa.zip
rt.equinox.p2-8ab9410d8c797e6a8d2a97e4ba46da3d548440fa.tar.gz
rt.equinox.p2-8ab9410d8c797e6a8d2a97e4ba46da3d548440fa.tar.bz2
Cache the fact that the state.properties is missing
-rw-r--r--bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java22
1 files changed, 16 insertions, 6 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 9e2eb44..c141fa0 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2012 IBM Corporation and others. All rights reserved. This
+ * Copyright (c) 2007, 2013 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -910,6 +910,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
// return true if the cached timestamp is the same as the one on disk
boolean isCurrent() {
+ if (!file.exists())
+ return true;
return file.lastModified() == timestamp;
}
@@ -949,8 +951,10 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
File file = new File(profileDirectory, PROFILE_PROPERTIES_FILE);
Properties properties = new Properties();
- if (!file.exists())
+ if (!file.exists()) {
+ lastAccessedProperties = new ProfileStateProperties(id, file, properties);
return properties;
+ }
InputStream input = null;
try {
input = new BufferedInputStream(new FileInputStream(file));
@@ -1055,7 +1059,9 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
if (!result.isOK())
return result;
- internalLockProfile(profile);
+ if (!internalLockProfile(profile))
+ throw new IllegalStateException(Messages.SimpleProfileRegistry_Profile_in_use);
+
try {
Properties properties = readStateProperties(profile.getProfileId());
for (Map.Entry<String, String> entry : propertiesToAdd.entrySet()) {
@@ -1101,7 +1107,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
int keyOffset = timestampString.length() + 1;
lock = lock || lastAccessedProperties == null;
if (lock)
- internalLockProfile(profile);
+ if (!internalLockProfile(profile))
+ throw new IllegalStateException(Messages.SimpleProfileRegistry_Profile_in_use);
try {
Properties properties = readStateProperties(profile.getProfileId());
Iterator<Object> keys = properties.keySet().iterator();
@@ -1132,7 +1139,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
private Map<String, String> internalGetProfileStateProperties(IProfile profile, String userKey) {
Map<String, String> result = new HashMap<String, String>();
- internalLockProfile(profile);
+ if (!internalLockProfile(profile))
+ throw new IllegalStateException(Messages.SimpleProfileRegistry_Profile_in_use);
try {
Properties properties = readStateProperties(profile.getProfileId());
Iterator<Object> keys = properties.keySet().iterator();
@@ -1163,7 +1171,9 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService {
return Status.OK_STATUS;
Profile internalProfile = internalGetProfile(id);
- internalLockProfile(internalProfile);
+ if (!internalLockProfile(internalProfile))
+ throw new IllegalStateException(Messages.SimpleProfileRegistry_Profile_in_use);
+
try {
Properties properties = readStateProperties(id);
String timestampString = String.valueOf(timestamp);