Skip to content

Commit 6c40236

Browse files
committed
Update deprecated code to recommended strategy
This is part one of an epic to replace deprecated method calls with the recommended solution. Signed-off-by: Glenn Renfro <[email protected]>
1 parent 163963a commit 6c40236

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

spring-cloud-common-security-config/spring-cloud-common-security-config-web/src/main/java/org/springframework/cloud/common/security/ManualOAuthAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.springframework.security.oauth2.core.AuthorizationGrantType;
3333
import org.springframework.security.oauth2.core.OAuth2AuthorizationException;
3434
import org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse;
35-
import org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken;
35+
import org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthenticationToken;
3636
import org.springframework.security.oauth2.server.resource.authentication.OpaqueTokenAuthenticationProvider;
3737
import org.springframework.security.oauth2.server.resource.introspection.OpaqueTokenIntrospector;
3838
import org.springframework.web.client.ResourceAccessException;

spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/DefaultDockerCompose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ private Optional<String> id(String containerName) throws IOException, Interrupte
225225
}
226226

227227
private Process followLogs(String container) throws IOException, InterruptedException {
228-
if (version().greaterThanOrEqualTo(VERSION_1_7_0)) {
228+
if (version().isHigherThanOrEquivalentTo(VERSION_1_7_0)) {
229229
return rawExecutable.execute(true, "logs", "--no-color", "--follow", container);
230230
}
231231

spring-cloud-dataflow-common/spring-cloud-dataflow-common-test-docker/src/main/java/org/springframework/cloud/dataflow/common/test/docker/compose/execution/Docker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Version configuredVersion() throws IOException, InterruptedException {
5252
String versionString = command.execute(Command.throwingOnError(), false, "-v");
5353
Matcher matcher = VERSION_PATTERN.matcher(versionString);
5454
Assert.state(matcher.matches(), "Unexpected output of docker -v: " + versionString);
55-
return Version.forIntegers(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)),
55+
return Version.of(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)),
5656
Integer.parseInt(matcher.group(3)));
5757
}
5858

spring-cloud-dataflow-composed-task-runner/src/main/java/org/springframework/cloud/dataflow/composedtaskrunner/ComposedTaskRunnerTaskListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
55

6-
import org.springframework.cloud.task.listener.TaskExecutionListenerSupport;
6+
import org.springframework.cloud.task.listener.TaskExecutionListener;
77
import org.springframework.cloud.task.repository.TaskExecution;
88

