Skip to content

Commit

Permalink
Clean up eureka-client deprecations (#4261)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZIRAKrezovic authored Mar 26, 2024
1 parent 817ea2c commit 4536954
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.springframework.cloud.config.client.ConfigServicePropertySourceLocator;
import org.springframework.cloud.configuration.TlsProperties;
import org.springframework.cloud.netflix.eureka.EurekaClientConfigBean;
import org.springframework.cloud.netflix.eureka.RestTemplateTimeoutProperties;
import org.springframework.cloud.netflix.eureka.http.DefaultEurekaClientHttpRequestFactorySupplier;
import org.springframework.cloud.netflix.eureka.http.EurekaClientHttpRequestFactorySupplier;
import org.springframework.cloud.netflix.eureka.http.RestTemplateEurekaHttpClient;
Expand All @@ -55,7 +56,7 @@
@ConditionalOnClass(ConfigServicePropertySourceLocator.class)
@Conditional(EurekaConfigServerBootstrapConfiguration.EurekaConfigServerBootstrapCondition.class)
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties
@EnableConfigurationProperties(RestTemplateTimeoutProperties.class)
public class EurekaConfigServerBootstrapConfiguration {

@Bean
Expand All @@ -78,8 +79,9 @@ public RestTemplateEurekaHttpClient configDiscoveryRestTemplateEurekaHttpClient(

@Bean
@ConditionalOnMissingBean
EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier() {
return new DefaultEurekaClientHttpRequestFactorySupplier();
EurekaClientHttpRequestFactorySupplier defaultEurekaClientHttpRequestFactorySupplier(
RestTemplateTimeoutProperties restTemplateTimeoutProperties) {
return new DefaultEurekaClientHttpRequestFactorySupplier(restTemplateTimeoutProperties);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,6 @@ public HttpStatusCode getStatusCode() throws IOException {
return response.getStatusCode();
}

@Override
public int getRawStatusCode() throws IOException {
return response.getRawStatusCode();
}

@Override
public String getStatusText() throws IOException {
return response.getStatusText();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2022 the original author or authors.
* Copyright 2013-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,11 +26,12 @@
import org.springframework.cloud.netflix.eureka.http.WebClientEurekaHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.function.client.ClientResponse;
import org.springframework.web.reactive.function.client.WebClient;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -53,10 +54,12 @@ class EurekaConfigServerBootstrapConfigurationWebClientIntegrationTests {
@Test
void webClientRespectsCodecProperties() {
WebClient webClient = eurekaHttpClient.getWebClient();
ClientResponse response = webClient.get().uri("http://localhost:" + port).exchange().block();
ResponseEntity<String> response = webClient.get().uri("http://localhost:" + port).retrieve()
.toEntity(String.class).block();

assertThat(response).isNotNull();
assertThat(response.statusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.bodyToMono(String.class).block()).startsWith("....").hasSize(300000);
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(response.getBody()).startsWith("....").hasSize(300000);
}

@SpringBootConfiguration
Expand All @@ -71,8 +74,8 @@ public String hello() {

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http.authorizeHttpRequests().anyRequest().permitAll().and().csrf().disable();
return http.build();
return http.authorizeHttpRequests(auth -> auth.anyRequest().permitAll())
.csrf(AbstractHttpConfigurer::disable).build();
}

}
Expand Down

0 comments on commit 4536954

Please sign in to comment.