高负载期间的ConcurrentModificationException - Spring Web REST

时间:2015-10-01 08:56:09

标签: java spring rest spring-mvc spring-web

在休息服务上运行负载测试时,每个请求都有随机的xml内容,偶尔会发生异常。似乎负载越高,发生的可能性越大。

在Spring中为unmarshal xml到java对象的当前实现似乎不是线程安全的吗?

  

13:23:38,314错误   [org.apache.catalina.core.ContainerBase [jboss.web] [缺省主机]。[/错误代码翻译]。[SpringApplication]]   (http- / 0.0.0.0:14080-36)JBWEB000236:servlet的Servlet.service()   SpringApplication引发了异常:   java.util.ConcurrentModificationException at   java.util.ArrayList中的$ Itr.checkForComodification(ArrayList.java:901)   [rt.jar:1.8.0_31] at java.util.ArrayList $ Itr.next(ArrayList.java:851)   [rt.jar:1.8.0_31] at   com.sun.xml.bind.v2.runtime.reflect.Lister $ CollectionLister $ 1.next(Lister.java:288)   在   com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:139)   在   com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:159)   在   com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:358)   在   com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593)   在   com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:340)   在   com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)   在   com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)   在   com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:251)   在   org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter.writeToResult(Jaxb2RootElementHttpMessageConverter.java:181)   [spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at   org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter.writeInternal(AbstractXmlHttpMessageConverter.java:66)   [spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at   org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:208)   [spring-web-4.1.7.RELEASE.jar:4.1.7.RELEASE] at   org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:161)   [spring-webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE] at   org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:101)   [弹簧webmvc-4.1.7.RELEASE.jar:4.1.7.RELEASE]

实施

import org.springframework.web.bind.annotation.*

APPLICATION_XML_V1 = "application/vnd.nnn.nnn.nnn.v1+xml"

@RequestMapping(
        value = "/{language}/batchtranslation",
        method = RequestMethod.POST,
       consumes = {MediaType.APPLICATION_XML_V1})
public Response translateBatchForLanguage_1_0(@PathVariable("language") String language,
                                                   @RequestBody String body){
    // Implementation code
}

在执行代码执行之前发生异常,它出现在spring代码中。

0 个答案:

没有答案