From 05ebd63339fb7443112e5070cf331b51ccb54db0 Mon Sep 17 00:00:00 2001 From: jdesprez Date: Tue, 29 Aug 2017 15:39:17 -0700 Subject: Conserve order of keys in device build map Like all the other structure, use linkedHashmap to ensure the order of the key in InvocationContext. Test: unit tests Bug: 65121670 Change-Id: Id8608b8be18877662282f2213c16ef4dfe2d62be --- src/com/android/tradefed/invoker/InvocationContext.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/com/android/tradefed') diff --git a/src/com/android/tradefed/invoker/InvocationContext.java b/src/com/android/tradefed/invoker/InvocationContext.java index f8a4be437..0ebe25c31 100644 --- a/src/com/android/tradefed/invoker/InvocationContext.java +++ b/src/com/android/tradefed/invoker/InvocationContext.java @@ -29,7 +29,6 @@ import com.android.tradefed.util.UniqueMultiMap; import java.io.IOException; import java.io.ObjectInputStream; import java.util.ArrayList; -import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -61,7 +60,7 @@ public class InvocationContext implements IInvocationContext { * Creates a {@link BuildInfo} using default attribute values. */ public InvocationContext() { - mAllocatedDeviceAndBuildMap = new HashMap(); + mAllocatedDeviceAndBuildMap = new LinkedHashMap(); // Use LinkedHashMap to ensure key ordering by insertion order mNameAndDeviceMap = new LinkedHashMap(); mNameAndBuildinfoMap = new LinkedHashMap(); @@ -298,7 +297,7 @@ public class InvocationContext implements IInvocationContext { // our "pseudo-constructor" in.defaultReadObject(); // now we are a "live" object again, so let's init the transient field - mAllocatedDeviceAndBuildMap = new HashMap(); + mAllocatedDeviceAndBuildMap = new LinkedHashMap(); mNameAndDeviceMap = new LinkedHashMap(); } } -- cgit v1.2.3