Fix FunctionTypeUtils as well as LocalServerPort issue

Resolves #871
This commit is contained in:
Oleg Zhurakousky
2022-06-07 16:01:50 +02:00
parent 66b88f2f1e
commit 724ba06c11
13 changed files with 19 additions and 14 deletions

View File

@@ -417,10 +417,15 @@ public final class FunctionTypeUtils {
type = getImmediateGenericType(type, 0); type = getImmediateGenericType(type, 0);
} }
if (type instanceof ParameterizedType && !Message.class.isAssignableFrom(TypeResolver.resolveRawClass(type, null))) { Class<?> resolveRawClass = FunctionTypeUtils.getRawType(type);
if (type instanceof ParameterizedType && !Message.class.isAssignableFrom(resolveRawClass)) {
type = getImmediateGenericType(type, 0); type = getImmediateGenericType(type, 0);
} }
return Message.class.isAssignableFrom(TypeResolver.resolveRawClass(type, null)); resolveRawClass = FunctionTypeUtils.getRawType(type);
if (resolveRawClass == null) {
return false;
}
return Message.class.isAssignableFrom(resolveRawClass);
} }
/** /**

View File

@@ -102,7 +102,7 @@ public class SimpleFunctionRegistryTests {
public void concurrencyRegistrationTest() throws Exception { public void concurrencyRegistrationTest() throws Exception {
Echo function = new Echo(); Echo function = new Echo();
FunctionRegistration<Echo> registration = new FunctionRegistration<>( FunctionRegistration<Echo> registration = new FunctionRegistration<>(
function, "echo").type(FunctionType.of(Echo.class)); function, "echo").type(Echo.class);
SimpleFunctionRegistry catalog = new SimpleFunctionRegistry(this.conversionService, this.messageConverter, SimpleFunctionRegistry catalog = new SimpleFunctionRegistry(this.conversionService, this.messageConverter,
new JacksonMapper(new ObjectMapper())); new JacksonMapper(new ObjectMapper()));
ExecutorService executor = Executors.newCachedThreadPool(); ExecutorService executor = Executors.newCachedThreadPool();

View File

@@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;

View File

@@ -36,7 +36,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.flux.FluxRestApplicationTests.TestConfiguration; import org.springframework.cloud.function.flux.FluxRestApplicationTests.TestConfiguration;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@@ -35,7 +35,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.mvc.MvcRestApplicationTests.TestConfiguration; import org.springframework.cloud.function.mvc.MvcRestApplicationTests.TestConfiguration;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;

View File

@@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;

View File

@@ -38,7 +38,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.flux.HttpGetIntegrationTests.ApplicationConfiguration; import org.springframework.cloud.function.web.flux.HttpGetIntegrationTests.ApplicationConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@@ -40,7 +40,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.flux.HttpPostIntegrationTests.ApplicationConfiguration; import org.springframework.cloud.function.web.flux.HttpPostIntegrationTests.ApplicationConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@@ -27,7 +27,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.flux.PrefixTests.TestConfiguration; import org.springframework.cloud.function.web.flux.PrefixTests.TestConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@@ -32,7 +32,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.flux.SingletonTests.TestConfiguration; import org.springframework.cloud.function.web.flux.SingletonTests.TestConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@@ -28,7 +28,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.mvc.DefaultRouteTests.TestConfiguration; import org.springframework.cloud.function.web.mvc.DefaultRouteTests.TestConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@@ -39,7 +39,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.mvc.HttpGetIntegrationTests.ApplicationConfiguration; import org.springframework.cloud.function.web.mvc.HttpGetIntegrationTests.ApplicationConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@@ -40,7 +40,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.cloud.function.web.RestApplication; import org.springframework.cloud.function.web.RestApplication;
import org.springframework.cloud.function.web.mvc.HttpPostIntegrationTests.ApplicationConfiguration; import org.springframework.cloud.function.web.mvc.HttpPostIntegrationTests.ApplicationConfiguration;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;