Skip to content

Commit 3138c0c

Browse files
committed
fix batch 5
1 parent 5e089c3 commit 3138c0c

File tree

10 files changed

+22
-31
lines changed

10 files changed

+22
-31
lines changed

src/main/java/io/vertx/httpproxy/HttpProxy.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import io.vertx.codegen.annotations.VertxGen;
1616
import io.vertx.core.Future;
1717
import io.vertx.core.Handler;
18-
import io.vertx.core.Vertx;
1918
import io.vertx.core.http.HttpClient;
2019
import io.vertx.core.http.HttpClientRequest;
2120
import io.vertx.core.http.HttpServerRequest;

src/main/java/io/vertx/httpproxy/ProxyContext.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public interface ProxyContext {
3535
boolean isWebSocket();
3636

3737
/**
38-
* Attach a payload to the context
38+
* Attach a payload to the context.
3939
*
4040
* @param name the payload name
4141
* @param value any payload value
4242
*/
4343
void set(String name, Object value);
4444

4545
/**
46-
* Get a payload attached to this context
46+
* Get a payload attached to this context.
4747
*
4848
* @param name the payload name
4949
* @param type the expected payload type

src/main/java/io/vertx/httpproxy/ProxyInterceptor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ default Future<Void> handleProxyResponse(ProxyContext context) {
3232
/**
3333
* Used to set whether to apply the interceptor to the WebSocket
3434
* handshake packet. The default value is false.
35+
*
3536
* @return the boolean value
3637
*/
3738
default boolean allowApplyToWebSocket() {

src/main/java/io/vertx/httpproxy/ProxyRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static ProxyRequest reverseProxy(HttpServerRequest proxiedRequest) {
101101
ProxyRequest setBody(Body body);
102102

103103
/**
104-
* Set the request authority
104+
* Set the request authority.
105105
*
106106
* <ul>
107107
* <li>for HTTP/1 the {@literal Host} header</li>
@@ -128,7 +128,7 @@ static ProxyRequest reverseProxy(HttpServerRequest proxiedRequest) {
128128
MultiMap headers();
129129

130130
/**
131-
* Put an HTTP header
131+
* Put an HTTP header.
132132
*
133133
* @param name The header name
134134
* @param value The header value
@@ -157,7 +157,7 @@ default Future<Void> proxy(HttpClientRequest request) {
157157
Future<ProxyResponse> send(HttpClientRequest request);
158158

159159
/**
160-
* Release the proxy request and its associated resources
160+
* Release the proxy request and its associated resources.
161161
*
162162
* <p> The HTTP server request is resumed, no HTTP server response is sent.
163163
*

src/main/java/io/vertx/httpproxy/cache/CacheOptions.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public class CacheOptions {
3333
private boolean shared = DEFAULT_SHARED;
3434

3535
/**
36-
* Default constructor
36+
* Default constructor.
3737
*/
3838
public CacheOptions() {
3939
}
4040

4141
/**
42-
* Copy constructor
42+
* Copy constructor.
4343
*
4444
* @param other the options to copy
4545
*/
@@ -50,7 +50,7 @@ public CacheOptions(CacheOptions other) {
5050
}
5151

5252
/**
53-
* Constructor to create an options from JSON
53+
* Constructor to create an options from JSON.
5454
*
5555
* @param json the JSON
5656
*/
@@ -124,7 +124,7 @@ public String toString() {
124124
}
125125

126126
/**
127-
* Convert to JSON
127+
* Convert to JSON.
128128
*
129129
* @return the JSON
130130
*/

src/main/java/io/vertx/httpproxy/impl/CacheImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,4 @@ public Future<Void> remove(String key) {
4444
return Future.succeededFuture();
4545
}
4646

47-
@Override
48-
public Future<Void> close() {
49-
return Future.succeededFuture();
50-
}
5147
}

src/main/java/io/vertx/httpproxy/impl/ReverseProxy.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ public Cache newCache(CacheOptions options, Vertx vertx) {
5050
if (options.getShared()) {
5151
CloseFuture closeFuture = new CloseFuture();
5252
return ((VertxInternal) vertx).createSharedResource("__vertx.shared.proxyCache", options.getName(), closeFuture, (cf_) -> {
53-
Cache cache = new CacheImpl(options);
54-
cf_.add(completion -> {
55-
cache.close().onComplete(completion);
56-
});
57-
return cache;
53+
return new CacheImpl(options);
5854
});
5955
}
6056
return new CacheImpl(options);

src/main/java/io/vertx/httpproxy/spi/cache/Cache.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package io.vertx.httpproxy.spi.cache;
22

3+
import io.vertx.codegen.annotations.Unstable;
34
import io.vertx.core.Future;
45
import io.vertx.core.dns.SrvRecord;
56

67

78
/**
89
* Cache SPI.
910
*/
11+
@Unstable
1012
public interface Cache {
1113

1214
/**
@@ -37,11 +39,4 @@ public interface Cache {
3739
* @return a succeed void future
3840
*/
3941
Future<Void> remove(String key);
40-
41-
/**
42-
* Being called when need to close the cache.
43-
*
44-
* @return a succeed void future
45-
*/
46-
Future<Void> close();
4742
}

src/test/java/io/vertx/tests/cache/spi/CacheSpiTestBase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ public void setUp() {
3636

3737
@After
3838
public void tearDown(TestContext context) {
39-
cache.close().onComplete(context.asyncAssertSuccess(
40-
v -> vertx.close().onComplete(context.asyncAssertSuccess())
41-
));
39+
vertx.close().onComplete(context.asyncAssertSuccess());
4240
}
4341

4442
private Resource generateResource(String absoluteURI, long maxAge) {

src/test/java/io/vertx/tests/parsing/ResourceParseTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.junit.Test;
99

1010
import java.util.Arrays;
11+
import java.util.Map;
1112
import java.util.Objects;
1213

1314
public class ResourceParseTest {
@@ -24,12 +25,17 @@ public static boolean weakEquals(Resource r1, Resource r2) {
2425

2526
if (r1.getHeaders() == null ^ r2.getHeaders() == null) return false;
2627
if (r1.getHeaders() != null && r2.getHeaders() != null) {
27-
if (r1.getHeaders().size() != r2.getHeaders().size()) return false;
28+
MultiMap h1 = r1.getHeaders();
29+
MultiMap h2 = r2.getHeaders();
30+
if (h1.size() != h2.size()) return false;
31+
for (Map.Entry<String, String> e : h1.entries()) {
32+
if (!Objects.equals(e.getValue(), h2.get(e.getKey()))) return false;
33+
}
2834
}
2935

3036
if (r1.getContent() == null ^ r2.getContent() == null) return false;
3137
if (r1.getContent() != null && r2.getContent() != null) {
32-
if (r1.getContent().length() != r2.getContent().length()) return false;
38+
if (!Arrays.equals(r1.getContent().getBytes(), r2.getContent().getBytes())) return false;
3339
}
3440

3541
return true;

0 commit comments

Comments
 (0)