VampireAchao commented on PR #6242:
URL: https://github.com/apache/shenyu/pull/6242#issuecomment-3595703332

   Hi 2823602869,
   
   The root issue lies in the usage of PageHelper. In the default method 
`org.apache.shenyu.admin.service.PageService#searchByPage`, it returns `new 
PageInfo<>(searchByCondition(pageCondition.getCondition()))`. Here, the return 
value of `searchByCondition` might be an `ArrayList` rather than a 
`com.github.pagehelper.Page`. In the constructor 
`com.github.pagehelper.PageInfo#PageInfo(java.util.List<? extends T>, int)`, a 
`com.github.pagehelper.Page` object is required to correctly obtain the 
pagination result. Your change performs an extra, unnecessary `count` query and 
doesn’t take the `rule` module into account. You can take a look at this PR:
   
   https://github.com/apache/shenyu/pull/6243
   
   As a side note, `new 
PageInfo<>(searchByCondition(pageCondition.getCondition()))` is somewhat of a 
“trap” and can be misleading, because it’s not guaranteed whether 
`searchByCondition` returns a plain `ArrayList` or a 
`com.github.pagehelper.Page`. Given that `searchByCondition` is also used 
elsewhere, after carefully reviewing the related code I’ve only made changes, 
for now, to the `Selector` and `Rule` modules.
   
   I’m truly sorry that I didn’t see your PR before writing and submitting 
mine—I hope you won’t mind.
   
   Best,
   achao


-- 
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