9-
public class ComposedTaskRunnerTaskListener extends TaskExecutionListenerSupport {
9+
public class ComposedTaskRunnerTaskListener implements TaskExecutionListener {
1010
private final static Logger logger = LoggerFactory.getLogger(ComposedTaskRunnerTaskListener.class);
1111

1212
private static Long executionId = null;

spring-cloud-dataflow-container-registry/src/main/java/org/springframework/cloud/dataflow/container/registry/authorization/DockerConfigJsonSecretToRegistryConfigurationConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public Optional<String> getDockerTokenServiceUri(String registryHost, boolean di
193193
return Optional.empty();
194194
} catch (HttpClientErrorException httpError) {
195195

196-
if (httpError.getRawStatusCode() != 401) {
196+
if (httpError.getStatusCode().value() != 401) {
197197
return Optional.empty();
198198
}
199199
if (httpError.getResponseHeaders() == null

spring-cloud-dataflow-rest-resource/src/test/java/org/springframework/cloud/dataflow/rest/resource/HttpClientTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.hc.client5.http.classic.methods.HttpGet;
2323
import org.apache.hc.core5.http.HttpHeaders;
24+
import org.apache.hc.core5.http.io.HttpClientResponseHandler;
2425
import org.junit.jupiter.api.Test;
2526

2627
import org.springframework.boot.SpringBootConfiguration;
@@ -61,14 +62,12 @@ void resourceBasedAuthorizationHeader() throws Exception {
6162
throw new Passed();
6263
})
6364
.buildHttpClient()) {
64-
assertThatExceptionOfType(Passed.class).isThrownBy(() -> client.execute(new HttpGet(targetHost)));
65+
assertThatExceptionOfType(Passed.class).isThrownBy(() -> client.execute(new HttpGet(targetHost), getNoOpResponseHandler()));
6566
}
6667
}
6768

68-
static final class TestException extends IOException {
69-
TestException() {
70-
super("It broke");
71-
}
69+
private HttpClientResponseHandler<String> getNoOpResponseHandler() {
70+
return response -> "noOp";
7271
}
7372

7473
static final class ByteArrayCheckableResource extends ByteArrayResource implements CheckableResource {

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/TaskSchedulerController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
3535
import org.springframework.http.HttpStatus;
3636
import org.springframework.util.Assert;
37-
import org.springframework.util.StringUtils;
3837
import org.springframework.web.bind.annotation.DeleteMapping;
3938
import org.springframework.web.bind.annotation.GetMapping;
4039
import org.springframework.web.bind.annotation.PathVariable;
@@ -168,7 +167,7 @@ public void save(
168167
) {
169168
Map<String, String> propertiesToUse = DeploymentPropertiesUtils.parse(properties);
170169
List<String> argumentsToUse = DeploymentPropertiesUtils.parseArgumentList(arguments, " ");
171-
this.schedulerService.schedule(StringUtils.trimWhitespace(scheduleName), taskDefinitionName,
170+
this.schedulerService.schedule(scheduleName.strip(), taskDefinitionName,
172171
propertiesToUse, argumentsToUse, platform);
173172
}
174173

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/config/H2ServerConfigurationTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,21 @@ void serverDoesNotStartWhenUrlIsH2ButInvalidForm() {
9393
"spring.datasource.url=jdbc:h2:tcp://localhost:-1/mem:dataflow;DATABASE_TO_UPPER=FALSE",
9494
"spring.dataflow.embedded.database.enabled=true")
9595
.run(context -> assertThat(context)
96-
.getFailure().getRootCause().isInstanceOf(IllegalArgumentException.class)
96+
.getFailure().rootCause().isInstanceOf(IllegalArgumentException.class)
9797
.hasMessageMatching("DataSource URL .* does not match regex pattern: .*"));
9898

9999
runner.withPropertyValues(
100100
"spring.datasource.url=jdbc:h2:tcp://localhost:port/mem:dataflow;DATABASE_TO_UPPER=FALSE",
101101
"spring.dataflow.embedded.database.enabled=true")
102102
.run(context -> assertThat(context)
103-
.getFailure().getRootCause().isInstanceOf(IllegalArgumentException.class)
103+
.getFailure().rootCause().isInstanceOf(IllegalArgumentException.class)
104104
.hasMessageMatching("DataSource URL .* does not match regex pattern: .*"));
105105

106106
runner.withPropertyValues(
107107
"spring.datasource.url=jdbc:h2:tcp://localhost:99999/mem:dataflow;DATABASE_TO_UPPER=FALSE",
108108
"spring.dataflow.embedded.database.enabled=true")
109109
.run(context -> assertThat(context)
110-
.getFailure().getRootCause().isInstanceOf(IllegalArgumentException.class)
110+
.getFailure().rootCause().isInstanceOf(IllegalArgumentException.class)
111111
.hasMessage("Port value out of range: 99999"));
112112
}
113113

spring-cloud-dataflow-test/src/main/java/org/springframework/cloud/dataflow/data/CSVLoader.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ public interface DeriveType {
4242
}
4343

4444
public static int loadCSV(String tableName, DataSource dataSource, Resource cvsResource, DeriveType deriveType) throws IOException {
45-
CSVParser parser = CSVFormat.RFC4180.withFirstRecordAsHeader()
45+
CSVParser parser = CSVFormat.RFC4180.builder()
46+
.setHeader()
47+
.setSkipHeaderRecord(true)
48+
.build()
4649
.parse(new InputStreamReader(cvsResource.getInputStream()));
4750
List<String> headerNames = parser.getHeaderNames();
4851
final List<CSVRecord> records = parser.getRecords();

0 commit comments

Comments
 (0)