处理BDPB标签体只包含空白换行符导致转换对象报错问题。

添加单元测试程序
This commit is contained in:
zhouxiunai
2019-01-09 10:17:22 +08:00
parent 2e2bef8eb9
commit 10f4ec15a1
4 changed files with 160 additions and 15 deletions
@@ -13,6 +13,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser.Feature;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -103,6 +104,10 @@ public class ExchangeServiceImpl implements IExchangeService {
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
xmlMapper.setAnnotationIntrospector(new JaxbAnnotationIntrospector(TypeFactory.defaultInstance()));
//tofix: 暂时单独对BDPB做容错处理 ,可能为 jackson xml 的bug 或配置问题
xmlStr = xmlStr.replace("<BDPB>\n</BDPB>", "<BDPB></BDPB>");
return xmlMapper.readValue(xmlStr, MSG.class);
} catch (Exception e) {
throw new ExchangeServiceException(e.getMessage(),e);