mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
CaseInsensitiveHeaders deprecation - fixes #3268
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public class RequestOptions {
|
||||
|
||||
private void checkHeaders() {
|
||||
if (headers == null) {
|
||||
headers = new CaseInsensitiveHeaders();
|
||||
headers = MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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.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());
|
||||
|
||||
@@ -27,7 +27,7 @@ public class CaseInsensitiveHeadersTest extends VertxHttpHeadersTest {
|
||||
}
|
||||
|
||||
protected MultiMap newMultiMap() {
|
||||
return new CaseInsensitiveHeaders();
|
||||
return MultiMap.caseInsensitiveMultiMap();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user