MINOR: Remove Dead Code from Netty4Transport (#34134)
* None of these methods are used
This commit is contained in:
parent
7df842c78d
commit
732ab06ee4
|
@ -49,19 +49,6 @@ public final class Netty4CorsConfigBuilder {
|
|||
return new Netty4CorsConfigBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Netty4CorsConfigBuilder} instance with the specified origin.
|
||||
*
|
||||
* @return {@link Netty4CorsConfigBuilder} to support method chaining.
|
||||
*/
|
||||
public static Netty4CorsConfigBuilder forOrigin(final String origin) {
|
||||
if ("*".equals(origin)) {
|
||||
return new Netty4CorsConfigBuilder();
|
||||
}
|
||||
return new Netty4CorsConfigBuilder(origin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@link Netty4CorsConfigBuilder} instance with the specified pattern origin.
|
||||
*
|
||||
|
@ -94,7 +81,6 @@ public final class Netty4CorsConfigBuilder {
|
|||
final Set<HttpMethod> requestMethods = new HashSet<>();
|
||||
final Set<String> requestHeaders = new HashSet<>();
|
||||
final Map<CharSequence, Callable<?>> preflightHeaders = new HashMap<>();
|
||||
private boolean noPreflightHeaders;
|
||||
boolean shortCircuit;
|
||||
|
||||
/**
|
||||
|
@ -130,18 +116,6 @@ public final class Netty4CorsConfigBuilder {
|
|||
anyOrigin = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Web browsers may set the 'Origin' request header to 'null' if a resource is loaded
|
||||
* from the local file system. Calling this method will enable a successful CORS response
|
||||
* with a wildcard for the CORS response header 'Access-Control-Allow-Origin'.
|
||||
*
|
||||
* @return {@link Netty4CorsConfigBuilder} to support method chaining.
|
||||
*/
|
||||
Netty4CorsConfigBuilder allowNullOrigin() {
|
||||
allowNullOrigin = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables CORS support.
|
||||
*
|
||||
|
@ -219,71 +193,6 @@ public final class Netty4CorsConfigBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTTP response headers that should be added to a CORS preflight response.
|
||||
*
|
||||
* An intermediary like a load balancer might require that a CORS preflight request
|
||||
* have certain headers set. This enables such headers to be added.
|
||||
*
|
||||
* @param name the name of the HTTP header.
|
||||
* @param values the values for the HTTP header.
|
||||
* @return {@link Netty4CorsConfigBuilder} to support method chaining.
|
||||
*/
|
||||
public Netty4CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Object... values) {
|
||||
if (values.length == 1) {
|
||||
preflightHeaders.put(name, new ConstantValueGenerator(values[0]));
|
||||
} else {
|
||||
preflightResponseHeader(name, Arrays.asList(values));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTTP response headers that should be added to a CORS preflight response.
|
||||
*
|
||||
* An intermediary like a load balancer might require that a CORS preflight request
|
||||
* have certain headers set. This enables such headers to be added.
|
||||
*
|
||||
* @param name the name of the HTTP header.
|
||||
* @param value the values for the HTTP header.
|
||||
* @param <T> the type of values that the Iterable contains.
|
||||
* @return {@link Netty4CorsConfigBuilder} to support method chaining.
|
||||
*/
|
||||
public <T> Netty4CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Iterable<T> value) {
|
||||
preflightHeaders.put(name, new ConstantValueGenerator(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTTP response headers that should be added to a CORS preflight response.
|
||||
*
|
||||
* An intermediary like a load balancer might require that a CORS preflight request
|
||||
* have certain headers set. This enables such headers to be added.
|
||||
*
|
||||
* Some values must be dynamically created when the HTTP response is created, for
|
||||
* example the 'Date' response header. This can be accomplished by using a Callable
|
||||
* which will have its 'call' method invoked when the HTTP response is created.
|
||||
*
|
||||
* @param name the name of the HTTP header.
|
||||
* @param valueGenerator a Callable which will be invoked at HTTP response creation.
|
||||
* @param <T> the type of the value that the Callable can return.
|
||||
* @return {@link Netty4CorsConfigBuilder} to support method chaining.
|
||||
*/
|
||||
public <T> Netty4CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Callable<T> valueGenerator) {
|
||||
preflightHeaders.put(name, valueGenerator);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies that no preflight response headers should be added to a preflight response.
|
||||
*
|
||||
* @return {@link Netty4CorsConfigBuilder} to support method chaining.
|
||||
*/
|
||||
public Netty4CorsConfigBuilder noPreflightResponseHeaders() {
|
||||
noPreflightHeaders = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies that a CORS request should be rejected if it's invalid before being
|
||||
* further processing.
|
||||
|
@ -305,7 +214,7 @@ public final class Netty4CorsConfigBuilder {
|
|||
* @return {@link Netty4CorsConfig} the configured CorsConfig instance.
|
||||
*/
|
||||
public Netty4CorsConfig build() {
|
||||
if (preflightHeaders.isEmpty() && !noPreflightHeaders) {
|
||||
if (preflightHeaders.isEmpty()) {
|
||||
preflightHeaders.put("date", DateValueGenerator.INSTANCE);
|
||||
preflightHeaders.put("content-length", new ConstantValueGenerator("0"));
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ package org.elasticsearch.transport.netty4;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.CompositeByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelFuture;
|
||||
import io.netty.util.NettyRuntime;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
|
@ -34,7 +32,6 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
@ -133,27 +130,4 @@ public class Netty4Utils {
|
|||
return new ByteBufBytesReference(buffer, size);
|
||||
}
|
||||
|
||||
public static void closeChannels(final Collection<Channel> channels) throws IOException {
|
||||
IOException closingExceptions = null;
|
||||
final List<ChannelFuture> futures = new ArrayList<>();
|
||||
for (final Channel channel : channels) {
|
||||
try {
|
||||
if (channel != null && channel.isOpen()) {
|
||||
futures.add(channel.close());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (closingExceptions == null) {
|
||||
closingExceptions = new IOException("failed to close channels");
|
||||
}
|
||||
closingExceptions.addSuppressed(e);
|
||||
}
|
||||
}
|
||||
for (final ChannelFuture future : futures) {
|
||||
future.awaitUninterruptibly();
|
||||
}
|
||||
|
||||
if (closingExceptions != null) {
|
||||
throw closingExceptions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue