Further polishing regarding JDK baseline upgrade
See gh-28440
This commit is contained in:
parent
a892ce80c1
commit
eb50a6f4a0
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -100,8 +100,8 @@ public class AspectJAwareAdvisorAutoProxyCreator extends AbstractAdvisorAutoProx
|
|||
// TODO: Consider optimization by caching the list of the aspect names
|
||||
List<Advisor> candidateAdvisors = findCandidateAdvisors();
|
||||
for (Advisor advisor : candidateAdvisors) {
|
||||
if (advisor instanceof AspectJPointcutAdvisor &&
|
||||
((AspectJPointcutAdvisor) advisor).getAspectName().equals(beanName)) {
|
||||
if (advisor instanceof AspectJPointcutAdvisor pointcutAdvisor &&
|
||||
pointcutAdvisor.getAspectName().equals(beanName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -436,12 +436,11 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
|||
// Materialize interceptor chain from bean names.
|
||||
for (String name : this.interceptorNames) {
|
||||
if (name.endsWith(GLOBAL_SUFFIX)) {
|
||||
if (!(this.beanFactory instanceof ListableBeanFactory)) {
|
||||
if (!(this.beanFactory instanceof ListableBeanFactory lbf)) {
|
||||
throw new AopConfigException(
|
||||
"Can only use global advisors or interceptors with a ListableBeanFactory");
|
||||
}
|
||||
addGlobalAdvisors((ListableBeanFactory) this.beanFactory,
|
||||
name.substring(0, name.length() - GLOBAL_SUFFIX.length()));
|
||||
addGlobalAdvisors(lbf, name.substring(0, name.length() - GLOBAL_SUFFIX.length()));
|
||||
}
|
||||
|
||||
else {
|
||||
|
|
@ -475,16 +474,16 @@ public class ProxyFactoryBean extends ProxyCreatorSupport
|
|||
Advisor[] advisors = getAdvisors();
|
||||
List<Advisor> freshAdvisors = new ArrayList<>(advisors.length);
|
||||
for (Advisor advisor : advisors) {
|
||||
if (advisor instanceof PrototypePlaceholderAdvisor pa) {
|
||||
if (advisor instanceof PrototypePlaceholderAdvisor ppa) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Refreshing bean named '" + pa.getBeanName() + "'");
|
||||
logger.debug("Refreshing bean named '" + ppa.getBeanName() + "'");
|
||||
}
|
||||
// Replace the placeholder with a fresh prototype instance resulting from a getBean lookup
|
||||
if (this.beanFactory == null) {
|
||||
throw new IllegalStateException("No BeanFactory available anymore (probably due to " +
|
||||
"serialization) - cannot resolve prototype advisor '" + pa.getBeanName() + "'");
|
||||
"serialization) - cannot resolve prototype advisor '" + ppa.getBeanName() + "'");
|
||||
}
|
||||
Object bean = this.beanFactory.getBean(pa.getBeanName());
|
||||
Object bean = this.beanFactory.getBean(ppa.getBeanName());
|
||||
Advisor refreshedAdvisor = namedBeanToAdvisor(bean);
|
||||
freshAdvisors.add(refreshedAdvisor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -60,6 +60,7 @@ import org.springframework.util.StringUtils;
|
|||
* @author Stephane Nicoll
|
||||
* @author Rod Johnson
|
||||
* @author Rob Harrop
|
||||
* @author Sam Brannen
|
||||
* @since 4.2
|
||||
* @see #registerCustomEditor
|
||||
* @see #setPropertyValues
|
||||
|
|
@ -279,7 +280,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
private void processKeyedProperty(PropertyTokenHolder tokens, PropertyValue pv) {
|
||||
Object propValue = getPropertyHoldingValue(tokens);
|
||||
PropertyHandler ph = getLocalPropertyHandler(tokens.actualName);
|
||||
|
|
@ -318,9 +319,8 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
}
|
||||
}
|
||||
|
||||
else if (propValue instanceof List) {
|
||||
else if (propValue instanceof List list) {
|
||||
Class<?> requiredType = ph.getCollectionType(tokens.keys.length);
|
||||
List<Object> list = (List<Object>) propValue;
|
||||
int index = Integer.parseInt(lastKey);
|
||||
Object oldValue = null;
|
||||
if (isExtractOldValueForEditor() && index < list.size()) {
|
||||
|
|
@ -354,10 +354,9 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
}
|
||||
}
|
||||
|
||||
else if (propValue instanceof Map) {
|
||||
else if (propValue instanceof Map map) {
|
||||
Class<?> mapKeyType = ph.getMapKeyType(tokens.keys.length);
|
||||
Class<?> mapValueType = ph.getMapValueType(tokens.keys.length);
|
||||
Map<Object, Object> map = (Map<Object, Object>) propValue;
|
||||
// IMPORTANT: Do not pass full property name in here - property editors
|
||||
// must not kick in for map keys but rather only for map values.
|
||||
TypeDescriptor typeDescriptor = TypeDescriptor.valueOf(mapKeyType);
|
||||
|
|
@ -446,8 +445,8 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
oldValue = ph.getValue();
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (ex instanceof PrivilegedActionException) {
|
||||
ex = ((PrivilegedActionException) ex).getException();
|
||||
if (ex instanceof PrivilegedActionException pae) {
|
||||
ex = pae.getException();
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Could not read previous value of property '" +
|
||||
|
|
@ -617,7 +616,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
return nestedPa.getPropertyValue(tokens);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Nullable
|
||||
protected Object getPropertyValue(PropertyTokenHolder tokens) throws BeansException {
|
||||
String propertyName = tokens.canonicalName;
|
||||
|
|
@ -653,15 +652,13 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
value = growArrayIfNecessary(value, index, indexedPropertyName.toString());
|
||||
value = Array.get(value, index);
|
||||
}
|
||||
else if (value instanceof List) {
|
||||
else if (value instanceof List list) {
|
||||
int index = Integer.parseInt(key);
|
||||
List<Object> list = (List<Object>) value;
|
||||
growCollectionIfNecessary(list, index, indexedPropertyName.toString(), ph, i + 1);
|
||||
value = list.get(index);
|
||||
}
|
||||
else if (value instanceof Set) {
|
||||
else if (value instanceof Set set) {
|
||||
// Apply index to Iterator in case of a Set.
|
||||
Set<Object> set = (Set<Object>) value;
|
||||
int index = Integer.parseInt(key);
|
||||
if (index < 0 || index >= set.size()) {
|
||||
throw new InvalidPropertyException(getRootClass(), this.nestedPath + propertyName,
|
||||
|
|
@ -677,8 +674,7 @@ public abstract class AbstractNestablePropertyAccessor extends AbstractPropertyA
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (value instanceof Map) {
|
||||
Map<Object, Object> map = (Map<Object, Object>) value;
|
||||
else if (value instanceof Map map) {
|
||||
Class<?> mapKeyType = ph.getResolvableType().getNested(i + 1).asMap().resolveGeneric(0);
|
||||
// IMPORTANT: Do not pass full property name in here - property editors
|
||||
// must not kick in for map keys but rather only for map values.
|
||||
|
|
@ -841,7 +837,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 && optional.isEmpty()) {
|
||||
if (value == null || (value instanceof Optional<?> optional && optional.isEmpty())) {
|
||||
if (isAutoGrowNestedPaths()) {
|
||||
value = setDefaultValue(tokens);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -198,9 +198,9 @@ public abstract class BeanFactoryUtils {
|
|||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
pbf, type, includeNonSingletons, allowEagerInit);
|
||||
result = mergeNamesWithParent(result, parentResult, hbf);
|
||||
}
|
||||
}
|
||||
|
|
@ -259,9 +259,9 @@ public abstract class BeanFactoryUtils {
|
|||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForType(type, includeNonSingletons, allowEagerInit);
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
|
||||
String[] parentResult = beanNamesForTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type, includeNonSingletons, allowEagerInit);
|
||||
pbf, type, includeNonSingletons, allowEagerInit);
|
||||
result = mergeNamesWithParent(result, parentResult, hbf);
|
||||
}
|
||||
}
|
||||
|
|
@ -284,9 +284,8 @@ public abstract class BeanFactoryUtils {
|
|||
Assert.notNull(lbf, "ListableBeanFactory must not be null");
|
||||
String[] result = lbf.getBeanNamesForAnnotation(annotationType);
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
String[] parentResult = beanNamesForAnnotationIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), annotationType);
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
|
||||
String[] parentResult = beanNamesForAnnotationIncludingAncestors(pbf, annotationType);
|
||||
result = mergeNamesWithParent(result, parentResult, hbf);
|
||||
}
|
||||
}
|
||||
|
|
@ -321,9 +320,8 @@ public abstract class BeanFactoryUtils {
|
|||
Map<String, T> result = new LinkedHashMap<>(4);
|
||||
result.putAll(lbf.getBeansOfType(type));
|
||||
if (lbf instanceof HierarchicalBeanFactory hbf) {
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(
|
||||
(ListableBeanFactory) hbf.getParentBeanFactory(), type);
|
||||
if (hbf.getParentBeanFactory() instanceof ListableBeanFactory pbf) {
|
||||
Map<String, T> parentResult = beansOfTypeIncludingAncestors(pbf, type);
|
||||
parentResult.forEach((beanName, beanInstance) -> {
|
||||
if (!result.containsKey(beanName) && !hbf.containsLocalBean(beanName)) {
|
||||
result.put(beanName, beanInstance);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -423,7 +423,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
buf.append("; Domain=").append(cookie.getDomain());
|
||||
}
|
||||
int maxAge = cookie.getMaxAge();
|
||||
ZonedDateTime expires = (cookie instanceof MockCookie ? ((MockCookie) cookie).getExpires() : null);
|
||||
ZonedDateTime expires = (cookie instanceof MockCookie mockCookie? mockCookie.getExpires() : null);
|
||||
if (maxAge >= 0) {
|
||||
buf.append("; Max-Age=").append(maxAge);
|
||||
buf.append("; Expires=");
|
||||
|
|
@ -692,7 +692,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
return true;
|
||||
}
|
||||
else if (HttpHeaders.CONTENT_LENGTH.equalsIgnoreCase(name)) {
|
||||
setContentLength(value instanceof Number ? ((Number) value).intValue() :
|
||||
setContentLength(value instanceof Number number ? number.intValue() :
|
||||
Integer.parseInt(value.toString()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -177,8 +177,8 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
else if (o instanceof HttpMethod other) {
|
||||
return this.name.equals(other.name);
|
||||
else if (o instanceof HttpMethod otherMethod) {
|
||||
return this.name.equals(otherMethod.name);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -187,4 +187,5 @@ public final class HttpMethod implements Comparable<HttpMethod>, Serializable {
|
|||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -423,7 +423,7 @@ public class MockHttpServletResponse implements HttpServletResponse {
|
|||
buf.append("; Domain=").append(cookie.getDomain());
|
||||
}
|
||||
int maxAge = cookie.getMaxAge();
|
||||
ZonedDateTime expires = (cookie instanceof MockCookie ? ((MockCookie) cookie).getExpires() : null);
|
||||
ZonedDateTime expires = (cookie instanceof MockCookie mockCookie? mockCookie.getExpires() : null);
|
||||
if (maxAge >= 0) {
|
||||
buf.append("; Max-Age=").append(maxAge);
|
||||
buf.append("; Expires=");
|
||||
|
|
|
|||
|
|
@ -149,8 +149,8 @@ public class RequestMappingHandlerAdapter implements HandlerAdapter, Application
|
|||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
if (applicationContext instanceof ConfigurableApplicationContext) {
|
||||
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
|
||||
if (applicationContext instanceof ConfigurableApplicationContext cac) {
|
||||
this.applicationContext = cac;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
|
|||
Loading…
Reference in New Issue