Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Resolve multiple TODOs #3660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.BiPredicate;
import java.util.function.Supplier;

import org.apache.commons.logging.Log;
Expand All @@ -38,6 +39,8 @@ public abstract class AbstractGatewayDiscoverer {

protected volatile MultiValueMap<String, OperationMethod> operations = new LinkedMultiValueMap<>();

private final BiPredicate<Method, Class<?>> returnTypePredicate = (method, returnType) -> returnType.isAssignableFrom(method.getReturnType());

public <T extends Supplier<Collection<Method>>, R> void doDiscover(Class<T> supplierClass, Class<R> returnType) {
List<T> suppliers = loadSuppliers(supplierClass);

Expand All @@ -59,8 +62,7 @@ else if (log.isTraceEnabled()) {
}

for (Method method : methods) {
// TODO: replace with a BiPredicate of some kind
if (returnType.isAssignableFrom(method.getReturnType())) {
if (returnTypePredicate.test(method, returnType)) {
addOperationMethod(method);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ static class DelegatingServiceInstance implements ServiceInstance {

private String overrideScheme;

private static final Set<String> SECURE_SCHEMES = Set.of("https", "wss");

DelegatingServiceInstance(ServiceInstance delegate, String overrideScheme) {
this.delegate = delegate;
this.overrideScheme = overrideScheme;
Expand All @@ -169,8 +171,7 @@ public int getPort() {

@Override
public boolean isSecure() {
// TODO: move to map
if ("https".equals(this.overrideScheme) || "wss".equals(this.overrideScheme)) {
if (SECURE_SCHEMES.contains(this.overrideScheme)) {
return true;
}
return delegate.isSecure();
Expand Down