Avoid leaking data via Exception message.

Do not include the result value in the exception message to avoid data exposure.
Improve data flow to avoid superfluous null checks.

See #2290.
Original Pull Request: #2291.
This commit is contained in:
Christoph Strobl
2021-02-09 10:28:23 +01:00
parent cdeecd4a75
commit e3a8edf581
2 changed files with 14 additions and 29 deletions

View File

@@ -43,6 +43,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
* @author Oliver Gierke
* @author Saulo Medeiros de Araujo
* @author Mark Paluch
* @author Christoph Strobl
*/
@ExtendWith(MockitoExtension.class)
class ProjectingMethodInterceptorUnitTests {
@@ -96,7 +97,7 @@ class ProjectingMethodInterceptorUnitTests {
verify(factory, times(0)).createProjection((Class<?>) any(), any());
}
@Test // #2290
@Test // GH-2290
void failsForNonConvertibleTypes() throws Throwable {
MethodInterceptor methodInterceptor = new ProjectingMethodInterceptor(factory, interceptor, conversionService);
@@ -106,7 +107,6 @@ class ProjectingMethodInterceptorUnitTests {
assertThatThrownBy(() -> methodInterceptor.invoke(invocation)) //
.isInstanceOf(UnsupportedOperationException.class) //
.hasMessageContaining("'1'") //
.hasMessageContaining("BigInteger") //
.hasMessageContaining("boolean");
}