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
guqing 2024-07-01 14:59:17 +08:00 committed by GitHub
parent 967eaa21e1
commit e7f4419131
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicBoolean;
@ -112,9 +113,17 @@ public class ReactiveExtensionClientImpl implements ReactiveExtensionClient {
@Override
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);
return Mono.fromSupplier(
() -> indexedQueryEngine.retrieveAll(scheme.groupVersionKind(), options, sort))
() -> indexedQueryEngine.retrieveAll(scheme.groupVersionKind(), options,
nullSafeSort))
.doOnSuccess(objectKeys -> {
if (log.isDebugEnabled()) {
if (objectKeys.size() > 500) {