Add casting check for create() provider
This commit is contained in:
parent
8aa81dc255
commit
f8eafb457a
1 changed files with 8 additions and 1 deletions
|
|
@ -187,9 +187,16 @@ class AwsCredentialsProviderPropertyValueDecoder implements IPropertyValueDecode
|
||||||
return constructor.construct();
|
return constructor.construct();
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
try {
|
try {
|
||||||
|
// Try to create an instance using .create()
|
||||||
Method createMethod = clazz.getDeclaredMethod("create");
|
Method createMethod = clazz.getDeclaredMethod("create");
|
||||||
if (Modifier.isStatic(createMethod.getModifiers())) {
|
if (Modifier.isStatic(createMethod.getModifiers())) {
|
||||||
return (T) createMethod.invoke(null);
|
Object provider = createMethod.invoke(null);
|
||||||
|
if (provider instanceof AwsCredentialsProvider) {
|
||||||
|
return (T) provider;
|
||||||
|
} else {
|
||||||
|
log.warn("Returned provider is not an instance of {}", AwsCredentialsProvider.class.getName());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Found non-static create() method in {}", providerName);
|
log.warn("Found non-static create() method in {}", providerName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue