Removing the use of getRawStatusCode

This commit is contained in:
Ryan Baxter
2022-04-26 12:46:21 -04:00
parent 1cd03a05fb
commit dbb3dcaafb
4 changed files with 5 additions and 3 deletions

1
.java-version Normal file
View File

@@ -0,0 +1 @@
17

View File

@@ -503,7 +503,7 @@ public class ConfigServerConfigDataLoaderTests {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
when(response.getHeaders()).thenReturn(headers);
when(response.getRawStatusCode()).thenReturn(status.value());
when(response.getStatusCode()).thenReturn(status);
when(response.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes()));
}

View File

@@ -558,7 +558,7 @@ public class ConfigServicePropertySourceLocatorTests {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
Mockito.when(response.getHeaders()).thenReturn(headers);
Mockito.when(response.getRawStatusCode()).thenReturn(status.value());
Mockito.when(response.getStatusCode()).thenReturn(status);
Mockito.when(response.getBody()).thenReturn(new ByteArrayInputStream("{}".getBytes()));
}

View File

@@ -20,6 +20,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestOperations;
@@ -70,7 +71,7 @@ abstract class VaultKvAccessStrategySupport implements VaultKvAccessStrategy {
ResponseEntity<VaultResponse> response = this.rest.exchange(urlTemplate, HttpMethod.GET,
new HttpEntity<>(headers), VaultResponse.class, key);
HttpStatus status = response.getStatusCode();
HttpStatusCode status = response.getStatusCode();
if (status == HttpStatus.OK) {
return extractDataFromBody(response.getBody());
}