Repository navigation
Suppress class and declaringClass pseudo-properties in BeanMap (1.X) - #447
Open
rootvector2 wants to merge 1 commit into
Open
rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
Port of apache#412. BeanMap.initialise registered every descriptor returned by Introspector.getBeanInfo, so the class pseudo-property (and declaringClass on enums) stayed reachable through the map even though PropertyUtilsBean suppresses both names by default. PropertyUtilsBean resolves Map beans with Map.get, so wrapping a bean in a BeanMap re-opened the class.classLoader path. Skip both names, as on master, and drop the class entry from the index-aligned BeanMapTest sample arrays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of #412 to the
1.Xbranch.BeanMap.initialisebuilds its entries straight fromIntrospector.getBeanInfo, so every bean gets aclassentry (and every enum adeclaringClassentry), althoughPropertyUtilsBeanon1.Xdrops both names by default throughSUPPRESS_CLASSandSUPPRESS_DECLARING_CLASS.PropertyUtilsBeanresolves aMapbean withMap.get, so wrapping a bean in aBeanMapre-opens theclass.classLoaderpath those suppressions close:PropertyUtils.getProperty(form, "class")throwsNoSuchMethodException, butPropertyUtils.getProperty(new BeanMap(form), "class.classLoader")returns the application class loader.BeanUtils.populate(new BeanMap(form), Collections.singletonMap("class.classLoader.defaultAssertionStatus", "true"))callssetDefaultAssertionStatus(true)on that loader (Form.class.desiredAssertionStatus()goes fromfalsetotrue).The runtime change and
testClassPropertyNotExposedare the same as on master. Theclassentry is removed from the index-alignedgetSampleKeys(),getSampleValues()andgetNewSampleValues()arrays that pinned the old behavior.BeanMapTestfails on unmodified1.Xand passes with the change. With the patch, the read above throwsNestedNullExceptionandpopulateleaves the loader untouched. Found while checking which master fixes are still missing on1.X.Same caveat as #417, #419 and #428: the default
mvngoal on my machine fails onlyLocaleBeanificationTest.testContextClassloaderIndependence, which fails the same way on unmodified1.X(1291 tests before, 1292 after, same single failure). With that failure ignored,apache-rat:check,japicmp:cmp,javadoc:javadocandcheckstyle:check(0 violations) pass.mvn; that'smvnon the command line by itself.