Browse Source

Avoid field autowiring in SimpleDiscoveryClientAutoConfiguration (#786)

In order to fix GraalVM compatibility
pull/803/head
Sébastien Deleuze 4 years ago committed by Marcin Grzejszczak
parent
commit
63ce0d965c
  1. 20
      spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientAutoConfiguration.java

20
spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientAutoConfiguration.java

@ -44,23 +44,29 @@ import org.springframework.core.annotation.Order;
public class SimpleDiscoveryClientAutoConfiguration public class SimpleDiscoveryClientAutoConfiguration
implements ApplicationListener<WebServerInitializedEvent> { implements ApplicationListener<WebServerInitializedEvent> {
@Autowired(required = false)
private ServerProperties server; private ServerProperties server;
@Value("${spring.application.name:application}")
private String serviceId;
@Autowired
private InetUtils inet; private InetUtils inet;
private int port = 0; private int port = 0;
private SimpleDiscoveryProperties simple = new SimpleDiscoveryProperties(); private SimpleDiscoveryProperties simple = new SimpleDiscoveryProperties();
@Autowired(required = false)
public void setServer(ServerProperties server) {
this.server = server;
}
@Autowired
public void setInet(InetUtils inet) {
this.inet = inet;
}
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public SimpleDiscoveryProperties simpleDiscoveryProperties() { public SimpleDiscoveryProperties simpleDiscoveryProperties(
simple.getLocal().setServiceId(this.serviceId); @Value("${spring.application.name:application}") String serviceId) {
simple.getLocal().setServiceId(serviceId);
simple.getLocal() simple.getLocal()
.setUri(URI.create( .setUri(URI.create(
"http://" + this.inet.findFirstNonLoopbackHostInfo().getHostname() "http://" + this.inet.findFirstNonLoopbackHostInfo().getHostname()

Loading…
Cancel
Save