fix:fix feign report -1 port bug.

pull/1110/head
Haotian Zhang 1 year ago
parent de1b2d53fb
commit 18c285bb25

@ -23,3 +23,4 @@
- fix:fix web server wrong open bug.
- fix:add deregister judgment.
- feat:added ribbon lb polaris weighted round robin rule.
- fix:fix feign report -1 port bug.

@ -47,7 +47,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = DEFINED_PORT,
classes = EncodeTransferMedataFeignInterceptorTest.TestApplication.class,
properties = {"server.port=8081",
properties = {"server.port=18081",
"spring.config.location = classpath:application-test.yml",
"spring.main.web-application-type = servlet",
"spring.cloud.gateway.enabled = false"})
@ -77,7 +77,7 @@ public class EncodeTransferMedataFeignInterceptorTest {
return MetadataContextHolder.get().getContext(MetadataContext.FRAGMENT_TRANSITIVE, "b");
}
@FeignClient(name = "test-feign", url = "http://localhost:8081")
@FeignClient(name = "test-feign", url = "http://localhost:18081")
public interface TestFeign {
@RequestMapping("/test")

@ -71,7 +71,13 @@ public class EnhancedFeignClient implements Client {
enhancedPluginContext.setLocalServiceInstance(pluginRunner.getLocalServiceInstance());
DefaultServiceInstance serviceInstance = new DefaultServiceInstance(request.requestTemplate().feignTarget()
.name(), url.getHost(), url.getPort(), url.getScheme().equals("https"));
enhancedPluginContext.setTargetServiceInstance(serviceInstance, url);
// -1 means access directly by url
if (serviceInstance.getPort() == -1) {
enhancedPluginContext.setTargetServiceInstance(null, url);
}
else {
enhancedPluginContext.setTargetServiceInstance(serviceInstance, url);
}
// Run pre enhanced plugins.
pluginRunner.run(EnhancedPluginType.Client.PRE, enhancedPluginContext);

Loading…
Cancel
Save