jaxb解组localDateTime多线程环境

jaxb解组localDateTime多线程环境,jaxb,Jaxb,提前为我的英语不好道歉 在多线程环境中,将字符串解组为LocalDateTime时出现问题。我使用org.apache.cxf版本2.7.7生成了java类(ActivityData) 当我不时调试应用程序时,字符串的年份在年初被一些奇怪的值损坏(例如722008-01-01、A2008-01-01、12008-01-01),当我使用客户端(如soap ui)进行调用时,日期格式良好。批处理应用程序中的多个线程调用localDateAdapter。当我重新运行批处理时,相同的调用成功,而其他调用

提前为我的英语不好道歉

在多线程环境中,将字符串解组为LocalDateTime时出现问题。我使用org.apache.cxf版本2.7.7生成了java类(ActivityData)

当我不时调试应用程序时,字符串的年份在年初被一些奇怪的值损坏(例如722008-01-01、A2008-01-01、12008-01-01),当我使用客户端(如soap ui)进行调用时,日期格式良好。批处理应用程序中的多个线程调用localDateAdapter。当我重新运行批处理时,相同的调用成功,而其他调用失败。解析错误是不可预测的。问题只出现在开始日期上,java对象中的结束日期总是格式良好的

我试图同步该方法,但它没有改变任何事情

提前谢谢你的帮助

下面是我的LocalDateTimeAdapter的代码

public class LocalDateTimeAdapter extends XmlAdapter<String, LocalDateTime> {
    public synchronized LocalDateTime unmarshal(String v) {
        if (StringUtils.isNotBlank(v)) {
            try {
                return LocalDateTime.parse(v, DateTimeFormatter.ISO_DATE_TIME);
            } catch (Exception exception) {
throw new IllegalArgumentException("Parsing problem in the localDateTime for string : " + v);
            }

        }
        return null;
    }

    public String marshal(LocalDateTime v) {
        if (v != null) {
            return v.toString();
        }
        return StringUtils.EMPTY;
    }
}

不知怎的,这是可疑的。我可以识别代码中的线程安全问题<从模式创建的code>LocalDateTime和
DateTimeFormatter
是不可变的,并且是线程安全的。您应该尝试提供一个复制MCVE。谢谢您的回复。实际上,在输入unmarshall方法时,字符串“v”已经损坏。如果您知道输入中的数据已损坏,为什么还要询问?那么,问题显然不在适配器中。请将该方法标记为已同步不足以处理线程问题?-在这种情况下,我无法识别代码中的线程安全问题。我甚至不明白你为什么需要在这里同步。谢谢。这就是我寻求帮助的原因。我不明白为什么我会收到这个损坏的字符串。它与将XML解析为java对象有关。。。我想不出来
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:annox="http://annox.dev.java.net"
        xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_1.xsd"
        jaxb:extensionBindingPrefixes="xjc annox"
        version="2.1">

    <jaxb:globalBindings>
        <jaxb:serializable uid="1"/>
        <xjc:javaType
                name="java.time.LocalDate"
                xmlType="xs:date"
                adapter="be.fgov.minfin.vies.adapter.LocalDateAdapter"/>
        <xjc:javaType
                name="java.time.LocalDateTime"
                xmlType="xs:dateTime"
                adapter="be.fgov.minfin.vies.adapter.LocalDateTimeAdapter"/>
    </jaxb:globalBindings>
</jaxb:bindings>
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ActivityData", propOrder = {
    "beginDate",
    "endDate"
})
public class ActivityData
    implements Serializable
{

    private final static long serialVersionUID = 1L;
    @XmlElement(type = String.class)
    @XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
    @XmlSchemaType(name = "dateTime")
    protected LocalDateTime beginDate;

    @XmlElement(type = String.class)
    @XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
    @XmlSchemaType(name = "dateTime")
    protected LocalDateTime endDate;


    /**
     * Gets the value of the beginDate property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public LocalDateTime getBeginDate() {
        return beginDate;
    }

    /**
     * Sets the value of the beginDate property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setBeginDate(LocalDateTime value) {
        this.beginDate = value;
    }


    /**
     * Gets the value of the endDate property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public LocalDateTime getEndDate() {
        return endDate;
    }

    /**
     * Sets the value of the endDate property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setEndDate(LocalDateTime value) {
        this.endDate = value;
    }
}