Consider Void.class a primitive wrapper in ClassUtils

Prior to this commit, ClassUtils.isPrimitiveOrWrapper() and
ClassUtils.isPrimitiveWrapper() did not return true for Void.class.
However, ClassUtils.isPrimitiveOrWrapper() did return true for
void.class. This lacking symmetry is inconsistent and can lead to bugs
in reflective code.

See: https://github.com/spring-projects/spring-data-r2dbc/issues/159

This commit addresses this by adding an entry for Void.class -> void.class
in the internal primitiveWrapperTypeMap in ClassUtils.

Closes gh-23572
This commit is contained in:
Sam Brannen
2019-09-03 13:55:56 +02:00
parent f748b1e68d
commit f37ec90f2f
4 changed files with 56 additions and 8 deletions

View File

@@ -114,7 +114,12 @@ public class ViewResolutionResultHandlerTests {
private void testSupports(MethodParameter returnType, boolean supports) {
ViewResolutionResultHandler resultHandler = resultHandler(mock(ViewResolver.class));
HandlerResult handlerResult = new HandlerResult(new Object(), null, returnType, this.bindingContext);
assertEquals(supports, resultHandler.supports(handlerResult));
if (supports) {
assertTrue("return type [" + returnType + "] should be supported", resultHandler.supports(handlerResult));
}
else {
assertFalse("return type [" + returnType + "] should not be supported", resultHandler.supports(handlerResult));
}
}
@Test