Upgrade to Spring Boot 3.2.0-RC2 (#4850)

#### What type of PR is this?

/kind cleanup
/area core
/milestone 2.11.x

#### What this PR does / why we need it:

- Upgrade to Spring Boot 3.2.0-RC2.
- Fix unit test errors due to upgrading.

See https://github.com/spring-projects/spring-boot/releases/tag/v3.2.0-RC2 for more.

#### Does this PR introduce a user-facing change?

Anyone who is using H2 database and wants to upgrade this version has to backup and restore Halo or upgrade old h2 database file manually.

```release-note
[Action Required] 升级 Spring Boot 至 3.2.0-RC2
```
pull/4854/head
John Niang 2023-11-13 17:28:08 +08:00 committed by GitHub
parent 70402994fa
commit 65a7e970cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 24 deletions

View File

@ -1,5 +1,5 @@
plugins {
id 'org.springframework.boot' version '3.1.5'
id 'org.springframework.boot' version '3.2.0-RC2'
id 'io.spring.dependency-management' version '1.1.0'
id "com.gorylenko.gradle-git-properties" version "2.3.2"
id "checkstyle"

View File

@ -31,7 +31,7 @@ public interface ReplyService {
reply -> reply.getMetadata().getCreationTimestamp();
// ascending order by creation time
// asc nulls high will be placed at the end
return Comparator.comparing(creationTime, Comparators.nullsHigh())
return Comparator.comparing(creationTime, Comparators.nullsLow())
.thenComparing(metadataCreationTime)
.thenComparing(reply -> reply.getMetadata().getName());
}

View File

@ -1,7 +1,10 @@
package run.halo.app.theme.finders.impl;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
import java.security.Principal;
import java.time.Instant;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
@ -9,7 +12,6 @@ import java.util.function.Function;
import java.util.function.Predicate;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.lang.Nullable;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
@ -254,35 +256,41 @@ public class CommentPublicQueryServiceImpl implements CommentPublicQueryService
public int compare(Comment c1, Comment c2) {
boolean c1Top = BooleanUtils.isTrue(c1.getSpec().getTop());
boolean c2Top = BooleanUtils.isTrue(c2.getSpec().getTop());
if (c1Top == c2Top) {
int c1Priority = ObjectUtils.defaultIfNull(c1.getSpec().getPriority(), 0);
int c2Priority = ObjectUtils.defaultIfNull(c2.getSpec().getPriority(), 0);
if (c1Top) {
// 都置顶
return Integer.compare(c1Priority, c2Priority);
// c1 top = true && c2 top = false
if (c1Top && !c2Top) {
return -1;
}
// 两个评论不置顶根据 creationTime 降序排列
return Comparator.comparing(
(Comment comment) -> comment.getSpec().getCreationTime(),
Comparators.nullsLow())
.thenComparing((Comment comment) -> comment.getMetadata().getName())
.compare(c2, c1);
} else if (c1Top) {
// 只有 c1 置顶c1 排前面
return -1;
} else {
// 只有c2置顶, c2排在前面
// c1 top = false && c2 top = true
if (!c1Top && c2Top) {
return 1;
}
// c1 top = c2 top = true || c1 top = c2 top = false
var priorityComparator = Comparator.<Comment, Integer>comparing(
comment -> defaultIfNull(comment.getSpec().getPriority(), 0));
var creationTimeComparator = Comparator.<Comment, Instant>comparing(
comment -> comment.getSpec().getCreationTime(),
Comparators.nullsLow(Comparator.<Instant>reverseOrder()));
var nameComparator = Comparator.<Comment, String>comparing(
comment -> comment.getMetadata().getName());
if (c1Top) {
return priorityComparator.thenComparing(creationTimeComparator)
.thenComparing(nameComparator)
.compare(c1, c2);
}
return creationTimeComparator.thenComparing(nameComparator).compare(c1, c2);
}
}
int pageNullSafe(Integer page) {
return ObjectUtils.defaultIfNull(page, 1);
return defaultIfNull(page, 1);
}
int sizeNullSafe(Integer size) {
return ObjectUtils.defaultIfNull(size, DEFAULT_SIZE);
return defaultIfNull(size, DEFAULT_SIZE);
}
}

View File

@ -164,7 +164,7 @@ class CommentPublicQueryServiceImplTest {
.map(Comment::getMetadata)
.map(MetadataOperator::getName)
.collect(Collectors.joining(", "));
assertThat(result).isEqualTo("1, 2, 3, 4, 5, 6, 9, 14, 10, 8, 7, 13, 12, 11");
assertThat(result).isEqualTo("1, 2, 4, 3, 5, 6, 10, 14, 9, 8, 7, 11, 12, 13");
}
@Test

View File

@ -1,7 +1,7 @@
import org.springframework.boot.gradle.plugin.SpringBootPlugin
plugins {
id 'org.springframework.boot' version '3.1.5' apply false
id 'org.springframework.boot' version '3.2.0-RC2' apply false
id 'java-platform'
id 'halo.publish'
id 'signing'