Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Spring Boot 3.2.0-RC2 #4850

Merged
Merged
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
2 changes: 1 addition & 1 deletion application/build.gradle
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static Comparator<Reply> creationTimeAscComparator() {
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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
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;
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;
Expand Down Expand Up @@ -254,35 +256,41 @@ static class CommentComparator implements Comparator<Comment> {
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);
}

// 两个评论不置顶根据 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 排前面

// c1 top = true && c2 top = false
if (c1Top && !c2Top) {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void commentComparator() {
.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
Expand Down
2 changes: 1 addition & 1 deletion platform/application/build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down