Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,10 @@ static class SimplePageable implements Pageable {

private final PageRequest delegate;

SimplePageable(@JsonProperty("pageNumber") int number, @JsonProperty("pageSize") int size,
@JsonProperty("sort") Sort sort) {
SimplePageable(
@JsonProperty("pageNumber") @JsonAlias({"page-number", "page_number", "pagenumber", "PageNumber"}) int number,
@JsonProperty("pageSize") @JsonAlias({"page-size", "page_size", "pagesize", "PageSize"}) int size,
Comment on lines +246 to +247
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor formatting: these @JsonAlias array initializers omit the spaces used elsewhere in this file (e.g., @JsonAlias({ "total-elements", ... })). Consider formatting consistently to avoid style/linter churn.

Suggested change
@JsonProperty("pageNumber") @JsonAlias({"page-number", "page_number", "pagenumber", "PageNumber"}) int number,
@JsonProperty("pageSize") @JsonAlias({"page-size", "page_size", "pagesize", "PageSize"}) int size,
@JsonProperty("pageNumber") @JsonAlias({ "page-number", "page_number", "pagenumber", "PageNumber" }) int number,
@JsonProperty("pageSize") @JsonAlias({ "page-size", "page_size", "pagesize", "PageSize" }) int size,

Copilot uses AI. Check for mistakes.
@JsonProperty("sort") Sort sort) {
delegate = buildPageRequest(number, size, sort);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,71 @@ void serializeAndDeserializeFilledMultipleCascade() throws JsonProcessingExcepti
assertThat(cascadedResult.getPageable().getPageNumber()).isEqualTo(6);
}

@Test
void deserializePageableWithHyphenatedAlias() {
// Given
File file = new File("./src/test/resources/withPageableAliasHyphen.json");
// When
Page<?> result = objectMapper.readValue(file, Page.class);
Comment on lines +191 to +196
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectMapper.readValue(File, ...) throws IOException, but this test method does not declare/handle it, so the test class will not compile. Add throws IOException (or throws Exception) to the method signature, or wrap the call in a try/catch and fail the test on exception.

Copilot uses AI. Check for mistakes.
// Then
assertThat(result).isNotNull();
assertThat(result.getTotalElements()).isEqualTo(15);
assertThat(result.getContent()).hasSize(10);
assertThat(result.getPageable()).isNotNull();
assertThat(result.getPageable().getPageNumber()).isEqualTo(2);
assertThat(result.getPageable().getPageSize()).isEqualTo(3);
assertThat(result.getPageable().getSort().getOrderFor("firstName").getDirection())
.isEqualTo(Sort.Direction.ASC);
}

@Test
void deserializePageableWithUnderscoreAlias() {
// Given
File file = new File("./src/test/resources/withPageableAliasUnderscore.json");
// When
Page<?> result = objectMapper.readValue(file, Page.class);
Comment on lines +208 to +213
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectMapper.readValue(File, ...) throws IOException, but this test method does not declare/handle it, so the test class will not compile. Add throws IOException (or throws Exception) to the method signature, or wrap the call in a try/catch and fail the test on exception.

Copilot uses AI. Check for mistakes.
// Then
Comment on lines +209 to +214
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These alias tests use the default ObjectMapper configuration, but the reported regression occurs specifically when a global PropertyNamingStrategies.SNAKE_CASE strategy is enabled. Consider adding a test that builds/configures an ObjectMapper with SNAKE_CASE and verifies the same JSON (e.g., page_number / page_size) deserializes correctly, so the original issue is covered end-to-end.

Copilot uses AI. Check for mistakes.
assertThat(result).isNotNull();
assertThat(result.getTotalElements()).isEqualTo(10);
assertThat(result.getContent()).hasSize(10);
assertThat(result.getPageable()).isNotNull();
assertThat(result.getPageable().getPageNumber()).isEqualTo(1);
assertThat(result.getPageable().getPageSize()).isEqualTo(2);
assertThat(result.getPageable().getSort().getOrderFor("lastName").getDirection())
.isEqualTo(Sort.Direction.DESC);
}

@Test
void deserializePageableWithLowercaseAlias() {
// Given
File file = new File("./src/test/resources/withPageableAliasLowercase.json");
// When
Page<?> result = objectMapper.readValue(file, Page.class);
Comment on lines +225 to +230
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectMapper.readValue(File, ...) throws IOException, but this test method does not declare/handle it, so the test class will not compile. Add throws IOException (or throws Exception) to the method signature, or wrap the call in a try/catch and fail the test on exception.

Copilot uses AI. Check for mistakes.
// Then
assertThat(result).isNotNull();
assertThat(result.getTotalElements()).isEqualTo(8);
assertThat(result.getContent()).hasSize(10);
assertThat(result.getPageable()).isNotNull();
assertThat(result.getPageable().getPageNumber()).isEqualTo(0);
assertThat(result.getPageable().getPageSize()).isEqualTo(4);
assertThat(result.getPageable().getSort()).isEqualTo(Sort.unsorted());
}

@Test
void deserializePageableWithPascalCaseAlias() {
// Given
File file = new File("./src/test/resources/withPageableAliasPascalCase.json");
// When
Page<?> result = objectMapper.readValue(file, Page.class);
Comment on lines +241 to +246
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectMapper.readValue(File, ...) throws IOException, but this test method does not declare/handle it, so the test class will not compile. Add throws IOException (or throws Exception) to the method signature, or wrap the call in a try/catch and fail the test on exception.

Copilot uses AI. Check for mistakes.
// Then
assertThat(result).isNotNull();
assertThat(result.getTotalElements()).isEqualTo(20);
assertThat(result.getContent()).hasSize(10);
assertThat(result.getPageable()).isNotNull();
assertThat(result.getPageable().getPageNumber()).isEqualTo(3);
assertThat(result.getPageable().getPageSize()).isEqualTo(2);
assertThat(result.getPageable().getSort().getOrderFor("firstName").getDirection())
.isEqualTo(Sort.Direction.ASC);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"content": [
{
"id": 3,
"lastName": "Williams",
"firstName": "Thomas",
"email": "w.t@my.domain.com"
},
{
"id": 1,
"lastName": "Smith",
"firstName": "James",
"email": "s.j@my.domain.com"
},
{
"id": 11,
"lastName": "Scott",
"firstName": "Steven",
"email": "s.s@my.domain.com"
},
{
"id": 8,
"lastName": "Rodriguez",
"firstName": "Daniel",
"email": "r.d@my.domain.com"
},
{
"id": 9,
"lastName": "Martinez",
"firstName": "Robert",
"email": "m.r@my.domain.com"
},
{
"id": 5,
"lastName": "Jones",
"firstName": "James",
"email": "j.j@my.domain.com"
},
{
"id": 2,
"lastName": "Johnson",
"firstName": "Robert",
"email": "j.r@my.domain.com"
},
{
"id": 6,
"lastName": "Garcia",
"firstName": "William",
"email": "g.w@my.domain.com"
},
{
"id": 7,
"lastName": "Davis",
"firstName": "Richard",
"email": "d.r@my.domain.com"
},
{
"id": 4,
"lastName": "Brown",
"firstName": "Paul",
"email": "b.p@my.domain.com"
}
],
"pageable": {
"page-number": 2,
"page-size": 3,
"sort": {
"orders": [
{
"direction": "ASC",
"property": "firstName"
}
]
}
},
"totalElements": 15
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"content": [
{
"id": 3,
"lastName": "Williams",
"firstName": "Thomas",
"email": "w.t@my.domain.com"
},
{
"id": 1,
"lastName": "Smith",
"firstName": "James",
"email": "s.j@my.domain.com"
},
{
"id": 11,
"lastName": "Scott",
"firstName": "Steven",
"email": "s.s@my.domain.com"
},
{
"id": 8,
"lastName": "Rodriguez",
"firstName": "Daniel",
"email": "r.d@my.domain.com"
},
{
"id": 9,
"lastName": "Martinez",
"firstName": "Robert",
"email": "m.r@my.domain.com"
},
{
"id": 5,
"lastName": "Jones",
"firstName": "James",
"email": "j.j@my.domain.com"
},
{
"id": 2,
"lastName": "Johnson",
"firstName": "Robert",
"email": "j.r@my.domain.com"
},
{
"id": 6,
"lastName": "Garcia",
"firstName": "William",
"email": "g.w@my.domain.com"
},
{
"id": 7,
"lastName": "Davis",
"firstName": "Richard",
"email": "d.r@my.domain.com"
},
{
"id": 4,
"lastName": "Brown",
"firstName": "Paul",
"email": "b.p@my.domain.com"
}
],
"pageable": {
"pagenumber": 0,
"pagesize": 4,
"sort": {
"orders": []
}
},
"totalElements": 8
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"content": [
{
"id": 3,
"lastName": "Williams",
"firstName": "Thomas",
"email": "w.t@my.domain.com"
},
{
"id": 1,
"lastName": "Smith",
"firstName": "James",
"email": "s.j@my.domain.com"
},
{
"id": 11,
"lastName": "Scott",
"firstName": "Steven",
"email": "s.s@my.domain.com"
},
{
"id": 8,
"lastName": "Rodriguez",
"firstName": "Daniel",
"email": "r.d@my.domain.com"
},
{
"id": 9,
"lastName": "Martinez",
"firstName": "Robert",
"email": "m.r@my.domain.com"
},
{
"id": 5,
"lastName": "Jones",
"firstName": "James",
"email": "j.j@my.domain.com"
},
{
"id": 2,
"lastName": "Johnson",
"firstName": "Robert",
"email": "j.r@my.domain.com"
},
{
"id": 6,
"lastName": "Garcia",
"firstName": "William",
"email": "g.w@my.domain.com"
},
{
"id": 7,
"lastName": "Davis",
"firstName": "Richard",
"email": "d.r@my.domain.com"
},
{
"id": 4,
"lastName": "Brown",
"firstName": "Paul",
"email": "b.p@my.domain.com"
}
],
"pageable": {
"PageNumber": 3,
"PageSize": 2,
"sort": {
"orders": [
{
"direction": "ASC",
"property": "firstName"
}
]
}
},
"totalElements": 20
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"content": [
{
"id": 3,
"lastName": "Williams",
"firstName": "Thomas",
"email": "w.t@my.domain.com"
},
{
"id": 1,
"lastName": "Smith",
"firstName": "James",
"email": "s.j@my.domain.com"
},
{
"id": 11,
"lastName": "Scott",
"firstName": "Steven",
"email": "s.s@my.domain.com"
},
{
"id": 8,
"lastName": "Rodriguez",
"firstName": "Daniel",
"email": "r.d@my.domain.com"
},
{
"id": 9,
"lastName": "Martinez",
"firstName": "Robert",
"email": "m.r@my.domain.com"
},
{
"id": 5,
"lastName": "Jones",
"firstName": "James",
"email": "j.j@my.domain.com"
},
{
"id": 2,
"lastName": "Johnson",
"firstName": "Robert",
"email": "j.r@my.domain.com"
},
{
"id": 6,
"lastName": "Garcia",
"firstName": "William",
"email": "g.w@my.domain.com"
},
{
"id": 7,
"lastName": "Davis",
"firstName": "Richard",
"email": "d.r@my.domain.com"
},
{
"id": 4,
"lastName": "Brown",
"firstName": "Paul",
"email": "b.p@my.domain.com"
}
],
"pageable": {
"page_number": 1,
"page_size": 2,
"sort": {
"orders": [
{
"direction": "DESC",
"property": "lastName"
}
]
}
},
"totalElements": 10
}
Loading