diff --git a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java index 4baa57cb7bdb..c2fb1aca6f71 100644 --- a/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java +++ b/spring-beans/src/main/java/org/springframework/beans/BeanWrapperImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -97,7 +97,7 @@ public BeanWrapperImpl(boolean registerDefaultEditors) { /** * Create a new BeanWrapperImpl for the given object. - * @param object object wrapped by this BeanWrapper + * @param object the object wrapped by this BeanWrapper */ public BeanWrapperImpl(Object object) { super(object); @@ -114,7 +114,7 @@ public BeanWrapperImpl(Class clazz) { /** * Create a new BeanWrapperImpl for the given object, * registering a nested path that the object is in. - * @param object object wrapped by this BeanWrapper + * @param object the object wrapped by this BeanWrapper * @param nestedPath the nested path of the object * @param rootObject the root object at the top of the path */ @@ -125,7 +125,7 @@ public BeanWrapperImpl(Object object, String nestedPath, Object rootObject) { /** * Create a new BeanWrapperImpl for the given object, * registering a nested path that the object is in. - * @param object object wrapped by this BeanWrapper + * @param object the object wrapped by this BeanWrapper * @param nestedPath the nested path of the object * @param parent the containing BeanWrapper (must not be {@code null}) */ @@ -289,15 +289,15 @@ public TypeDescriptor nested(int level) { @Override @Nullable public Object getValue() throws Exception { - final Method readMethod = this.pd.getReadMethod(); + Method readMethod = this.pd.getReadMethod(); if (System.getSecurityManager() != null) { AccessController.doPrivileged((PrivilegedAction) () -> { ReflectionUtils.makeAccessible(readMethod); return null; }); try { - return AccessController.doPrivileged((PrivilegedExceptionAction) () -> - readMethod.invoke(getWrappedInstance(), (Object[]) null), acc); + return AccessController.doPrivileged((PrivilegedExceptionAction) + () -> readMethod.invoke(getWrappedInstance(), (Object[]) null), acc); } catch (PrivilegedActionException pae) { throw pae.getException(); @@ -310,8 +310,8 @@ public Object getValue() throws Exception { } @Override - public void setValue(final @Nullable Object value) throws Exception { - final Method writeMethod = (this.pd instanceof GenericTypeAwarePropertyDescriptor ? + public void setValue(@Nullable Object value) throws Exception { + Method writeMethod = (this.pd instanceof GenericTypeAwarePropertyDescriptor ? ((GenericTypeAwarePropertyDescriptor) this.pd).getWriteMethodForActualAccess() : this.pd.getWriteMethod()); if (System.getSecurityManager() != null) { @@ -320,8 +320,8 @@ public void setValue(final @Nullable Object value) throws Exception { return null; }); try { - AccessController.doPrivileged((PrivilegedExceptionAction) () -> - writeMethod.invoke(getWrappedInstance(), value), acc); + AccessController.doPrivileged((PrivilegedExceptionAction) + () -> writeMethod.invoke(getWrappedInstance(), value), acc); } catch (PrivilegedActionException ex) { throw ex.getException(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java index 20383c0e775c..d88630a950d9 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -309,7 +309,7 @@ public T createBean(Class beanClass) throws BeansException { public void autowireBean(Object existingBean) { // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean)); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); bd.allowCaching = ClassUtils.isCacheSafe(bd.getBeanClass(), getBeanClassLoader()); BeanWrapper bw = new BeanWrapperImpl(existingBean); initBeanWrapper(bw); @@ -329,7 +329,7 @@ public Object configureBean(Object existingBean, String beanName) throws BeansEx bd = new RootBeanDefinition(mbd); } if (!bd.isPrototype()) { - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); bd.allowCaching = ClassUtils.isCacheSafe(ClassUtils.getUserClass(existingBean), getBeanClassLoader()); } BeanWrapper bw = new BeanWrapperImpl(existingBean); @@ -347,28 +347,27 @@ public Object configureBean(Object existingBean, String beanName) throws BeansEx public Object createBean(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); return createBean(beanClass.getName(), bd, null); } @Override public Object autowire(Class beanClass, int autowireMode, boolean dependencyCheck) throws BeansException { // Use non-singleton bean definition, to avoid registering bean as dependent bean. - final RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + RootBeanDefinition bd = new RootBeanDefinition(beanClass, autowireMode, dependencyCheck); + bd.setScope(SCOPE_PROTOTYPE); if (bd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR) { return autowireConstructor(beanClass.getName(), bd, null, null).getWrappedInstance(); } else { Object bean; - final BeanFactory parent = this; if (System.getSecurityManager() != null) { - bean = AccessController.doPrivileged((PrivilegedAction) () -> - getInstantiationStrategy().instantiate(bd, null, parent), + bean = AccessController.doPrivileged( + (PrivilegedAction) () -> getInstantiationStrategy().instantiate(bd, null, this), getAccessControlContext()); } else { - bean = getInstantiationStrategy().instantiate(bd, null, parent); + bean = getInstantiationStrategy().instantiate(bd, null, this); } populateBean(beanClass.getName(), bd, new BeanWrapperImpl(bean)); return bean; @@ -385,7 +384,7 @@ public void autowireBeanProperties(Object existingBean, int autowireMode, boolea // Use non-singleton bean definition, to avoid registering bean as dependent bean. RootBeanDefinition bd = new RootBeanDefinition(ClassUtils.getUserClass(existingBean), autowireMode, dependencyCheck); - bd.setScope(BeanDefinition.SCOPE_PROTOTYPE); + bd.setScope(SCOPE_PROTOTYPE); BeanWrapper bw = new BeanWrapperImpl(existingBean); initBeanWrapper(bw); populateBean(bd.getBeanClass().getName(), bd, bw); @@ -543,7 +542,7 @@ protected Object createBean(String beanName, RootBeanDefinition mbd, @Nullable O * @see #instantiateUsingFactoryMethod * @see #autowireConstructor */ - protected Object doCreateBean(final String beanName, final RootBeanDefinition mbd, final @Nullable Object[] args) + protected Object doCreateBean(String beanName, RootBeanDefinition mbd, @Nullable Object[] args) throws BeanCreationException { // Instantiate the bean. @@ -554,7 +553,7 @@ protected Object doCreateBean(final String beanName, final RootBeanDefinition mb if (instanceWrapper == null) { instanceWrapper = createBeanInstance(beanName, mbd, args); } - final Object bean = instanceWrapper.getWrappedInstance(); + Object bean = instanceWrapper.getWrappedInstance(); Class beanType = instanceWrapper.getWrappedClass(); if (beanType != NullBean.class) { mbd.resolvedTargetType = beanType; @@ -623,7 +622,7 @@ else if (!this.allowRawInjectionDespiteWrapping && hasDependentBean(beanName)) { "] in its raw version as part of a circular reference, but has eventually been " + "wrapped. This means that said other beans do not use the final version of the " + "bean. This is often the result of over-eager type matching - consider using " + - "'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example."); + "'getBeanNamesForType' with the 'allowEagerInit' flag turned off, for example."); } } } @@ -899,7 +898,7 @@ protected Class getTypeForFactoryBean(String beanName, RootBeanDefinition mbd * @return the common {@code FactoryBean} object type, or {@code null} if none */ @Nullable - private Class getTypeForFactoryBeanFromMethod(Class beanClass, final String factoryMethodName) { + private Class getTypeForFactoryBeanFromMethod(Class beanClass, String factoryMethodName) { /** * Holder used to keep a reference to a {@code Class} value. @@ -1281,17 +1280,16 @@ protected Constructor[] determineConstructorsFromBeanPostProcessors(@Nullable * @param mbd the bean definition for the bean * @return a BeanWrapper for the new instance */ - protected BeanWrapper instantiateBean(final String beanName, final RootBeanDefinition mbd) { + protected BeanWrapper instantiateBean(String beanName, RootBeanDefinition mbd) { try { Object beanInstance; - final BeanFactory parent = this; if (System.getSecurityManager() != null) { - beanInstance = AccessController.doPrivileged((PrivilegedAction) () -> - getInstantiationStrategy().instantiate(mbd, beanName, parent), + beanInstance = AccessController.doPrivileged( + (PrivilegedAction) () -> getInstantiationStrategy().instantiate(mbd, beanName, this), getAccessControlContext()); } else { - beanInstance = getInstantiationStrategy().instantiate(mbd, beanName, parent); + beanInstance = getInstantiationStrategy().instantiate(mbd, beanName, this); } BeanWrapper bw = new BeanWrapperImpl(beanInstance); initBeanWrapper(bw); @@ -1747,7 +1745,7 @@ private Object convertForProperty( * @see #invokeInitMethods * @see #applyBeanPostProcessorsAfterInitialization */ - protected Object initializeBean(final String beanName, final Object bean, @Nullable RootBeanDefinition mbd) { + protected Object initializeBean(String beanName, Object bean, @Nullable RootBeanDefinition mbd) { if (System.getSecurityManager() != null) { AccessController.doPrivileged((PrivilegedAction) () -> { invokeAwareMethods(beanName, bean); @@ -1778,7 +1776,7 @@ protected Object initializeBean(final String beanName, final Object bean, @Nulla return wrappedBean; } - private void invokeAwareMethods(final String beanName, final Object bean) { + private void invokeAwareMethods(String beanName, Object bean) { if (bean instanceof Aware) { if (bean instanceof BeanNameAware) { ((BeanNameAware) bean).setBeanName(beanName); @@ -1807,7 +1805,7 @@ private void invokeAwareMethods(final String beanName, final Object bean) { * @throws Throwable if thrown by init methods or by the invocation process * @see #invokeCustomInitMethod */ - protected void invokeInitMethods(String beanName, final Object bean, @Nullable RootBeanDefinition mbd) + protected void invokeInitMethods(String beanName, Object bean, @Nullable RootBeanDefinition mbd) throws Throwable { boolean isInitializingBean = (bean instanceof InitializingBean); @@ -1848,7 +1846,7 @@ protected void invokeInitMethods(String beanName, final Object bean, @Nullable R * methods with arguments. * @see #invokeInitMethods */ - protected void invokeCustomInitMethod(String beanName, final Object bean, RootBeanDefinition mbd) + protected void invokeCustomInitMethod(String beanName, Object bean, RootBeanDefinition mbd) throws Throwable { String initMethodName = mbd.getInitMethodName(); @@ -1883,8 +1881,8 @@ protected void invokeCustomInitMethod(String beanName, final Object bean, RootBe return null; }); try { - AccessController.doPrivileged((PrivilegedExceptionAction) () -> - methodToInvoke.invoke(bean), getAccessControlContext()); + AccessController.doPrivileged((PrivilegedExceptionAction) + () -> methodToInvoke.invoke(bean), getAccessControlContext()); } catch (PrivilegedActionException pae) { InvocationTargetException ex = (InvocationTargetException) pae.getException(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 06d9b372303a..dd498ce0f1e1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -147,7 +147,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp /** String resolvers to apply e.g. to annotation attribute values. */ private final List embeddedValueResolvers = new CopyOnWriteArrayList<>(); - /** BeanPostProcessors to apply in createBean. */ + /** BeanPostProcessors to apply. */ private final List beanPostProcessors = new CopyOnWriteArrayList<>(); /** Indicates whether any InstantiationAwareBeanPostProcessors have been registered. */ @@ -236,10 +236,11 @@ public T getBean(String name, @Nullable Class requiredType, @Nullable Obj * @throws BeansException if the bean could not be created */ @SuppressWarnings("unchecked") - protected T doGetBean(final String name, @Nullable final Class requiredType, - @Nullable final Object[] args, boolean typeCheckOnly) throws BeansException { + protected T doGetBean( + String name, @Nullable Class requiredType, @Nullable Object[] args, boolean typeCheckOnly) + throws BeansException { - final String beanName = transformedBeanName(name); + String beanName = transformedBeanName(name); Object bean; // Eagerly check singleton cache for manually registered singletons. @@ -291,7 +292,7 @@ else if (requiredType != null) { } try { - final RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); + RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); checkMergedBeanDefinition(mbd, beanName, args); // Guarantee initialization of beans that the current bean depends on. @@ -345,7 +346,10 @@ else if (mbd.isPrototype()) { else { String scopeName = mbd.getScope(); - final Scope scope = this.scopes.get(scopeName); + if (!StringUtils.hasLength(scopeName)) { + throw new IllegalStateException("No scope name defined for bean ยด" + beanName + "'"); + } + Scope scope = this.scopes.get(scopeName); if (scope == null) { throw new IllegalStateException("No Scope registered for scope name '" + scopeName + "'"); } @@ -469,10 +473,12 @@ public boolean isPrototype(String name) throws NoSuchBeanDefinitionException { return false; } if (isFactoryBean(beanName, mbd)) { - final FactoryBean fb = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName); + FactoryBean fb = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName); if (System.getSecurityManager() != null) { - return AccessController.doPrivileged((PrivilegedAction) () -> - ((fb instanceof SmartFactoryBean && ((SmartFactoryBean) fb).isPrototype()) || !fb.isSingleton()), + return AccessController.doPrivileged( + (PrivilegedAction) () -> + ((fb instanceof SmartFactoryBean && ((SmartFactoryBean) fb).isPrototype()) || + !fb.isSingleton()), getAccessControlContext()); } else { @@ -1369,7 +1375,7 @@ public void clearMetadataCache() { * @throws CannotLoadBeanClassException if we failed to load the class */ @Nullable - protected Class resolveBeanClass(final RootBeanDefinition mbd, String beanName, final Class... typesToMatch) + protected Class resolveBeanClass(RootBeanDefinition mbd, String beanName, Class... typesToMatch) throws CannotLoadBeanClassException { try { @@ -1377,8 +1383,8 @@ protected Class resolveBeanClass(final RootBeanDefinition mbd, String beanNam return mbd.getBeanClass(); } if (System.getSecurityManager() != null) { - return AccessController.doPrivileged((PrivilegedExceptionAction>) () -> - doResolveBeanClass(mbd, typesToMatch), getAccessControlContext()); + return AccessController.doPrivileged((PrivilegedExceptionAction>) + () -> doResolveBeanClass(mbd, typesToMatch), getAccessControlContext()); } else { return doResolveBeanClass(mbd, typesToMatch); @@ -1634,7 +1640,7 @@ protected boolean hasBeanCreationStarted() { * Get the object for the given bean instance, either the bean * instance itself or its created object in case of a FactoryBean. * @param beanInstance the shared bean instance - * @param name name that may include factory dereference prefix + * @param name the name that may include factory dereference prefix * @param beanName the canonical bean name * @param mbd the merged bean definition * @return the object to expose for the bean diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index f29c2fb1811b..4c32655baab1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -292,12 +292,12 @@ public Comparator getDependencyComparator() { * when deciding whether a bean definition should be considered as a * candidate for autowiring. */ - public void setAutowireCandidateResolver(final AutowireCandidateResolver autowireCandidateResolver) { + public void setAutowireCandidateResolver(AutowireCandidateResolver autowireCandidateResolver) { Assert.notNull(autowireCandidateResolver, "AutowireCandidateResolver must not be null"); if (autowireCandidateResolver instanceof BeanFactoryAware) { if (System.getSecurityManager() != null) { AccessController.doPrivileged((PrivilegedAction) () -> { - ((BeanFactoryAware) autowireCandidateResolver).setBeanFactory(DefaultListableBeanFactory.this); + ((BeanFactoryAware) autowireCandidateResolver).setBeanFactory(this); return null; }, getAccessControlContext()); } @@ -503,8 +503,7 @@ private String[] doGetBeanNamesForType(ResolvableType type, boolean includeNonSi // Check all bean definitions. for (String beanName : this.beanDefinitionNames) { - // Only consider bean as eligible if the bean name - // is not defined as alias for some other bean. + // Only consider bean as eligible if the bean name is not defined as alias for some other bean. if (!isAlias(beanName)) { try { RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); @@ -601,8 +600,8 @@ public Map getBeansOfType(@Nullable Class type) throws BeansEx @Override @SuppressWarnings("unchecked") - public Map getBeansOfType(@Nullable Class type, boolean includeNonSingletons, boolean allowEagerInit) - throws BeansException { + public Map getBeansOfType( + @Nullable Class type, boolean includeNonSingletons, boolean allowEagerInit) throws BeansException { String[] beanNames = getBeanNamesForType(type, includeNonSingletons, allowEagerInit); Map result = new LinkedHashMap<>(beanNames.length); @@ -720,12 +719,13 @@ public boolean isAutowireCandidate(String beanName, DependencyDescriptor descrip * @param resolver the AutowireCandidateResolver to use for the actual resolution algorithm * @return whether the bean should be considered as autowire candidate */ - protected boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor, AutowireCandidateResolver resolver) + protected boolean isAutowireCandidate( + String beanName, DependencyDescriptor descriptor, AutowireCandidateResolver resolver) throws NoSuchBeanDefinitionException { - String beanDefinitionName = BeanFactoryUtils.transformedBeanName(beanName); - if (containsBeanDefinition(beanDefinitionName)) { - return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(beanDefinitionName), descriptor, resolver); + String bdName = BeanFactoryUtils.transformedBeanName(beanName); + if (containsBeanDefinition(bdName)) { + return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(bdName), descriptor, resolver); } else if (containsSingleton(beanName)) { return isAutowireCandidate(beanName, new RootBeanDefinition(getType(beanName)), descriptor, resolver); @@ -757,15 +757,15 @@ else if (parent instanceof ConfigurableListableBeanFactory) { protected boolean isAutowireCandidate(String beanName, RootBeanDefinition mbd, DependencyDescriptor descriptor, AutowireCandidateResolver resolver) { - String beanDefinitionName = BeanFactoryUtils.transformedBeanName(beanName); - resolveBeanClass(mbd, beanDefinitionName); + String bdName = BeanFactoryUtils.transformedBeanName(beanName); + resolveBeanClass(mbd, bdName); if (mbd.isFactoryMethodUnique && mbd.factoryMethodToIntrospect == null) { new ConstructorResolver(this).resolveFactoryMethodIfPossible(mbd); } - BeanDefinitionHolder holder = (beanName.equals(beanDefinitionName) ? + BeanDefinitionHolder holder = (beanName.equals(bdName) ? this.mergedBeanDefinitionHolders.computeIfAbsent(beanName, - key -> new BeanDefinitionHolder(mbd, beanName, getAliases(beanDefinitionName))) : - new BeanDefinitionHolder(mbd, beanName, getAliases(beanDefinitionName))); + key -> new BeanDefinitionHolder(mbd, beanName, getAliases(bdName))) : + new BeanDefinitionHolder(mbd, beanName, getAliases(bdName))); return resolver.isAutowireCandidate(holder, descriptor); } @@ -840,11 +840,11 @@ public void preInstantiateSingletons() throws BeansException { if (isFactoryBean(beanName)) { Object bean = getBean(FACTORY_BEAN_PREFIX + beanName); if (bean instanceof FactoryBean) { - final FactoryBean factory = (FactoryBean) bean; + FactoryBean factory = (FactoryBean) bean; boolean isEagerInit; if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) { - isEagerInit = AccessController.doPrivileged((PrivilegedAction) - ((SmartFactoryBean) factory)::isEagerInit, + isEagerInit = AccessController.doPrivileged( + (PrivilegedAction) ((SmartFactoryBean) factory)::isEagerInit, getAccessControlContext()); } else { @@ -866,7 +866,7 @@ public void preInstantiateSingletons() throws BeansException { for (String beanName : beanNames) { Object singletonInstance = getSingleton(beanName); if (singletonInstance instanceof SmartInitializingSingleton) { - final SmartInitializingSingleton smartSingleton = (SmartInitializingSingleton) singletonInstance; + SmartInitializingSingleton smartSingleton = (SmartInitializingSingleton) singletonInstance; if (System.getSecurityManager() != null) { AccessController.doPrivileged((PrivilegedAction) () -> { smartSingleton.afterSingletonsInstantiated(); @@ -1291,7 +1291,7 @@ public Object doResolveDependency(DependencyDescriptor descriptor, @Nullable Str private Object resolveMultipleBeans(DependencyDescriptor descriptor, @Nullable String beanName, @Nullable Set autowiredBeanNames, @Nullable TypeConverter typeConverter) { - final Class type = descriptor.getDependencyType(); + Class type = descriptor.getDependencyType(); if (descriptor instanceof StreamDependencyDescriptor) { Map matchingBeans = findAutowireCandidates(beanName, type, descriptor); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java index ce865d11305f..fc689a7aec32 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/FactoryBeanRegistrySupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 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. @@ -54,11 +54,11 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg * or {@code null} if the type cannot be determined yet */ @Nullable - protected Class getTypeForFactoryBean(final FactoryBean factoryBean) { + protected Class getTypeForFactoryBean(FactoryBean factoryBean) { try { if (System.getSecurityManager() != null) { - return AccessController.doPrivileged((PrivilegedAction>) - factoryBean::getObjectType, getAccessControlContext()); + return AccessController.doPrivileged( + (PrivilegedAction>) factoryBean::getObjectType, getAccessControlContext()); } else { return factoryBean.getObjectType(); @@ -153,9 +153,7 @@ protected Object getObjectFromFactoryBean(FactoryBean factory, String beanNam * @throws BeanCreationException if FactoryBean object creation failed * @see org.springframework.beans.factory.FactoryBean#getObject() */ - private Object doGetObjectFromFactoryBean(final FactoryBean factory, final String beanName) - throws BeanCreationException { - + private Object doGetObjectFromFactoryBean(FactoryBean factory, String beanName) throws BeanCreationException { Object object; try { if (System.getSecurityManager() != null) {