Fix removal of getLocalServiceInstance()

parent 35e2af77
......@@ -26,6 +26,7 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.actuator.HasFeatures;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClient;
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Output;
......@@ -100,10 +101,10 @@ public class HystrixStreamAutoConfiguration {
}
@Bean
public HystrixStreamTask hystrixStreamTask(SimpleDiscoveryClient simpleDiscoveryClient) {
public HystrixStreamTask hystrixStreamTask(SimpleDiscoveryProperties simpleDiscoveryProperties) {
ServiceInstance serviceInstance = this.registration;
if (serviceInstance == null) {
serviceInstance = simpleDiscoveryClient.getLocalServiceInstance();
serviceInstance = simpleDiscoveryProperties.getLocal();
}
return new HystrixStreamTask(this.outboundChannel, serviceInstance,
this.properties);
......
......@@ -23,6 +23,7 @@ import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryClient;
import org.springframework.cloud.client.discovery.simple.SimpleDiscoveryProperties;
import org.springframework.cloud.client.serviceregistry.Registration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringRunner;
......@@ -44,13 +45,13 @@ public class HystrixStreamAutoConfigurationNoRegistrationTests {
Registration registration;
@Autowired
SimpleDiscoveryClient simpleDiscoveryClient;
SimpleDiscoveryProperties simpleDiscoveryProperties;
@Test
public void withoutRegistrationWorks() throws Exception {
assertThat(this.registration).isNull();
assertThat(this.simpleDiscoveryClient).isNotNull();
assertThat(task.getRegistration()).isEqualTo(this.simpleDiscoveryClient.getLocalServiceInstance());
assertThat(this.simpleDiscoveryProperties).isNotNull();
assertThat(task.getRegistration()).isEqualTo(this.simpleDiscoveryProperties.getLocal());
}
@EnableAutoConfiguration
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment