Index: modules/luni/src/main/java/java/net/HttpCookie.java =================================================================== --- modules/luni/src/main/java/java/net/HttpCookie.java (revision 803899) +++ modules/luni/src/main/java/java/net/HttpCookie.java (working copy) @@ -83,7 +83,7 @@ private static Pattern ATTR_PATTERN1 = Pattern .compile("(,?[^;=]*)(?:=([^;,]*))?((?=.))?"); //$NON-NLS-1$ - private static HashMap attributeSet = new HashMap(); + private HashMap attributeSet = new HashMap(); /** * A utility method used to check whether the host name is in a domain or @@ -248,7 +248,7 @@ } } - Setter setter = attributeSet.get(attrName.toLowerCase()); + Setter setter = cookie.attributeSet.get(attrName.toLowerCase()); if (null == setter) { throw new IllegalArgumentException(); } Index: modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpCookieTest.java =================================================================== --- modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpCookieTest.java (revision 792181) +++ modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/HttpCookieTest.java (working copy) @@ -897,7 +897,42 @@ cookie = list.get(0); assertEquals(0, cookie.getVersion()); } + + /** + * @tests java.net.HttpCookie#parse(String) on multiple threads + * Regression test for HARMONY-6307 + * + * @since 1.6 + * + */ + public void test_Parse_multipleThreads() throws InterruptedException { + Thread[] threads = new Thread[10]; + // create threads + for (int i = 0; i < threads.length; i++) { + threads[i] = new Thread(new Runnable() { + public void run() { + for (int i = 0; i < 200; i++) { + List list = HttpCookie.parse("Set-cookie:PREF=test;path=/;domain=.b.c;"); + assertEquals(1, list.size()); + HttpCookie cookie = list.get(0); + assertEquals(0, cookie.getVersion()); + assertEquals(".b.c", cookie.getDomain()); + } + } + }); + } + + // start threads + for (Thread thread : threads) { + thread.start(); + } + // wait for threads to finish + for (Thread thread : threads) { + thread.join(); + } + } + private void checkValidValue(String header, String value) { List list = HttpCookie .parse(header + "name=" + value + ";");