apache / apache/incubator-seata

不支持 'multipart/form-data;boundary=.....'类型的请求

Open
#2,057 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
26k
Forks
8.8k
Avg merge
1d 8h
Merged PRs (30d)
4

Description

- [ ] I have searched the [issues](https://github.com/seata/seata/issues) of this repository and believe that this is not a duplicate.

### Ⅰ. Describe what happened
微服务情况下,上传一个txt文件,消费者Controller(全局事务开启)正常接收,稍作处理后去调用提供者(通过feign调用),提供者报错,错误信息如下:
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'multipart/form-data;boundary=----WebKitFormBoundarylj3qe26Wz8idJh4U;charset=UTF-8' not supported
at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:224)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:157)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:126)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:166)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
```
Just paste your stack trace here!
```

### Ⅱ. Anything else we need to know?
1.这个错误在开启全局事务的情况下,报错。 不开启全局事务时,运行正常。
2.在提供者的AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters方法处断点调式,发现不开启全局事务时,提供者request的请求类型为application/json。 开启全局事务时,提供者request的请求类型为:multipart/form-data。
3.消费者调用的接口为:
```
@SinfFeignClient(value = "provider-acm-v1" )
public interface StaffApi {
@PostMapping(value = "/xxxx")
Message findAll(@RequestBody QueryInfo queryInfo);
}
```

### Ⅲ. Environment:
- seata 0.9.0
- com.alibaba.cloud.spring-cloud-alibaba-seata 2.1.0.RELEASE

Contributor guide

Open the contributing guide

Research direction

Start at Spring's AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters entry point and trace the StaffApi Feign call with and without a global transaction. Compare the request Content-Type and multipart handling in both paths; done means the provider accepts the request without the reported HttpMediaTypeNotSupportedException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend-api-design, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.