Skip to content

Commit df673e6

Browse files
committed
Polish contribution
See gh-25300
1 parent 43df06b commit df673e6

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

spring-web/src/main/java/org/springframework/http/client/SimpleBufferingAsyncClientHttpRequest.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
2020
import java.net.HttpURLConnection;
2121
import java.net.URI;
2222
import java.net.URISyntaxException;
23-
import java.util.concurrent.Callable;
2423

2524
import org.springframework.core.task.AsyncListenableTaskExecutor;
2625
import org.springframework.http.HttpHeaders;
@@ -74,26 +73,26 @@ public URI getURI() {
7473

7574
@Override
7675
protected ListenableFuture<ClientHttpResponse> executeInternal(
77-
final HttpHeaders headers, final byte[] bufferedOutput) throws IOException {
76+
HttpHeaders headers, byte[] bufferedOutput) throws IOException {
7877

7978
return this.taskExecutor.submitListenable(() -> {
80-
SimpleBufferingClientHttpRequest.addHeaders(connection, headers);
79+
SimpleBufferingClientHttpRequest.addHeaders(this.connection, headers);
8180
// JDK <1.8 doesn't support getOutputStream with HTTP DELETE
8281
if (getMethod() == HttpMethod.DELETE && bufferedOutput.length == 0) {
83-
connection.setDoOutput(false);
82+
this.connection.setDoOutput(false);
8483
}
85-
if (connection.getDoOutput() && outputStreaming) {
86-
connection.setFixedLengthStreamingMode(bufferedOutput.length);
84+
if (this.connection.getDoOutput() && outputStreaming) {
85+
this.connection.setFixedLengthStreamingMode(bufferedOutput.length);
8786
}
88-
connection.connect();
89-
if (connection.getDoOutput()) {
90-
FileCopyUtils.copy(bufferedOutput, connection.getOutputStream());
87+
this.connection.connect();
88+
if (this.connection.getDoOutput()) {
89+
FileCopyUtils.copy(bufferedOutput, this.connection.getOutputStream());
9190
}
9291
else {
9392
// Immediately trigger the request in a no-output scenario as well
94-
connection.getResponseCode();
93+
this.connection.getResponseCode();
9594
}
96-
return new SimpleClientHttpResponse(connection);
95+
return new SimpleClientHttpResponse(this.connection);
9796
});
9897
}
9998

spring-web/src/main/java/org/springframework/http/client/SimpleStreamingAsyncClientHttpRequest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@
2121
import java.net.HttpURLConnection;
2222
import java.net.URI;
2323
import java.net.URISyntaxException;
24-
import java.util.concurrent.Callable;
2524

2625
import org.springframework.core.task.AsyncListenableTaskExecutor;
2726
import org.springframework.http.HttpHeaders;
@@ -102,23 +101,23 @@ protected OutputStream getBodyInternal(HttpHeaders headers) throws IOException {
102101
}
103102

104103
@Override
105-
protected ListenableFuture<ClientHttpResponse> executeInternal(final HttpHeaders headers) throws IOException {
104+
protected ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers) throws IOException {
106105
return this.taskExecutor.submitListenable(() -> {
107106
try {
108-
if (body != null) {
109-
body.close();
107+
if (this.body != null) {
108+
this.body.close();
110109
}
111110
else {
112-
SimpleBufferingClientHttpRequest.addHeaders(connection, headers);
113-
connection.connect();
111+
SimpleBufferingClientHttpRequest.addHeaders(this.connection, headers);
112+
this.connection.connect();
114113
// Immediately trigger the request in a no-output scenario as well
115-
connection.getResponseCode();
114+
this.connection.getResponseCode();
116115
}
117116
}
118117
catch (IOException ex) {
119118
// ignore
120119
}
121-
return new SimpleClientHttpResponse(connection);
120+
return new SimpleClientHttpResponse(this.connection);
122121
});
123122

124123
}

0 commit comments

Comments
 (0)