Avoid using CaseInsensitiveMultiMap directly

This commit is contained in:
Julien Viet
2020-01-30 09:57:35 +01:00
parent 67011f027b
commit df59247516
12 changed files with 11 additions and 26 deletions

View File

@@ -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;

View File

@@ -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();
}
}

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -352,7 +352,7 @@ public class RequestOptions {
private void checkHeaders() {
if (headers == null) {
headers = new CaseInsensitiveHeaders();
headers = MultiMap.caseInsensitiveMultiMap();
}
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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());

View File

@@ -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;

View File

@@ -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());