aboutsummaryrefslogtreecommitdiffstats
path: root/sdkmanager
diff options
context:
space:
mode:
authorRaphael Moll <ralf@android.com>2012-11-26 10:55:51 -0800
committerRaphael Moll <ralf@android.com>2012-11-26 10:55:51 -0800
commit65d2c252d1eafb22552bbfcf7fc788d4ba377c89 (patch)
tree4c32597434c346e18d0b76c2b0bb4a6f958c85db /sdkmanager
parent9955ad3458416bbffb61eb03e7e60bea699bffd0 (diff)
downloadsdk-65d2c252d1eafb22552bbfcf7fc788d4ba377c89.zip
sdk-65d2c252d1eafb22552bbfcf7fc788d4ba377c89.tar.gz
sdk-65d2c252d1eafb22552bbfcf7fc788d4ba377c89.tar.bz2
AVD Manager: prevent NPE in AvdInfo.
AvdInfo.mProperties should never be null. The constructor assumed it could but then the code below uses it without guard in multiple places. Solve this by making sure the constructor doesn't set the map to null. SDK Bug: 40400 Change-Id: I82f4b4c3bfa05ab3b3f57463fdaf5b17273faf56
Diffstat (limited to 'sdkmanager')
-rwxr-xr-xsdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdInfo.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdInfo.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdInfo.java
index c4b6b18..83aa2ef 100755
--- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdInfo.java
+++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/avd/AvdInfo.java
@@ -60,6 +60,7 @@ public final class AvdInfo implements Comparable<AvdInfo> {
private final String mTargetHash;
private final IAndroidTarget mTarget;
private final String mAbiType;
+ /** An immutable map of properties. This must not be modified. Map can be empty. Never null. */
private final Map<String, String> mProperties;
private final AvdStatus mStatus;
@@ -75,7 +76,7 @@ public final class AvdInfo implements Comparable<AvdInfo> {
* @param targetHash the target hash
* @param target The target. Can be null, if the target was not resolved.
* @param abiType Name of the abi.
- * @param properties The property map. Cannot be null.
+ * @param properties The property map. If null, an empty map will be created.
*/
public AvdInfo(String name,
File iniFile,
@@ -99,7 +100,7 @@ public final class AvdInfo implements Comparable<AvdInfo> {
* @param targetHash the target hash
* @param target The target. Can be null, if the target was not resolved.
* @param abiType Name of the abi.
- * @param properties The property map. Can be null.
+ * @param properties The property map. If null, an empty map will be created.
* @param status The {@link AvdStatus} of this AVD. Cannot be null.
*/
public AvdInfo(String name,
@@ -116,7 +117,8 @@ public final class AvdInfo implements Comparable<AvdInfo> {
mTargetHash = targetHash;
mTarget = target;
mAbiType = abiType;
- mProperties = properties == null ? null : Collections.unmodifiableMap(properties);
+ mProperties = properties == null ? Collections.<String, String>emptyMap()
+ : Collections.unmodifiableMap(properties);
mStatus = status;
}
@@ -261,7 +263,9 @@ public final class AvdInfo implements Comparable<AvdInfo> {
}
/**
- * Returns an unmodifiable map of properties for the AVD. This can be null.
+ * Returns an unmodifiable map of properties for the AVD.
+ * This can be empty but not null.
+ * Callers must NOT try to modify this immutable map.
*/
public Map<String, String> getProperties() {
return mProperties;