mirror of https://github.com/halo-dev/halo
chore: compatibility support for null for sort parameter of listAll (#6230)
#### What type of PR is this? /area core /milestone 2.17.x #### What this PR does / why we need it: 由于2.17.0 修改了 listAll 的实现导致出现了不兼容 Sort 参数为 null 的情况,考虑到给开发者适应的时间因此先兼容并给出警告日志 see also #6219 #### Which issue(s) this PR fixes: Fixes #6219 #### Does this PR introduce a user-facing change? ```release-note None ```pull/6239/head
parent
967eaa21e1
commit
e7f4419131
|
@ -11,6 +11,7 @@ import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
@ -112,9 +113,17 @@ public class ReactiveExtensionClientImpl implements ReactiveExtensionClient {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <E extends Extension> Flux<E> listAll(Class<E> type, ListOptions options, Sort sort) {
|
public <E extends Extension> Flux<E> listAll(Class<E> type, ListOptions options, Sort sort) {
|
||||||
|
var nullSafeSort = Optional.ofNullable(sort)
|
||||||
|
.orElseGet(() -> {
|
||||||
|
log.warn("The sort parameter is null, it is recommended to use Sort.unsorted() "
|
||||||
|
+ "instead and the compatibility support for null will be removed in the "
|
||||||
|
+ "subsequent version.");
|
||||||
|
return Sort.unsorted();
|
||||||
|
});
|
||||||
var scheme = schemeManager.get(type);
|
var scheme = schemeManager.get(type);
|
||||||
return Mono.fromSupplier(
|
return Mono.fromSupplier(
|
||||||
() -> indexedQueryEngine.retrieveAll(scheme.groupVersionKind(), options, sort))
|
() -> indexedQueryEngine.retrieveAll(scheme.groupVersionKind(), options,
|
||||||
|
nullSafeSort))
|
||||||
.doOnSuccess(objectKeys -> {
|
.doOnSuccess(objectKeys -> {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
if (objectKeys.size() > 500) {
|
if (objectKeys.size() > 500) {
|
||||||
|
|
Loading…
Reference in New Issue