mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
Avoid using CaseInsensitiveMultiMap directly
This commit is contained in:
@@ -15,7 +15,6 @@ import io.vertx.codegen.annotations.Fluent;
|
||||
import io.vertx.codegen.annotations.GenIgnore;
|
||||
import io.vertx.codegen.annotations.Nullable;
|
||||
import io.vertx.codegen.annotations.VertxGen;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.http.HttpHeaders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -14,7 +14,6 @@ package io.vertx.core.eventbus;
|
||||
import io.vertx.codegen.annotations.DataObject;
|
||||
import io.vertx.codegen.annotations.GenIgnore;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.impl.Arguments;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
|
||||
@@ -75,7 +74,7 @@ public class DeliveryOptions {
|
||||
this.codecName = json.getString("codecName", null);
|
||||
JsonObject hdrs = json.getJsonObject("headers", null);
|
||||
if (hdrs != null) {
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
for (Map.Entry<String, Object> entry: hdrs) {
|
||||
if (!(entry.getValue() instanceof String)) {
|
||||
throw new IllegalStateException("Invalid type for message header value " + entry.getValue().getClass());
|
||||
@@ -194,7 +193,7 @@ public class DeliveryOptions {
|
||||
|
||||
private void checkHeaders() {
|
||||
if (headers == null) {
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ package io.vertx.core.eventbus.impl;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.eventbus.*;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.impl.logging.Logger;
|
||||
import io.vertx.core.impl.logging.LoggerFactory;
|
||||
|
||||
@@ -60,7 +59,7 @@ public class MessageImpl<U, V> implements Message<V> {
|
||||
this.messageCodec = other.messageCodec;
|
||||
if (other.headers != null) {
|
||||
List<Map.Entry<String, String>> entries = other.headers.entries();
|
||||
this.headers = new CaseInsensitiveHeaders();
|
||||
this.headers = MultiMap.caseInsensitiveMultiMap();
|
||||
for (Map.Entry<String, String> entry: entries) {
|
||||
this.headers.add(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@@ -85,7 +84,7 @@ public class MessageImpl<U, V> implements Message<V> {
|
||||
public MultiMap headers() {
|
||||
// Lazily decode headers
|
||||
if (headers == null) {
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
return headers;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.vertx.core.eventbus.MessageCodec;
|
||||
import io.vertx.core.eventbus.impl.CodecManager;
|
||||
import io.vertx.core.eventbus.impl.EventBusImpl;
|
||||
import io.vertx.core.eventbus.impl.MessageImpl;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.impl.logging.Logger;
|
||||
import io.vertx.core.impl.logging.LoggerFactory;
|
||||
import io.vertx.core.net.impl.ServerID;
|
||||
@@ -85,7 +84,7 @@ public class ClusteredMessage<U, V> extends MessageImpl<U, V> {
|
||||
decodeHeaders();
|
||||
}
|
||||
if (headers == null) {
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
}
|
||||
return headers;
|
||||
@@ -217,7 +216,7 @@ public class ClusteredMessage<U, V> extends MessageImpl<U, V> {
|
||||
headersPos += 4;
|
||||
int numHeaders = wireBuffer.getInt(headersPos);
|
||||
headersPos += 4;
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
for (int i = 0; i < numHeaders; i++) {
|
||||
int keyLength = wireBuffer.getInt(headersPos);
|
||||
headersPos += 4;
|
||||
|
||||
@@ -352,7 +352,7 @@ public class RequestOptions {
|
||||
|
||||
private void checkHeaders() {
|
||||
if (headers == null) {
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,12 @@
|
||||
|
||||
package io.vertx.core.http;
|
||||
|
||||
import io.vertx.codegen.annotations.CacheReturn;
|
||||
import io.vertx.codegen.annotations.GenIgnore;
|
||||
import io.vertx.codegen.annotations.Nullable;
|
||||
import io.vertx.codegen.annotations.VertxGen;
|
||||
import io.vertx.core.AsyncResult;
|
||||
import io.vertx.core.Future;
|
||||
import io.vertx.core.Handler;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
|
||||
|
||||
@@ -589,7 +589,7 @@ public class Http1xServerRequest implements HttpServerRequest {
|
||||
private MultiMap attributes() {
|
||||
// Create it lazily
|
||||
if (attributes == null) {
|
||||
attributes = new CaseInsensitiveHeaders();
|
||||
attributes = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -385,10 +385,6 @@ class Http2ClientConnection extends Http2ConnectionBase implements HttpClientCon
|
||||
|
||||
@Override
|
||||
void handleEnd(MultiMap trailers) {
|
||||
// Should use a shared immutable object for CaseInsensitiveHeaders ?
|
||||
if (trailers == null) {
|
||||
trailers = new CaseInsensitiveHeaders();
|
||||
}
|
||||
response.handleEnd(trailers);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import io.vertx.core.Handler;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Promise;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.http.Cookie;
|
||||
import io.vertx.core.http.HttpConnection;
|
||||
import io.vertx.core.http.HttpMethod;
|
||||
@@ -466,7 +465,7 @@ public class Http2ServerRequestImpl extends Http2ServerStream implements HttpSer
|
||||
synchronized (conn) {
|
||||
// Create it lazily
|
||||
if (attributes == null) {
|
||||
attributes = new CaseInsensitiveHeaders();
|
||||
attributes = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import io.netty.util.AsciiString;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.http.HttpClientRequest;
|
||||
import io.vertx.core.http.HttpClientResponse;
|
||||
import io.vertx.core.http.HttpServerRequest;
|
||||
@@ -481,7 +480,7 @@ public final class HttpUtils {
|
||||
static MultiMap params(String uri) {
|
||||
QueryStringDecoder queryStringDecoder = new QueryStringDecoder(uri);
|
||||
Map<String, List<String>> prms = queryStringDecoder.parameters();
|
||||
MultiMap params = new CaseInsensitiveHeaders();
|
||||
MultiMap params = MultiMap.caseInsensitiveMultiMap();
|
||||
if (!prms.isEmpty()) {
|
||||
for (Map.Entry<String, List<String>> entry: prms.entrySet()) {
|
||||
params.add(entry.getKey(), entry.getValue());
|
||||
|
||||
@@ -18,11 +18,9 @@ import io.netty.util.AsciiString;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import io.netty.util.HashingStrategy;
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.http.impl.HttpUtils;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,7 +13,6 @@ package io.vertx.core.eventbus;
|
||||
|
||||
import io.vertx.core.*;
|
||||
import io.vertx.core.eventbus.impl.MessageConsumerImpl;
|
||||
import io.vertx.core.http.CaseInsensitiveHeaders;
|
||||
import io.vertx.core.impl.ConcurrentHashSet;
|
||||
import io.vertx.core.impl.ContextInternal;
|
||||
import io.vertx.core.impl.EventLoopContext;
|
||||
@@ -751,7 +750,7 @@ public class LocalEventBusTest extends EventBusTestBase {
|
||||
|
||||
@Test
|
||||
public void testHeadersCopiedAfterSend() throws Exception {
|
||||
MultiMap headers = new CaseInsensitiveHeaders();
|
||||
MultiMap headers = MultiMap.caseInsensitiveMultiMap();
|
||||
headers.add("foo", "bar");
|
||||
vertx.eventBus().consumer(ADDRESS1).handler(msg -> {
|
||||
assertNotSame(headers, msg.headers());
|
||||
|
||||
Reference in New Issue
Block a user