-
-
Notifications
You must be signed in to change notification settings - Fork 234
Closed
Milestone
Description
This is the sample to reproduce the bug. The "localName" override is failed in some of thread, printing original class name "TestModel" instead of "model". XmlMapper seems not thread safe.
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
@JacksonXmlRootElement(localName = "model")
public class TestModel {
public static void main(String[] s) throws Exception {
final ObjectMapper xmlMapper = new XmlMapper();
for (int i=0;i < 100;i++) {
new Thread(new Runnable() {
@Override
public void run() {
try {
System.out.println(xmlMapper.writeValueAsString(new TestModel()));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}).start();
}
Thread.sleep(10000L);
}
}
Output:
<model/>
<model/>
<model/>
<model/>
<model/>
<model/>
<model/>
<TestModel/>
<model/>
<model/>
<model/>
<model/>
Metadata
Metadata
Assignees
Labels
No labels