Log Message
Support java.util.concurrent.ConcurrentHashMap with the MapConverter. This will also avoid a bug in JRockit JDK reported in JIRA:XSTR-608.
Modified Paths
- trunk/xstream/pom.xml
- trunk/xstream/src/java/com/thoughtworks/xstream/XStream.java
- trunk/xstream/src/java/com/thoughtworks/xstream/converters/collections/MapConverter.java
- trunk/xstream-distribution/src/content/changes.html
Added Paths
Diff
Modified: trunk/xstream/pom.xml (1966 => 1967)
--- trunk/xstream/pom.xml 2012-03-21 00:29:42 UTC (rev 1966)
+++ trunk/xstream/pom.xml 2012-03-21 01:14:14 UTC (rev 1967)
@@ -1,7 +1,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!--
Copyright (C) 2006 Joe Walnes.
- Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 XStream committers.
+ Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 XStream committers.
All rights reserved.
The software in this package is published under the terms of the BSD
@@ -253,6 +253,7 @@
<exclude>**/enums/*</exclude>
<exclude>**/reflection/PureJavaReflectionProvider15Test*</exclude>
<exclude>**/acceptance/Basic15TypesTest*</exclude>
+ <exclude>**/acceptance/Concurrent15TypesTest*</exclude>
</testExcludes>
</configuration>
</plugin>
Modified: trunk/xstream/src/java/com/thoughtworks/xstream/XStream.java (1966 => 1967)
--- trunk/xstream/src/java/com/thoughtworks/xstream/XStream.java 2012-03-21 00:29:42 UTC (rev 1966)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/XStream.java 2012-03-21 01:14:14 UTC (rev 1967)
@@ -618,6 +618,7 @@
if (JVM.is15()) {
aliasDynamically("duration", "javax.xml.datatype.Duration");
+ aliasDynamically("concurrent-hash-map", "java.util.concurrent.ConcurrentHashMap");
alias("enum-set", jvm.loadClass("java.util.EnumSet"));
alias("enum-map", jvm.loadClass("java.util.EnumMap"));
alias("string-builder", jvm.loadClass("java.lang.StringBuilder"));
Modified: trunk/xstream/src/java/com/thoughtworks/xstream/converters/collections/MapConverter.java (1966 => 1967)
--- trunk/xstream/src/java/com/thoughtworks/xstream/converters/collections/MapConverter.java 2012-03-21 00:29:42 UTC (rev 1966)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/converters/collections/MapConverter.java 2012-03-21 01:14:14 UTC (rev 1967)
@@ -29,8 +29,8 @@
* <p>Note: 'key' and 'value' is not the name of the generated tag. The
* children are serialized as normal elements and the implementation expects
* them in the order 'key'/'value'.</p>
- * <p>Supports java.util.HashMap, java.util.Hashtable and
- * java.util.LinkedHashMap.</p>
+ * <p>Supports java.util.HashMap, java.util.Hashtable,
+ * java.util.LinkedHashMap and java.util.concurrent.ConcurrentHashMap.</p>
*
* @author Joe Walnes
*/
@@ -44,6 +44,7 @@
return type.equals(HashMap.class)
|| type.equals(Hashtable.class)
|| type.getName().equals("java.util.LinkedHashMap")
+ || type.getName().equals("java.util.concurrent.ConcurrentHashMap")
|| type.getName().equals("sun.font.AttributeMap") // Used by java.awt.Font in JDK 6
;
}
Added: trunk/xstream/src/test/com/thoughtworks/acceptance/Concurrent15TypesTest.java (0 => 1967)
--- trunk/xstream/src/test/com/thoughtworks/acceptance/Concurrent15TypesTest.java (rev 0)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/Concurrent15TypesTest.java 2012-03-21 01:14:14 UTC (rev 1967)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2012 XStream Committers.
+ * All rights reserved.
+ *
+ * The software in this package is published under the terms of the BSD
+ * style license a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ *
+ * Created on 21. March 2012 by Joerg Schaible
+ */
+package com.thoughtworks.acceptance;
+
+import java.util.concurrent.ConcurrentHashMap;
+
+public class Concurrent15TypesTest extends AbstractAcceptanceTest {
+
+ public void testConcurrentHashMap() {
+ ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>();
+ map.put("walnes", "joe");
+ String xml = xstream.toXML(map);
+ String expected =
+ "<concurrent-hash-map>\n"
+ + " <entry>\n"
+ + " <string>walnes</string>\n"
+ + " <string>joe</string>\n"
+ + " </entry>\n"
+ + "</concurrent-hash-map>";
+ assertEquals(xml, expected);
+ @SuppressWarnings("unchecked")
+ ConcurrentHashMap<String, String> out = (ConcurrentHashMap<String, String>) xstream.fromXML(xml);
+ assertEquals("{walnes=joe}", out.toString());
+ }
+}
Property changes on: trunk/xstream/src/test/com/thoughtworks/acceptance/Concurrent15TypesTest.java
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Modified: trunk/xstream-distribution/src/content/changes.html (1966 => 1967)
--- trunk/xstream-distribution/src/content/changes.html 2012-03-21 00:29:42 UTC (rev 1966)
+++ trunk/xstream-distribution/src/content/changes.html 2012-03-21 01:14:14 UTC (rev 1967)
@@ -40,6 +40,8 @@
<h2>Minor changes</h2>
<ul>
+ <li>Support java.util.concurrent.ConcurrentHashMap with the MapConverter. This will also avoid a bug in JRockit
+ JDK reported in JIRA:XSTR-608.</li>
<li>JVM.loadClass will now also initialize the loaded class and ignore any occurring LinkageError.</li>
<li>JIRA:XSTR-596: SubjectConverter will be no longer registered if initialization of javax.security.auth.Subject fails.</li>
<li>JIRA:XSTR-683: Inheritance of implicit collections, arrays or maps is dependent on declaration sequence.</li>
To unsubscribe from this list please visit:
