[
https://issues.apache.org/jira/browse/SCB-2085?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Haishi Yao updated SCB-2085:
----------------------------
Description:
If the three conditions below are met:
1. If there are aggregated params(BeanParam for JAX-RS and query object for
SpringMVC),
2. and annotation @ApiParam is added behind another param annotation(like
QueryParam or RequestParam)
3. and the swagger parameter name is different from the producer parameter name
a NullPointException is triggered and the microservice instance boot up
procedure aborts.
For example, the code show below will trigger the problem, no matter whether
the param name is specified in @ApiParam:
{code:java}
public PageResp getPage(
@QueryParam("begin") @ApiParam(value = "start Unix time") long
beginTime,
@BeanParam PageInfo pageInfo) {
return new PageResp();
}
{code}
The root cause is that in the method
{code:java}
org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapperFactory#retrieveVisibleParamName(java.lang.reflect.Method,
int)
{code}
all of the annotations on the producer param are traversed to retrieve the
swagger param name, and the latter one will override the former one. If
@ApiParam is the last annotation of a producer param, the retrieved swagger
param name is null because the ArgumentsMapperFactory cannot retrieve the param
name from @ApiParam. As a result, the swagger param cannot be mapped properly
to the producer param.
was:
If the three conditions below are met:
1. If there are aggregated params(BeanParam for JAX-RS and query object for
SpringMVC),
2. and annotation @ApiParam is added behind another param annotation(like
QueryParam or RequestParam)
3. and the swagger parameter name is different from the producer parameter name
a NullPointException is triggered and the microservice instance boot up
procedure aborts.
The root cause is that in the method
{code:java}
org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapperFactory#retrieveVisibleParamName(java.lang.reflect.Method,
int)
{code}
all of the annotations on the producer param are traversed to retrieve the
swagger param name, and the latter one will override the former one. If
@ApiParam is the last annotation of a producer param, the retrieved swagger
param name is null because the ArgumentsMapperFactory cannot retrieve the param
name from @ApiParam. As a result, the swagger param cannot be mapped properly
to the producer param.
> NullPointerException triggered by @ApiParam on condition that aggregated
> params exist
> -------------------------------------------------------------------------------------
>
> Key: SCB-2085
> URL: https://issues.apache.org/jira/browse/SCB-2085
> Project: Apache ServiceComb
> Issue Type: Bug
> Components: Java-Chassis
> Affects Versions: java-chassis-1.3.0
> Reporter: Haishi Yao
> Assignee: Haishi Yao
> Priority: Major
>
> If the three conditions below are met:
> 1. If there are aggregated params(BeanParam for JAX-RS and query object for
> SpringMVC),
> 2. and annotation @ApiParam is added behind another param annotation(like
> QueryParam or RequestParam)
> 3. and the swagger parameter name is different from the producer parameter
> name
> a NullPointException is triggered and the microservice instance boot up
> procedure aborts.
> For example, the code show below will trigger the problem, no matter whether
> the param name is specified in @ApiParam:
> {code:java}
> public PageResp getPage(
> @QueryParam("begin") @ApiParam(value = "start Unix time") long
> beginTime,
> @BeanParam PageInfo pageInfo) {
> return new PageResp();
> }
> {code}
> The root cause is that in the method
> {code:java}
> org.apache.servicecomb.swagger.invocation.arguments.ArgumentsMapperFactory#retrieveVisibleParamName(java.lang.reflect.Method,
> int)
> {code}
> all of the annotations on the producer param are traversed to retrieve the
> swagger param name, and the latter one will override the former one. If
> @ApiParam is the last annotation of a producer param, the retrieved swagger
> param name is null because the ArgumentsMapperFactory cannot retrieve the
> param name from @ApiParam. As a result, the swagger param cannot be mapped
> properly to the producer param.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)