You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@servicecomb.apache.org by "liubao (Jira)" <ji...@apache.org> on 2022/10/21 10:51:00 UTC

[jira] [Closed] (SCB-2085) NullPointerException triggered by @ApiParam on condition that aggregated params exist

     [ https://issues.apache.org/jira/browse/SCB-2085?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

liubao closed SCB-2085.
-----------------------
    Resolution: Won't Fix

> 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.20.10#820010)