Browse Source

Reinstate Introspector.flushFromCaches() call for JDK ClassInfo cache

Closes gh-27781
pull/31496/head
Juergen Hoeller 1 year ago
parent
commit
156b3696a7
  1. 16
      spring-beans/src/main/java/org/springframework/beans/StandardBeanInfoFactory.java

16
spring-beans/src/main/java/org/springframework/beans/StandardBeanInfoFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2022 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -68,9 +68,21 @@ public class StandardBeanInfoFactory implements BeanInfoFactory, Ordered {
@Override @Override
@NonNull @NonNull
public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException { public BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException {
return (shouldIntrospectorIgnoreBeaninfoClasses ? BeanInfo beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ?
Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) : Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) :
Introspector.getBeanInfo(beanClass)); Introspector.getBeanInfo(beanClass));
// Immediately remove class from Introspector cache to allow for proper garbage
// collection on class loader shutdown; we cache it in CachedIntrospectionResults
// in a GC-friendly manner. This is necessary (again) for the JDK ClassInfo cache.
Class<?> classToFlush = beanClass;
do {
Introspector.flushFromCaches(classToFlush);
classToFlush = classToFlush.getSuperclass();
}
while (classToFlush != null && classToFlush != Object.class);
return beanInfo;
} }
@Override @Override

Loading…
Cancel
Save