garydgregory commented on code in PR #412:
URL: https://github.com/apache/commons-beanutils/pull/412#discussion_r3562786461
##########
src/test/java/org/apache/commons/beanutils2/BeanMapTest.java:
##########
@@ -188,21 +190,20 @@ public Object[] getNewSampleValues() {
// To:
// "some\2Value",
//
- // Then, I manually added the "class" key, which is a property that exists
for
- // all beans (and all objects for that matter.
+ // The "class" pseudo-property is intentionally absent: it is suppressed
so the bean's
+ // ClassLoader is not reachable through the map.
@Override
public String[] getSampleKeys() {
final String[] keys = { "someIntValue", "someLongValue",
"someDoubleValue", "someFloatValue", "someShortValue", "someByteValue",
"someCharValue",
- "someIntegerValue", "someStringValue", "someObjectValue",
"class", };
+ "someIntegerValue", "someStringValue", "someObjectValue", };
return keys;
}
// note to self: the sample values were created manually
@Override
public Object[] getSampleValues() {
final Object[] values = { Integer.valueOf(1234),
Long.valueOf(1298341928234L), Double.valueOf(123423.34),
Float.valueOf(1213332.12f),
- Short.valueOf((short) 134), Byte.valueOf((byte) 10),
Character.valueOf('a'), Integer.valueOf(1432), "SomeStringValue",
objectInFullMap,
- BeanWithProperties.class, };
Review Comment:
Why was `BeanWithProperties` removed here?
##########
src/test/java/org/apache/commons/beanutils2/BeanMapTest.java:
##########
@@ -283,6 +284,23 @@ void testBeanMapClone() {
}
}
+ /**
+ * The {@code class} and (for enums) {@code declaringClass}
pseudo-properties expose the bean's {@link ClassLoader} and must not be
reachable through the map,
+ * matching the suppression {@link PropertyUtilsBean} applies by default.
+ */
+ @Test
+ void testClassPropertyNotExposed() {
+ final BeanMap map = new BeanMap(new BeanWithProperties());
+ assertFalse(map.containsKey("class"), "class must not be exposed as a
property");
+ assertNull(map.get("class"));
+ assertNull(map.getReadMethod("class"));
+
+ final BeanMap enumMap = new BeanMap(java.time.DayOfWeek.MONDAY);
Review Comment:
Don't use a fully-qualified class name here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]