Skip to content

Commit 2613c83

Browse files
committed
Use Jettison 1.4.1 with appropriate configuration. Closes #72.
1 parent 5f16992 commit 2613c83

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@
11051105
<version.junit>3.8.1</version.junit>
11061106
<version.net.sf.kxml.kxml2>2.3.0</version.net.sf.kxml.kxml2>
11071107
<version.org.apache.felix>6.0.3</version.org.apache.felix>
1108-
<version.org.codehaus.jettison>1.2</version.org.codehaus.jettison>
1108+
<version.org.codehaus.jettison>1.4.1</version.org.codehaus.jettison>
11091109
<version.com.fasterxml.woodstox.core>5.2.0</version.com.fasterxml.woodstox.core>
11101110
<version.org.dom4j>2.0.2</version.org.dom4j>
11111111
<version.org.hibernate.core>4.2.5.Final</version.org.hibernate.core>

xstream-distribution/src/content/changes.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
22
<!--
33
Copyright (C) 2005, 2006 Joe Walnes.
4-
Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 XStream committers.
4+
Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 XStream committers.
55
All rights reserved.
66
77
The software in this package is published under the terms of the BSD
@@ -60,6 +60,7 @@ <h2>Minor changes</h2>
6060
<li>No need for reflection in StackTraceElementFactory anymore since Java 5.</li>
6161
<li>StaxReader did not propagate close for Reader and InputStream.</li>
6262
<li>Add SimpleStaxDriver without namespace support as possible alternative to default driver.</li>
63+
<li>GHI:#72: Finally it is possible to use Jettison 1.4.1 or higher.</li>
6364
</ul>
6465

6566
<h2>API changes</h2>

xstream-distribution/src/content/download.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ <h1 id="optional-deps">Optional Dependencies</h1>
7171
<li><a href="https://repo1.maven.org/maven2/javax/activation/jaxax.activation-api/1.2.0/jaxax.activation-api-1.2.0.jar">Java Activation module</a> for the ActivationDataFlavorConverter. The dependency is required for the Java 11 runtime.</li>
7272
<li><a href="https://github.com/JodaOrg/joda-time/releases/download/v2.10.1/joda-time-2.10.1-dist.zip">Joda Time</a> for optional ISO8601 date/time converters in JDK 1.7 or below.</li>
7373
<li><a href="http://downloads.sourceforge.net/cglib/cglib-nodep-2.2.jar">CGLIB</a> for optional support of some proxies generated with the CGLIB Enhancer.</li>
74-
<li><a href="https://repo1.maven.org/maven2/org/codehaus/jettison/jettison/1.2/jettison-1.2.jar">Jettison</a> for serialization and deserialization support with JSON. Note, that newer versions 1.3.x are no longer compatible with XStream.</li>
75-
<li><a href="https://repo1.maven.org/maven2/org/codehaus/jettison/jettison/1.0/jettison-1.0.jar">Jettison 1.0.1</a> for serialization and deserialization support with JSON in JDK 1.4. Note, that newer version 1.1 is not compatible with XStream.</li>
74+
<li><a href="https://repo1.maven.org/maven2/org/codehaus/jettison/jettison/1.4.1/jettison-1.4.1.jar">Jettison</a> for serialization and deserialization support with JSON. Note, except Jettison 1.2 no lower version is compatible.</li>
7675
</ul>
7776
</li>
7877
</ul>

xstream/src/java/com/thoughtworks/xstream/io/json/JettisonMappedXmlDriver.java

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013, 2014, 2018 XStream Committers.
2+
* Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013, 2014, 2018, 2020 XStream Committers.
33
* All rights reserved.
44
*
55
* The software in this package is published under the terms of the BSD
66
* style license a copy of which has been included with this distribution in
77
* the LICENSE.txt file.
8-
*
8+
*
99
* Created on 30. March 2007 by Joerg Schaible
1010
*/
1111
package com.thoughtworks.xstream.io.json;
@@ -36,8 +36,9 @@
3636

3737

3838
/**
39-
* Simple XStream driver wrapping Jettison's Mapped reader and writer. Serializes object from and to JSON.
40-
*
39+
* Simple XStream driver wrapping Jettison's Mapped reader and writer. Serializes object from and to JSON. Use exactly
40+
* Jettison 1.2 or at least 1.4.1. Versions in between are not compatible.
41+
*
4142
* @author Dejan Bosanac
4243
*/
4344
public class JettisonMappedXmlDriver extends AbstractDriver {
@@ -56,7 +57,10 @@ public JettisonMappedXmlDriver() {
5657

5758
/**
5859
* Construct a JettisonMappedXmlDriver with configuration.
59-
*
60+
* <p>
61+
* Note, you should turn off Jettison's root element array wrapper using Jettison 1.4.1 or higher.
62+
* </p>
63+
*
6064
* @param config the Jettison configuration
6165
*/
6266
public JettisonMappedXmlDriver(final Configuration config) {
@@ -70,13 +74,16 @@ public JettisonMappedXmlDriver(final Configuration config) {
7074
* versions. if the driver is setup to ignore the XStream hints for JSON arrays, there is neither support from
7175
* XStream's side nor are there any tests to ensure this mode.
7276
* </p>
73-
*
74-
* @param config the Jettison configuration
77+
*
78+
* @param config the Jettison configuration or null for XStream's defaults
7579
* @param useSerializeAsArray flag to use XStream's hints for collections and arrays
7680
* @since 1.4
7781
*/
7882
public JettisonMappedXmlDriver(Configuration config, final boolean useSerializeAsArray) {
79-
config = config == null ? new Configuration() : config;
83+
if (config == null) {
84+
config = new Configuration();
85+
config.setRootElementArrayWrapper(false);
86+
}
8087
mof = new MappedXMLOutputFactory(config);
8188
mif = new MappedXMLInputFactory(config);
8289
convention = new MappedNamespaceConvention(config);

0 commit comments

Comments
 (0)