Use ReflectionUtils.makeAccessible() - not direct
The `LambdaMessageProcessor` and `MethodInvokingMessageSource` call `method.setAccessible(true)` unconditionally. * Use `ReflectionUtils.makeAccessible()` for some optimization * Remove `Content is not allowed in prolog` from the `JaxbMarshallingIntegrationTests` since it is locale dependant and not relevant for the unit test logic
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -80,7 +80,7 @@ public class MethodInvokingMessageSource extends AbstractMessageSource<Object> i
|
||||
}
|
||||
Assert.isTrue(!void.class.equals(this.method.getReturnType()),
|
||||
"invalid MessageSource method '" + this.method.getName() + "', a non-void return is required");
|
||||
this.method.setAccessible(true);
|
||||
ReflectionUtils.makeAccessible(this.method);
|
||||
this.initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class LambdaMessageProcessor implements MessageProcessor<Object>, BeanFac
|
||||
"classes with single method - functional interface implementations.");
|
||||
|
||||
this.method = methods.iterator().next();
|
||||
this.method.setAccessible(true);
|
||||
ReflectionUtils.makeAccessible(this.method);
|
||||
this.parameterTypes = this.method.getParameterTypes();
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -97,8 +97,7 @@ public class JaxbMarshallingIntegrationTests {
|
||||
Files.write(tempFile, "junk".getBytes());
|
||||
assertThatExceptionOfType(MessageTransformationException.class)
|
||||
.isThrownBy(() -> this.unmarshallIn.send(new GenericMessage<>(tempFile.toFile())))
|
||||
.withCauseInstanceOf(UnmarshallingFailureException.class)
|
||||
.withStackTraceContaining("Content is not allowed in prolog.");
|
||||
.withCauseInstanceOf(UnmarshallingFailureException.class);
|
||||
|
||||
Files.delete(tempFile);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user