Skip to content

Commit 016a56f

Browse files
committed
minor tweaks to JDK serializability
1 parent b7433bd commit 016a56f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/java/com/fasterxml/jackson/dataformat/xml/util/XmlRootNameLookup.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,21 @@ public class XmlRootNameLookup
2121
/**
2222
* For efficient operation, let's try to minimize number of times we
2323
* need to introspect root element name to use.
24+
*<p>
25+
* Note: changed to <code>transient</code> for 2.3; no point in serializing such
26+
* state
2427
*/
25-
protected final LRUMap<ClassKey,QName> _rootNames = new LRUMap<ClassKey,QName>(40, 200);
28+
protected final transient LRUMap<ClassKey,QName> _rootNames = new LRUMap<ClassKey,QName>(40, 200);
2629

2730
public XmlRootNameLookup() { }
31+
32+
protected Object readResolve() {
33+
// just need to make 100% sure it gets set to non-null, that's all
34+
if (_rootNames == null) {
35+
return new XmlRootNameLookup();
36+
}
37+
return this;
38+
}
2839

2940
public QName findRootName(JavaType rootType, MapperConfig<?> config)
3041
{

src/test/java/com/fasterxml/jackson/dataformat/xml/TestJDKSerializability.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import javax.xml.namespace.QName;
66

77
import com.fasterxml.jackson.core.*;
8+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
89
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
910

1011
/**
@@ -13,6 +14,7 @@
1314
*/
1415
public class TestJDKSerializability extends XmlTestBase
1516
{
17+
@JacksonXmlRootElement(localName="MyPojo")
1618
static class MyPojo {
1719
public int x;
1820
private int y;

0 commit comments

Comments
 (0)