Skip to content

Commit

Permalink
Reinstate Introspector.flushFromCaches() call for JDK ClassInfo cache
Browse files Browse the repository at this point in the history
Closes gh-27781
  • Loading branch information
jhoeller committed Aug 7, 2023
1 parent 9d71549 commit fc085e8
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -248,9 +248,22 @@ private static BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionExce
return beanInfo;
}
}
return (shouldIntrospectorIgnoreBeaninfoClasses ?

BeanInfo beanInfo = (shouldIntrospectorIgnoreBeaninfoClasses ?
Introspector.getBeanInfo(beanClass, Introspector.IGNORE_ALL_BEANINFO) :
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;
}


Expand Down

1 comment on commit fc085e8

@jdomigon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! I've traced this commit to a performance problem we're having in our automated tests.

As I've seen, this code has been deleted or seems not necessary any more in modern 6.x branches.

¿Is it necessary that it stays in 5.3.x branch?

Please sign in to comment.