General code cleanup
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 the original author or authors.
|
||||
* Copyright 2019-2022 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.
|
||||
@@ -548,19 +548,4 @@ public final class FunctionTypeUtils {
|
||||
}
|
||||
return functionDefinition;
|
||||
}
|
||||
|
||||
private static boolean isFunctional(Type type) {
|
||||
if (type instanceof ParameterizedType) {
|
||||
type = ((ParameterizedType) type).getRawType();
|
||||
Assert.isTrue(type instanceof Class<?>, "Must be one of Supplier, Function, Consumer"
|
||||
+ " or FunctionRegistration. Was " + type);
|
||||
}
|
||||
|
||||
Class<?> candidateType = (Class<?>) type;
|
||||
return Supplier.class.isAssignableFrom(candidateType)
|
||||
|| Function.class.isAssignableFrom(candidateType)
|
||||
|| Consumer.class.isAssignableFrom(candidateType)
|
||||
|| BiFunction.class.isAssignableFrom(candidateType)
|
||||
|| BiConsumer.class.isAssignableFrom(candidateType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +445,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry {
|
||||
this.propagateInputHeaders = function.propagateInputHeaders;
|
||||
this.composed = function.composed;
|
||||
this.inputType = function.inputType;
|
||||
this.composed = function.composed;
|
||||
this.outputType = function.outputType;
|
||||
this.functionDefinition = function.functionDefinition;
|
||||
this.message = this.inputType != null && FunctionTypeUtils.isMessage(this.inputType);
|
||||
@@ -1134,6 +1135,7 @@ public class SimpleFunctionRegistry implements FunctionRegistry {
|
||||
* This is an optional conversion which would only happen if `expected-content-type` is
|
||||
* set as a header in a message or explicitly provided as part of the lookup.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Object convertOutputIfNecessary(Object output, Type type, String[] contentType) {
|
||||
if (output instanceof Message && ((Message) output).getPayload() instanceof byte[]) {
|
||||
return output;
|
||||
|
||||
@@ -16,12 +16,9 @@
|
||||
|
||||
package org.springframework.cloud.function.context.config;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -113,30 +110,8 @@ public abstract class FunctionContextUtils {
|
||||
|
||||
private static Method[] getCandidateMethods(final Class<?> factoryClass,
|
||||
final RootBeanDefinition mbd) {
|
||||
if (System.getSecurityManager() != null) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
|
||||
@Override
|
||||
public Method[] run() {
|
||||
return (mbd.isNonPublicAccessAllowed()
|
||||
? ReflectionUtils.getAllDeclaredMethods(factoryClass)
|
||||
: factoryClass.getMethods());
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
return (mbd.isNonPublicAccessAllowed()
|
||||
? ReflectionUtils.getAllDeclaredMethods(factoryClass)
|
||||
: factoryClass.getMethods());
|
||||
}
|
||||
return (mbd.isNonPublicAccessAllowed()
|
||||
? ReflectionUtils.getAllDeclaredMethods(factoryClass)
|
||||
: factoryClass.getMethods());
|
||||
}
|
||||
|
||||
private static Object getField(Object target, String name) {
|
||||
Field field = ReflectionUtils.findField(target.getClass(), name);
|
||||
if (field == null) {
|
||||
return null;
|
||||
}
|
||||
ReflectionUtils.makeAccessible(field);
|
||||
return ReflectionUtils.getField(field, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user