Text may not be null 异常修复

Text may not be null 异常修复

1. 异常信息
java.lang.IllegalArgumentException: Text may not be null
    at org.apache.http.util.Args.notNull(Args.java:54)
    at org.apache.http.entity.mime.content.StringBody.<init>(StringBody.java:155)
    at org.apache.http.entity.mime.MultipartEntityBuilder.addTextBody(MultipartEntityBuilder.java:153)
    at configure.client.impl.YNClientImpl.uploadEntAssets(YNClientImpl.java:127)
    at configure.strategy.TicketStrategy.distributeYN(TicketStrategy.java:168)
    at configure.strategy.TicketStrategy.sendAsserts(TicketStrategy.java:90)
    at configure.service.script.impl.ServiceImpl.sendEntAsset(ScriptServiceImpl.java:132)
    at configure.facade.ServiceFacade.sendEntAssets(ServiceFacade.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190)
2. 对应业务代码
HttpEntity entity = MultipartEntityBuilder.create()
                    .setCharset(StandardCharsets.UTF_8)
                    .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
                    .addTextBody("tid", entDTO.getEntId(), txtUtf8Type)
                    .addTextBody("id", entDTO.getCrmId()  == null ? "" : entDTO.getCrmId(), txtUtf8Type)
                    .build();

    // todo send http
           
3. 修复

请求体 中 包含了为 null的字段,可以把null 改为 “” 即可

猜你喜欢

转载自blog.csdn.net/xu990128638/article/details/132031643