Aias00 opened a new issue, #6463:
URL: https://github.com/apache/shenyu/issues/6463

   ### Is there an existing issue for this?
   
   - [x] I have searched the existing issues
   
   ### Current Behavior
   
   `PageParameter(Integer currentPage, Integer pageSize)` checks `currentPage` 
twice and then unboxes `pageSize`:
   
   ```java
   this.currentPage = Objects.isNull(currentPage) || currentPage <= 0 ? 1 : 
currentPage;
   this.pageSize = Objects.isNull(currentPage) || pageSize <= 0 ? 
DEFAULT_PAGE_SIZE : pageSize;
   ```
   
   If a request provides `currentPage` but omits `pageSize`, `pageSize <= 0` 
throws `NullPointerException` instead of falling back to `DEFAULT_PAGE_SIZE`.
   
   This constructor is used by many admin list endpoints, for example:
   
   - `AiProxyApiKeyController#listByPage`
   - `AlertReceiverController#listByPage`
   - `ApiController#listByPage`
   - `PluginController#listByPage`
   - `SelectorController` / `RuleController` query flows via their query DTOs
   
   So a request such as `?currentPage=1` without `pageSize` can fail with a 
server error for endpoints that otherwise intend to default pagination values.
   
   ### Expected Behavior
   
   `pageSize` should be checked independently:
   
   ```java
   this.pageSize = Objects.isNull(pageSize) || pageSize <= 0 ? 
DEFAULT_PAGE_SIZE : pageSize;
   ```
   
   Requests with missing or non-positive `pageSize` should use 
`DEFAULT_PAGE_SIZE` instead of throwing.
   
   ### Steps To Reproduce
   
   1. Call any admin list endpoint that constructs `new 
PageParameter(currentPage, pageSize)`.
   2. Include `currentPage`, but omit `pageSize`, for example `?currentPage=1`.
   3. The constructor attempts to evaluate `pageSize <= 0` and throws 
`NullPointerException`.
   
   ### Environment
   
   ```markdown
   ShenYu version(s): current master
   ```
   
   ### Debug logs
   
   _No response_
   
   ### Anything else?
   
   The likely typo is in 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/model/page/PageParameter.java`
 line 59 on current master.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to