CaseInsensitiveHeaders deprecation - fixes #3268

This commit is contained in:
Julien Viet
2020-01-30 10:36:50 +01:00
parent bc11c218f1
commit 7eb6f16b82
13 changed files with 22 additions and 22 deletions

View File

@@ -41,7 +41,9 @@ public interface MultiMap extends Iterable<Map.Entry<String, String>> {
* @return the multi-map
*/
static MultiMap caseInsensitiveMultiMap() {
return new CaseInsensitiveHeaders();
@SuppressWarnings("deprecation")
CaseInsensitiveHeaders map = new CaseInsensitiveHeaders();
return map;
}
@GenIgnore(GenIgnore.PERMITTED_TYPE)

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

@@ -15,7 +15,6 @@ import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
import io.vertx.core.eventbus.*;
import io.vertx.core.http.CaseInsensitiveHeaders;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
@@ -63,7 +62,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());
}
@@ -89,7 +88,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

@@ -20,7 +20,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.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.core.net.impl.ServerID;
@@ -76,7 +75,7 @@ public class ClusteredMessage<U, V> extends MessageImpl<U, V> {
decodeHeaders();
}
if (headers == null) {
headers = new CaseInsensitiveHeaders();
headers = MultiMap.caseInsensitiveMultiMap();
}
}
return headers;
@@ -207,7 +206,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

@@ -27,7 +27,9 @@ import java.util.function.Consumer;
* prior to making an HTTP request.
*
* @author <a href="mailto:nmaurer@redhat.com">Norman Maurer</a>
* @deprecated instead use {@link MultiMap}
*/
@Deprecated
public final class CaseInsensitiveHeaders implements MultiMap {
private static final int BUCKET_SIZE = 17;
@@ -104,6 +106,10 @@ public final class CaseInsensitiveHeaders implements MultiMap {
private final MapEntry[] entries = new MapEntry[BUCKET_SIZE];
private final MapEntry head = new MapEntry(-1, null, null);
/**
* @deprecated use {@link MultiMap#caseInsensitiveMultiMap()} instead
*/
@Deprecated
public CaseInsensitiveHeaders() {
head.before = head.after = head;
}

View File

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

View File

@@ -249,7 +249,7 @@ class Http2ClientConnection extends Http2ConnectionBase implements HttpClientCon
responseEnded = true;
// Should use a shared immutable object for CaseInsensitiveHeaders ?
if (trailers == null) {
trailers = new CaseInsensitiveHeaders();
trailers = MultiMap.caseInsensitiveMultiMap();
}
response.handleEnd(trailers);
}

View File

@@ -26,7 +26,6 @@ import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.Handler;
import io.vertx.core.MultiMap;
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;
@@ -449,7 +448,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

@@ -605,7 +605,7 @@ public class HttpServerRequestImpl implements HttpServerRequest {
private MultiMap attributes() {
// 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.HttpServerRequest;
import io.vertx.core.http.StreamPriority;
@@ -381,7 +380,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.HandlerRegistration;
import io.vertx.core.http.CaseInsensitiveHeaders;
import io.vertx.core.impl.ConcurrentHashSet;
import io.vertx.core.impl.ContextInternal;
import io.vertx.core.impl.EventLoopContext;
@@ -758,7 +757,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());

View File

@@ -27,7 +27,7 @@ public class CaseInsensitiveHeadersTest extends VertxHttpHeadersTest {
}
protected MultiMap newMultiMap() {
return new CaseInsensitiveHeaders();
return MultiMap.caseInsensitiveMultiMap();
}
@Test