diff options
author | Sergey Prigogin | 2016-08-20 00:52:42 +0000 |
---|---|---|
committer | Sergey Prigogin | 2016-08-30 19:09:05 +0000 |
commit | ab6c4729ea853f7e4e1c5952eabdee3e41dcddaf (patch) | |
tree | d1df578f0fd587f33c5c837897e98a5c91af347b | |
parent | 42bc4529afd2190f44e4152bf8bac1ec23a6aaa2 (diff) | |
download | rt.equinox.p2-ab6c4729ea853f7e4e1c5952eabdee3e41dcddaf.tar.gz rt.equinox.p2-ab6c4729ea853f7e4e1c5952eabdee3e41dcddaf.tar.xz rt.equinox.p2-ab6c4729ea853f7e4e1c5952eabdee3e41dcddaf.zip |
Bug 371970 - NPE at
org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.lockProfile
Change-Id: I789887493f8b5e3b601a6b00c8ec7928c77e85e3
Signed-off-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r-- | bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java | 24 |
1 files changed, 20 insertions, 4 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 8c98a4c74..451822ebb 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 @@ -110,7 +110,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { } } if (self == null) - self = (String) agent.getService("FORCED_SELF"); + self = (String) agent.getService("FORCED_SELF"); //$NON-NLS-1$ context.ungetService(ref); } @@ -243,6 +243,9 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { return timestamps; } + /** + * Returns the profile with the given ID, or {@code null} if no such profile exists. + */ private Profile internalGetProfile(String id) { if (SELF.equals(id)) id = self; @@ -1126,6 +1129,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { throw new NullPointerException(); Profile internalProfile = internalGetProfile(id); + if (internalProfile == null) + throw new IllegalArgumentException(id); return internalSetProfileStateProperties(internalProfile, timestamp, propertiesToAdd); } @@ -1158,7 +1163,10 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { public IStatus setProfileStateProperty(String id, long timestamp, String key, String value) { if (id == null) throw new NullPointerException(); - return internalSetProfileStateProperty(internalGetProfile(id), timestamp, key, value); + Profile internalProfile = internalGetProfile(id); + if (internalProfile == null) + throw new IllegalArgumentException(id); + return internalSetProfileStateProperty(internalProfile, timestamp, key, value); } private IStatus internalSetProfileStateProperty(IProfile profile, long timestamp, String key, String value) { @@ -1173,7 +1181,10 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { public Map<String, String> getProfileStateProperties(String id, long timestamp) { if (id == null) throw new NullPointerException(); - return internalGetProfileStateProperties(internalGetProfile(id), timestamp, true); + Profile internalProfile = internalGetProfile(id); + if (internalProfile == null) + return Collections.emptyMap(); + return internalGetProfileStateProperties(internalProfile, timestamp, true); } private Map<String, String> internalGetProfileStateProperties(IProfile profile, long timestamp, boolean lock) { @@ -1209,6 +1220,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { throw new NullPointerException(); Profile internalProfile = internalGetProfile(id); + if (internalProfile == null) + return Collections.emptyMap(); return internalGetProfileStateProperties(internalProfile, userKey, true); } @@ -1249,6 +1262,9 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { return Status.OK_STATUS; Profile internalProfile = internalGetProfile(id); + if (internalProfile == null) + return Status.OK_STATUS; + if (!internalLockProfile(internalProfile)) throw new IllegalStateException(Messages.SimpleProfileRegistry_Profile_in_use); @@ -1260,7 +1276,7 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { for (Iterator<Object> already = properties.keySet().iterator(); already.hasNext();) { String key = (String) already.next(); // property key is timestamp.key - if (key.indexOf(timestampString) == 0) + if (key.startsWith(timestampString)) already.remove(); } } else { |