liyiorg / weixin-popular

微信SDK JAVA (公众平台、开放平台、 商户平台、 服务商平台)
Apache License 2.0
2.5k stars 1.06k forks source link

java.lang.ArrayIndexOutOfBoundsException in PayMchAPI.payUnifiedorder #196

Closed wuxudong closed 5 years ago

wuxudong commented 5 years ago

version 2.8.22

java.lang.ArrayIndexOutOfBoundsException: -1 at com.sun.xml.bind.v2.util.CollisionCheckStack.pushNocheck(CollisionCheckStack.java:121) at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:487) at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315) at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244) at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:116) at weixin.popular.util.XMLConverUtil.convertToXML(XMLConverUtil.java:127) at weixin.popular.api.PayMchAPI.payUnifiedorder(PayMchAPI.java:153)

在 XmlConvertUtils 里 缓存Marshaller, Unmarshaller, 提供复用, 在多线程情况下会出问题, 并导致后续所有的 marshal 都报同样的异常。

Create JAXBContext is very expensive operation and JAXBContext is thread safe. Create marshaller/unmarshaller is very light operation and costs almost nothing comparing to JAXBConetxt.