Skip to content

Commit 137fc48

Browse files
committed
Polishing
1 parent 04d5a29 commit 137fc48

File tree

7 files changed

+21
-24
lines changed

7 files changed

+21
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ private enum State {NEW, COMMITTING, COMMITTED}
5555

5656
private final MultiValueMap<String, HttpCookie> cookies;
5757

58-
private AtomicReference<State> state = new AtomicReference<>(State.NEW);
58+
private final AtomicReference<State> state = new AtomicReference<>(State.NEW);
5959

6060
private final List<Supplier<? extends Mono<Void>>> commitActions = new ArrayList<>(4);
6161

@@ -95,7 +95,7 @@ public void beforeCommit(Supplier<? extends Mono<Void>> action) {
9595

9696
@Override
9797
public boolean isCommitted() {
98-
return this.state.get() != State.NEW;
98+
return (this.state.get() != State.NEW);
9999
}
100100

101101
/**

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.http.client.reactive;
1718

1819
import java.net.URI;
@@ -37,7 +38,6 @@ public interface ClientHttpConnector {
3738
* {@code URI}, then apply the given {@code requestCallback} on the
3839
* {@link ClientHttpRequest} once the connection has been established.
3940
* <p>Return a publisher of the {@link ClientHttpResponse}.
40-
*
4141
* @param method the HTTP request method
4242
* @param uri the HTTP request URI
4343
* @param requestCallback a function that prepares and writes the request,
@@ -49,4 +49,4 @@ public interface ClientHttpConnector {
4949
Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
5050
Function<? super ClientHttpRequest, Mono<Void>> requestCallback);
5151

52-
}
52+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.http.client.reactive;
1718

1819
import java.net.URI;
@@ -42,7 +43,7 @@ public class ClientHttpRequestDecorator implements ClientHttpRequest {
4243

4344

4445
public ClientHttpRequestDecorator(ClientHttpRequest delegate) {
45-
Assert.notNull(delegate, "ClientHttpRequest delegate is required.");
46+
Assert.notNull(delegate, "Delegate is required");
4647
this.delegate = delegate;
4748
}
4849

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package org.springframework.http.client.reactive;
1718

1819
import reactor.core.publisher.Flux;
@@ -37,7 +38,7 @@ public class ClientHttpResponseDecorator implements ClientHttpResponse {
3738

3839

3940
public ClientHttpResponseDecorator(ClientHttpResponse delegate) {
40-
Assert.notNull(delegate, "ClientHttpResponse delegate is required.");
41+
Assert.notNull(delegate, "Delegate is required");
4142
this.delegate = delegate;
4243
}
4344

@@ -49,7 +50,6 @@ public ClientHttpResponse getDelegate() {
4950

5051
// ServerHttpResponse delegation methods...
5152

52-
5353
@Override
5454
public HttpStatus getStatusCode() {
5555
return this.delegate.getStatusCode();

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import java.util.function.Function;
2222

2323
import reactor.core.publisher.Mono;
24+
import reactor.ipc.netty.http.client.HttpClient;
2425
import reactor.ipc.netty.http.client.HttpClientOptions;
2526
import reactor.ipc.netty.options.ClientOptions;
26-
import reactor.ipc.netty.http.client.HttpClient;
2727

2828
import org.springframework.http.HttpMethod;
2929

3030
/**
31-
* Reactor-Netty implementation of {@link ClientHttpConnector}
31+
* Reactor-Netty implementation of {@link ClientHttpConnector}.
3232
*
3333
* @author Brian Clozel
3434
* @see HttpClient
@@ -59,7 +59,7 @@ public ReactorClientHttpConnector(Consumer<? super HttpClientOptions> clientOpti
5959
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
6060
Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
6161

62-
return httpClient
62+
return this.httpClient
6363
.request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name()),
6464
uri.toString(),
6565
httpClientRequest -> requestCallback

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,12 @@ public Mono<Void> writeWith(Publisher<? extends DataBuffer> body) {
8181

8282
@Override
8383
public Mono<Void> writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>> body) {
84-
Publisher<Publisher<ByteBuf>> byteBufs = Flux.from(body).
85-
map(ReactorClientHttpRequest::toByteBufs);
84+
Publisher<Publisher<ByteBuf>> byteBufs = Flux.from(body).map(ReactorClientHttpRequest::toByteBufs);
8685
return doCommit(() -> this.httpRequest.sendGroups(byteBufs).then());
8786
}
8887

8988
private static Publisher<ByteBuf> toByteBufs(Publisher<? extends DataBuffer> dataBuffers) {
90-
return Flux.from(dataBuffers).
91-
map(NettyDataBufferFactory::toByteBuf);
89+
return Flux.from(dataBuffers).map(NettyDataBufferFactory::toByteBuf);
9290
}
9391

9492
@Override
@@ -98,8 +96,7 @@ public Mono<Void> setComplete() {
9896

9997
@Override
10098
protected void applyHeaders() {
101-
getHeaders().entrySet()
102-
.forEach(e -> this.httpRequest.requestHeaders().set(e.getKey(), e.getValue()));
99+
getHeaders().entrySet().forEach(e -> this.httpRequest.requestHeaders().set(e.getKey(), e.getValue()));
103100
}
104101

105102
@Override
@@ -109,4 +106,4 @@ protected void applyCookies() {
109106
.forEach(this.httpRequest::addCookie);
110107
}
111108

112-
}
109+
}

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -62,8 +62,7 @@ public Flux<DataBuffer> getBody() {
6262
@Override
6363
public HttpHeaders getHeaders() {
6464
HttpHeaders headers = new HttpHeaders();
65-
this.response.responseHeaders()
66-
.entries()
65+
this.response.responseHeaders().entries()
6766
.forEach(e -> headers.add(e.getKey(), e.getValue()));
6867
return headers;
6968
}
@@ -90,12 +89,12 @@ public MultiValueMap<String, ResponseCookie> getCookies() {
9089
return CollectionUtils.unmodifiableMultiValueMap(result);
9190
}
9291

92+
9393
@Override
9494
public String toString() {
9595
return "ReactorClientHttpResponse{" +
96-
"request=" + this.response.method().name() + " " + this.response.uri() + "," +
97-
"status=" + getStatusCode() +
98-
'}';
96+
"request=[" + this.response.method().name() + " " + this.response.uri() + "]," +
97+
"status=" + getStatusCode() + '}';
9998
}
10099

101100
}

0 commit comments

Comments
 (0)