Use HashMap instead of WeakHashMap.
Otherwise, the entries in the map could be concurrently deleted,
and the test for passing invalid indices actually pass.
bug:62527942
Test: OldAttributeStringTest
Change-Id: I73b8d7c3a547585060667038d85b4b28fefef2bf
diff --git a/luni/src/test/java/libcore/java/text/OldAttributedStringTest.java b/luni/src/test/java/libcore/java/text/OldAttributedStringTest.java
index 89f6f13..26bd21d 100644
--- a/luni/src/test/java/libcore/java/text/OldAttributedStringTest.java
+++ b/luni/src/test/java/libcore/java/text/OldAttributedStringTest.java
@@ -358,17 +358,17 @@
*/
public void test_addAttributesLjava_util_MapII() {
AttributedString as = new AttributedString("test");
- Map<AttributedCharacterIterator.Attribute, String> whm = new WeakHashMap<AttributedCharacterIterator.Attribute, String>();
+ Map<AttributedCharacterIterator.Attribute, String> hm = new HashMap<AttributedCharacterIterator.Attribute, String>();
// case 1: Try to add attributes to AttributesString.
try {
- whm.put(new TestAttributedCharacterIteratorAttribute("test1"),
+ hm.put(new TestAttributedCharacterIteratorAttribute("test1"),
"value1");
- whm.put(new TestAttributedCharacterIteratorAttribute("test2"),
+ hm.put(new TestAttributedCharacterIteratorAttribute("test2"),
"value2");
- whm.put(new TestAttributedCharacterIteratorAttribute("test3"),
+ hm.put(new TestAttributedCharacterIteratorAttribute("test3"),
"value3");
- as.addAttributes(whm, 0, 3);
+ as.addAttributes(hm, 0, 3);
} catch (Exception e) {
fail("Unexpected exception " + e.toString());
}
@@ -384,7 +384,7 @@
// case 3: Try to add attributes to AttributesString using incorrect
// index.
try {
- as.addAttributes(whm, 0, 0);
+ as.addAttributes(hm, 0, 0);
fail("Expected IllegalArgumentException was not thrown");
} catch (IllegalArgumentException e) {
// expected