This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new d4c85f237e fix:PageParameter throws NPE when pageSize is omitted 
(#6494)
d4c85f237e is described below

commit d4c85f237e9b5b8b4e5c4c40be9d740a8787173b
Author: hengyuss <[email protected]>
AuthorDate: Fri Jul 31 19:58:31 2026 +0800

    fix:PageParameter throws NPE when pageSize is omitted (#6494)
    
    Co-authored-by: xiaoyu <[email protected]>
---
 .../shenyu/admin/model/page/PageParameter.java      |  2 +-
 .../shenyu/admin/model/page/PageParameterTest.java  | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/page/PageParameter.java
 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/page/PageParameter.java
index 31dcfa418d..1a990c3330 100644
--- 
a/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/page/PageParameter.java
+++ 
b/shenyu-admin/src/main/java/org/apache/shenyu/admin/model/page/PageParameter.java
@@ -56,7 +56,7 @@ public class PageParameter implements Serializable {
      */
     public PageParameter(final Integer currentPage, final Integer pageSize) {
         this.currentPage = Objects.isNull(currentPage) || currentPage <= 0 ? 1 
: currentPage;
-        this.pageSize = Objects.isNull(currentPage) || pageSize <= 0 ? 
DEFAULT_PAGE_SIZE : pageSize;
+        this.pageSize = Objects.isNull(pageSize) || pageSize <= 0 ? 
DEFAULT_PAGE_SIZE : pageSize;
         this.offset = (this.currentPage - 1) * this.pageSize;
     }
 
diff --git 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/page/PageParameterTest.java
 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/page/PageParameterTest.java
index 2be91261bd..6bac493c18 100644
--- 
a/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/page/PageParameterTest.java
+++ 
b/shenyu-admin/src/test/java/org/apache/shenyu/admin/model/page/PageParameterTest.java
@@ -36,6 +36,27 @@ public final class PageParameterTest {
         pageParameterUnderTest = new PageParameter(1, 10, 100);
     }
 
+    @Test
+    public void testNullPageSize() {
+        PageParameter param = new PageParameter(1, null);
+        assertEquals(1, param.getCurrentPage());
+        assertEquals(12, param.getPageSize());
+    }
+
+    @Test
+    public void testNullCurrentPageAndPageSize() {
+        PageParameter param = new PageParameter(null, null);
+        assertEquals(1, param.getCurrentPage());
+        assertEquals(12, param.getPageSize());
+    }
+
+    @Test
+    public void testNegativePageSize() {
+        PageParameter param = new PageParameter(1, -1);
+        assertEquals(1, param.getCurrentPage());
+        assertEquals(12, param.getPageSize());
+    }
+
     @Test
     public void testEquals() {
         assertEquals(pageParameterUnderTest.getCurrentPage(), 1);

Reply via email to