我们有这个奇怪的错误,当我们从MySQL数据库中读取数据并将其反序列化为POJO时,
Cannot parse \"2014-02-29T00:00:00+0000\": Value 29 for dayOfMonth must be in the range [1,28] (through reference chain: com.reports.common.SearchResult[\"entities\"]->java.util.HashSet[19]->com.reports.common.User[\"registrationDate\"])"}
当我们检查数据库中的记录时,没有记录显示registrationDate为' 2014-02-29',最接近的是' 2014-02-19'。我们使用多线程从Mysql表中读取数据,我想知道它是否因为Joda的dateTime解串器是线程不安全的?
这是我们的POJO:
public class SearchResult {
@JsonProperty("entities")
Set<User> users = new HashSet<>();
String totalRecords;
}
public class User {
private String email;
private String gui;
private DateTime creationDate;
private DateTime registrationDate;
}
这是我们的ObjectMapper:
public class PyObjectMapper extends ObjectMapper {
public PyObjectMapper() {
registerModule(new JodaModule());
}
}
在我们的代码中,我们使用多线程来调用从数据库读取并将结果映射到POJO的客户端代码
result = client.getResourceLocator().getMembers(orgId, query,returnFields, bookmark, limit);
if (result != null) {
try {
searchResult = mapper.readValue(result.toString(), SearchResult.class);
} catch (Exception e) {
throw e;
}
我们在pom中使用的joda是:
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.6.6</version>
</dependency>