summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikaelpeltier <mikaelpeltier@google.com>2015-03-09 15:19:29 +0100
committermikaelpeltier <mikaelpeltier@google.com>2015-03-09 15:27:20 +0100
commit6d2670e5f06cfe49d85d04f656cdb8d99579ff03 (patch)
tree1cd9024a8aa7b54838b4e18bb1f6f0bd60e980d5
parent20ef3af418a5acd49b202a5b9441127689a79508 (diff)
downloadtoolchain_jack-6d2670e5f06cfe49d85d04f656cdb8d99579ff03.zip
toolchain_jack-6d2670e5f06cfe49d85d04f656cdb8d99579ff03.tar.gz
toolchain_jack-6d2670e5f06cfe49d85d04f656cdb8d99579ff03.tar.bz2
Duplicate PropertyId.Value when used
Change-Id: Ic7c6f047bdbb29690233848cfe225508612e2f6f
-rw-r--r--sched/src/com/android/sched/util/config/ConfigChecker.java7
-rw-r--r--sched/src/com/android/sched/util/config/id/PropertyId.java31
2 files changed, 37 insertions, 1 deletions
diff --git a/sched/src/com/android/sched/util/config/ConfigChecker.java b/sched/src/com/android/sched/util/config/ConfigChecker.java
index 63a21e5..dc94c3b 100644
--- a/sched/src/com/android/sched/util/config/ConfigChecker.java
+++ b/sched/src/com/android/sched/util/config/ConfigChecker.java
@@ -26,6 +26,7 @@ import com.android.sched.util.location.Location;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import javax.annotation.Nonnull;
@@ -56,7 +57,11 @@ public class ConfigChecker {
@Nonnull Map<ObjectId<?>, Object> instanceValues,
@Nonnull Map<KeyId<?, ?>, Location> locationsById) {
this.context = context;
- this.values.putAll(stringValues);
+ for (Entry<PropertyId<?>, PropertyId<?>.Value> entry : stringValues.entrySet()) {
+ this.values.put(entry.getKey(), (entry.getValue() != null) ? entry.getValue().duplicate()
+ : null);
+ }
+
this.instances.putAll(instanceValues);
this.locations.putAll(locationsById);
}
diff --git a/sched/src/com/android/sched/util/config/id/PropertyId.java b/sched/src/com/android/sched/util/config/id/PropertyId.java
index 7086a43..1d73382 100644
--- a/sched/src/com/android/sched/util/config/id/PropertyId.java
+++ b/sched/src/com/android/sched/util/config/id/PropertyId.java
@@ -173,6 +173,15 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription {
this.value = new IValueObject<T>(value);
}
+ private Value (@Nonnull IValue<T> value) {
+ this.value = value.duplicate();
+ }
+
+ @Nonnull
+ public synchronized Value duplicate() {
+ return new Value(value);
+ }
+
public Value (@Nonnull CodecContext context, @Nonnull T value) {
this.value = new IValueObject<T>(context, value);
}
@@ -221,6 +230,9 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription {
@Nonnull
public String getString();
+
+ @Nonnull
+ public IValue<T> duplicate();
}
private class IValueString implements IValue<T> {
@@ -253,6 +265,12 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription {
public PropertyId<T>.IValueObject<T> getValueObject(@Nonnull CodecContext context) {
throw new AssertionError();
}
+
+ @Override
+ @Nonnull
+ public IValue<T> duplicate() {
+ return this;
+ }
}
private class IValueCheckedString implements IValue<T> {
@@ -279,6 +297,12 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription {
public PropertyId<?>.IValueObject<T> getValueObject(@Nonnull CodecContext context) {
return new IValueObject<T>(context, PropertyId.this.codec.parseString(context, value));
}
+
+ @Override
+ @Nonnull
+ public IValue<T> duplicate() {
+ return this;
+ }
}
private class IValueObject<T> implements IValue<T> {
@@ -331,5 +355,12 @@ public class PropertyId<T> extends KeyId<T, String> implements HasDescription {
public T getObject() {
return value;
}
+
+ @SuppressWarnings("unchecked")
+ @Override
+ @Nonnull
+ public IValue<T> duplicate() {
+ return ((PropertyId<T>) (PropertyId.this)).new IValueCheckedString(getString());
+ }
}
}