Polishing regarding JDK baseline upgrade

Closes gh-28440
This commit is contained in:
lihan
2022-05-10 21:11:07 +08:00
committed by Sam Brannen
parent 5c5c89e9fe
commit a892ce80c1
9 changed files with 21 additions and 26 deletions

View File

@@ -841,7 +841,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
PropertyTokenHolder tokens = getPropertyNameTokens(nestedProperty);
String canonicalName = tokens.canonicalName;
Object value = getPropertyValue(tokens);
if (value == null || (value instanceof Optional && !((Optional<?>) value).isPresent())) {
if (value == null || (value instanceof Optional<?> optional && optional.isEmpty()) {
if (isAutoGrowNestedPaths()) {
value = setDefaultValue(tokens);
}

View File

@@ -162,9 +162,8 @@ public abstract class BeanFactoryUtils {
Assert.notNull(lbf, "ListableBeanFactory must not be null");
String[] result = lbf.getBeanNamesForType(type);
if (lbf instanceof HierarchicalBeanFactory hbf) {
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
String[] parentResult = beanNamesForTypeIncludingAncestors(
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
String[] parentResult = beanNamesForTypeIncludingAncestors(pbf, type);
result = mergeNamesWithParent(result, parentResult, hbf);
}
}
@@ -225,9 +224,8 @@ public abstract class BeanFactoryUtils {
Assert.notNull(lbf, "ListableBeanFactory must not be null");
String[] result = lbf.getBeanNamesForType(type);
if (lbf instanceof HierarchicalBeanFactory hbf) {
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
String[] parentResult = beanNamesForTypeIncludingAncestors(
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
String[] parentResult = beanNamesForTypeIncludingAncestors(pbf, type);
result = mergeNamesWithParent(result, parentResult, hbf);
}
}
@@ -371,9 +369,8 @@ public abstract class BeanFactoryUtils {
Map<String, T> result = new LinkedHashMap<>(4);
result.putAll(lbf.getBeansOfType(type, includeNonSingletons, allowEagerInit));
if (lbf instanceof HierarchicalBeanFactory hbf) {
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
Map<String, T> parentResult = beansOfTypeIncludingAncestors(pbf, type, includeNonSingletons, allowEagerInit);
parentResult.forEach((beanName, beanInstance) -> {
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
result.put(beanName, beanInstance);