Clear descriptor caches when bean introspectors change - #435
Conversation
garydgregory
left a comment
There was a problem hiding this comment.
Hello @rootvector2
Thank you for the PR.
What do you think about adding tests that cover the following patterns:
resetBeanIntrospectors()cache invalidation. The method now callsclearDescriptorCaches(), but there is no dedicated test that warms a cache, callsresetBeanIntrospectors(),and checks that a previously suppressed or modified property is re-evaluated.- Invalidation of the mappedDescriptorsCache path specifically. The existing
testCustomIntrospectionSuppressedMappedProperty*tests exercise suppression of mapped properties, but they add the introspector before the first access. A test that warms a mapped descriptor, then adds and/or removes an introspector and checks the mapped descriptor is re-created would close the gap. - Multiple sequential adds/removes.
|
makes sense, added all three in 85eda71: |
|
@rootvector2 Please rebase on git master to pick up a fix to the tests. |
the per-class descriptorsCache is populated once and was never invalidated when addBeanIntrospector, removeBeanIntrospector or resetBeanIntrospectors changed the introspector set, so a SuppressPropertiesBeanIntrospector registered after a class was introspected had no effect.
cover resetBeanIntrospectors() re-evaluating a warmed cache, the mappedDescriptorsCache entry being re-created rather than served stale, and multiple sequential adds/removes each taking effect. all three fail without the cache invalidation in PropertyUtilsBean.
85eda71 to
796fe9e
Compare
|
rebased on master, full |
addBeanIntrospector,removeBeanIntrospectorandresetBeanIntrospectorsmutate theintrospectorslist but never invalidatedescriptorsCache, whichgetIntrospectionDatafills once per bean class, so registering aSuppressPropertiesBeanIntrospector(the documented BEANUTILS-463 hardening) after a class has already been introspected is a no-op:getPropertyDescriptorreturns the stale cached descriptor at its early return before it reaches theisPropertySuppressedguard, and the suppressed property stays readable and writable viapopulate/getProperty/setProperty. found while auditing the suppression path from #413/#431, whose own tests callclearDescriptors()right beforeaddBeanIntrospectorto work around this. clearing the descriptor caches when the introspector set changes makes the change take effect for already-cached classes; i did not reuseclearDescriptors()because it also flushes the JVM-globalIntrospectorcache.mvn; that'smvnon the command line by itself.