code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
public EpollServerSocketChannelConfig setFreeBind(boolean freeBind) {
try {
((EpollServerSocketChannel) channel).socket.setIpFreeBind(freeBind);
return this;
} catch (IOException e) {
throw new ChannelException(... | Create a Java method that does the following: "Sets whether the free bind flag is set.". |
Of course, here is the Java code you requested:
```java
public EpollServerSocketChannelConfig setIpTransparent(boolean transparent) {
try {
((EpollServerSocketChannel) channel).socket.setIpTransparent(transparent);
return this;
} catch (IOException e) {
throw new Cha... | Create a Java method that does the following: "Sets the transparent mode of the socket.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <T> ProtocolDetectionResult<T> detected(T protocol) {
return new ProtocolDetectionResult<T>(ProtocolDetectionState.DETECTED, checkNotNull(protocol, "protocol"));
}
```
Hope this helps! | Create a Java method that does the following: "Creates a new instance of the class which is detected by the given protocol.". |
Of course, here is the Java code you requested:
```java
boolean decodeHuffmanData(final Bzip2HuffmanStageDecoder huffmanDecoder) {
final Bzip2BitReader reader = this.reader;
final byte[] bwtBlock = this.bwtBlock;
final byte[] huffmanSymbolMap = this.huffmanSymbolMap;
final int streamBlo... | Create a Java method that does the following: "Decode the Huffman data.". |
Of course, here is the Java code you requested:
```java
private void initialiseInverseBWT() {
final int bwtStartPointer = this.bwtStartPointer;
final byte[] bwtBlock = this.bwtBlock;
final int[] bwtMergedPointers = new int[bwtBlockLength];
final int[] characterBase = new int[256];
... | Create a Java method that does the following: "Initialise the inverse Burrows - Wheeler Transform.". |
Of course, here is the Java code you requested:
```java
public int read() {
while (rleRepeat < 1) {
if (bwtBytesDecoded == bwtBlockLength) {
return -1;
}
int nextByte = decodeNextBWTByte();
if (nextByte != rleLastDecodedByte) {
//... | Create a Java method that does the following: "Read a single BWT byte from the stream.". |
Of course, here is the Java code you requested:
```java
@Override
public Long put(char key, Long value) {
verifyStandardSetting(key, value);
return super.put(key, value);
}
```
Hope this helps! | Create a Java method that does the following: "Override put to verify the standard setting and put the value.". |
Of course, here is the Java code you requested:
```java
public Boolean pushEnabled() {
Long value = get(SETTINGS_ENABLE_PUSH);
if (value == null) {
return null;
}
return TRUE.equals(value);
}
```
Hope this helps! | Create a Java method that does the following: "Gets the value of the SETTINGS_ENABLE_PUSH property.". |
Of course, here is the Java code you requested:
```java
public static WebSocketClientHandshaker newHandshaker(
URI webSocketURL, WebSocketVersion version, String subprotocol,
boolean allowExtensions, HttpHeaders customHeaders) {
return newHandshaker(webSocketURL, version, subprotocol, a... | Create a Java method that does the following: "Create a new instance of the class handshaker.". |
Of course, here is the Java code you requested:
```java
public static WebSocketClientHandshaker newHandshaker(
URI webSocketURL, WebSocketVersion version, String subprotocol,
boolean allowExtensions, HttpHeaders customHeaders, int maxFramePayloadLength) {
return newHandshaker(webSocketU... | Create a Java method that does the following: "Create a new handshaker.". |
Of course, here is the Java code you requested:
```java
public static void load(String originalName, ClassLoader loader) {
// Adjust expected name to support shading of native libraries.
String packagePrefix = calculatePackagePrefix().replace('.', '_');
String name = packagePrefix + originalNam... | Create a Java method that does the following: "Load a single class from the system library.". |
Of course, here is the Java code you requested:
```java
static boolean patchShadedLibraryId(InputStream in, OutputStream out, String originalName, String name)
throws IOException {
byte[] buffer = new byte[8192];
int length;
// We read the whole native lib into memory to make it eas... | Create a Java method that does the following: "Patch the shaded library id.". |
Of course, here is the Java code you requested:
```java
private static void loadLibrary(final ClassLoader loader, final String name, final boolean absolute) {
Throwable suppressed = null;
try {
try {
// Make sure the helper is belong to the target ClassLoader.
... | Create a Java method that does the following: "Load the library.". |
Of course, here is the Java code you requested:
```java
public static long memoryAddress(ByteBuffer buffer) {
assert buffer.isDirect();
if (PlatformDependent.hasUnsafe()) {
return PlatformDependent.directBufferAddress(buffer);
}
return memoryAddress0(buffer);
}
```
Hope... | Create a Java method that does the following: "Get the address of the given buffer as a long.". |
Of course, here is the Java code you requested:
```java
private M invalidMessage(Exception cause) {
state = State.BAD_MESSAGE;
M message = buildInvalidMessage();
message.setDecoderResult(DecoderResult.failure(cause));
return message;
}
```
Hope this helps! | Create a Java method that does the following: "Creates an invalid message.". |
Of course, here is the Java code you requested:
```java
private void sendResponse(ChannelHandlerContext ctx, int streamId, ByteBuf payload) {
// Send a frame for the response status
Http2Headers headers = new DefaultHttp2Headers().status(OK.codeAsText());
encoder().writeHeaders(ctx, streamId, h... | Create a Java method that does the following: "Sends a response frame to the server.". |
Of course, here is the Java code you requested:
```java
public static StringBuilder append(Date date, StringBuilder sb) {
return formatter().append0(checkNotNull(date, "date"), checkNotNull(sb, "sb"));
}
```
Hope this helps! | Create a Java method that does the following: "Append a date to a StringBuilder.". |
Of course, here is the Java code you requested:
```java
@Override
public final void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
try {
onChannelReadComplete(ctx);
} finally {
parentReadInProgress = false;
tail = head = null;
// We... | Create a Java method that does the following: "Called when the channel is complete.". |
Of course, here is the Java code you requested:
```java
protected B server(boolean isServer) {
enforceConstraint("server", "connection", connection);
enforceConstraint("server", "codec", decoder);
enforceConstraint("server", "codec", encoder);
this.isServer = isServer;
return s... | Create a Java method that does the following: "Sets the isServer attribute of the Crafter App App.". |
Of course, here is the Java code you requested:
```java
protected B maxReservedStreams(int maxReservedStreams) {
enforceConstraint("server", "connection", connection);
enforceConstraint("server", "codec", decoder);
enforceConstraint("server", "codec", encoder);
this.maxReservedStreams ... | Create a Java method that does the following: "Sets the maximum number of reserved streams for this session.". |
Of course, here is the Java code you requested:
```java
protected B codec(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder) {
enforceConstraint("codec", "server", isServer);
enforceConstraint("codec", "maxReservedStreams", maxReservedStreams);
enforceConstraint("codec", "connectio... | Create a Java method that does the following: "Sets the codec.". |
Of course, here is the Java code you requested:
```java
protected T build() {
if (encoder != null) {
assert decoder != null;
return buildFromCodec(decoder, encoder);
}
Http2Connection connection = this.connection;
if (connection == null) {
connection... | Create a Java method that does the following: "Build the result.". |
Of course, here is the Java code you requested:
```java
final void forEachActiveStream(final Http2FrameStreamVisitor streamVisitor) throws Http2Exception {
assert ctx.executor().inEventLoop();
connection().forEachActiveStream(new Http2StreamVisitor() {
@Override
public boolean ... | Create a Java method that does the following: "For each active stream visit the given streamVisitor.". |
Of course, here is the Java code you requested:
```java
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
if (msg instanceof Http2DataFrame) {
Http2DataFrame dataFrame = (Http2DataFrame) msg;
encoder().writeData(ctx, dataFrame.stream().id()... | Create a Java method that does the following: "Override method to write a message to the HTTP2 protocol.". |
Of course, here is the Java code you requested:
```java
private static FullHttpResponse createUpgradeResponse(CharSequence upgradeProtocol) {
DefaultFullHttpResponse res = new DefaultFullHttpResponse(HTTP_1_1, SWITCHING_PROTOCOLS,
Unpooled.EMPTY_BUFFER, false);
res.headers().add(HttpHea... | Create a Java method that does the following: "Creates a new HTTP response with the upgrade protocol and the content.". |
Of course, here is the Java code you requested:
```java
private static List<CharSequence> splitHeader(CharSequence header) {
final StringBuilder builder = new StringBuilder(header.length());
final List<CharSequence> protocols = new ArrayList<CharSequence>(4);
for (int i = 0; i < header.length()... | Create a Java method that does the following: "Split the header into a list of protocol strings.". |
Of course, here is the Java code you requested:
```java
public static Http2Exception connectionError(Http2Error error, String fmt, Object... args) {
return new Http2Exception(error, String.format(fmt, args));
}
```
Hope this helps! | Create a Java method that does the following: "Create a new Http2Exception with a connection error.". |
Of course, here is the Java code you requested:
```java
public static Http2Exception headerListSizeError(int id, Http2Error error, boolean onDecode,
String fmt, Object... args) {
return CONNECTION_STREAM_ID == id ?
Http2Exception.connectionError(error, fmt, args) :
... | Create a Java method that does the following: "Create an exception for a HeaderListSizeError.". |
Of course, here is the Java code you requested:
```java
void add(AbstractEpollChannel ch) throws IOException {
assert inEventLoop();
int fd = ch.socket.intValue();
Native.epollCtlAdd(epollFd.intValue(), fd, ch.flags);
channels.put(fd, ch);
}
```
Hope this helps! | Create a Java method that does the following: "Add a new EpollChannel to the set of channels.". |
Of course, here is the Java code you requested:
```java
void remove(AbstractEpollChannel ch) throws IOException {
assert inEventLoop();
if (ch.isOpen()) {
int fd = ch.socket.intValue();
if (channels.remove(fd) != null) {
// Remove the epoll. This is only needed ... | Create a Java method that does the following: "Remove a channel from the list of channels.". |
Of course, here is the Java code you requested:
```java
@Override
public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
if (ctx.channel().isRegistered()) {
// This should always be true with our current DefaultChannelPipeline implementation.
// The good thing about ... | Create a Java method that does the following: "This method is called when a handler is added to the channel pipeline.". |
Of course, here is the Java code you requested:
```java
public static <T> T checkNotNull(T arg, String text) {
if (arg == null) {
throw new NullPointerException(text);
}
return arg;
}
```
Hope this helps! | Create a Java method that does the following: "Check if the argument is not null.". |
Of course, here is the Java code you requested:
```java
public static <T extends Collection<?>> T checkNonEmpty(T collection, String name) {
checkNotNull(collection, name);
checkPositive(collection.size(), name + ".size");
return collection;
}
```
Hope this helps! | Create a Java method that does the following: "Check that the collection is non - empty.". |
Of course, here is the Java code you requested:
```java
protected boolean isSwitchingToNonHttp1Protocol(HttpResponse msg) {
if (msg.status().code() != HttpResponseStatus.SWITCHING_PROTOCOLS.code()) {
return false;
}
String newProtocol = msg.headers().get(HttpHeaderNames.UPGRADE);
... | Create a Java method that does the following: "Checks if the response is switching to a non - HTTP 1 protocol.". |
Of course, here is the Java code you requested:
```java
static int mask(Class<? extends ChannelHandler> clazz) {
// Try to obtain the mask from the cache first. If this fails calculate it and put it in the cache for fast
// lookup in the future.
Map<Class<? extends ChannelHandler>, Integer> cac... | Create a Java method that does the following: "Get the mask for a channel handler.". |
Of course, here is the Java code you requested:
```java
private static int mask0(Class<? extends ChannelHandler> handlerType) {
int mask = MASK_EXCEPTION_CAUGHT;
try {
if (ChannelInboundHandler.class.isAssignableFrom(handlerType)) {
mask |= MASK_ALL_INBOUND;
... | Create a Java method that does the following: "mask 0 for all exceptions". |
Of course, here is the Java code you requested:
```java
public static ByteBuf toByteBuf(InputStream input) throws IOException {
ByteBuf buf = Unpooled.buffer();
int n = 0;
do {
n = buf.writeBytes(input, BLOCK_SIZE);
} while (n > 0);
return buf;
}
```
Hope this h... | Create a Java method that does the following: "Convert an input stream to a byte buffer.". |
Of course, here is the Java code you requested:
```java
public static <K, V> List<String> getAllAsString(Headers<K, V, ?> headers, K name) {
final List<V> allNames = headers.getAll(name);
return new AbstractList<String>() {
@Override
public String get(int index) {
... | Create a Java method that does the following: "Gets all String value from a Headers object.". |
Of course, here is the Java code you requested:
```java
public static <K, V> String getAsString(Headers<K, V, ?> headers, K name) {
V orig = headers.get(name);
return orig != null ? orig.toString() : null;
}
```
Hope this helps! | Create a Java method that does the following: "Get the value of the header as a string.". |
Of course, here is the Java code you requested:
```java
public static Iterator<Entry<String, String>> iteratorAsString(
Iterable<Entry<CharSequence, CharSequence>> headers) {
return new StringEntryIterator(headers.iterator());
}
```
Hope this helps! | Create a Java method that does the following: "Returns an iterator over the given sequence of CIDCTYPE entries as a String.". |
Of course, here is the Java code you requested:
```java
public static Set<String> namesAsString(Headers<CharSequence, CharSequence, ?> headers) {
return new CharSequenceDelegatingStringSet(headers.names());
}
```
Hope this helps! | Create a Java method that does the following: "Returns a set of names as a string set.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings({ "unchecked", "rawtypes" })
public void add(Future future) {
checkAddAllowed();
checkInEventLoop();
++expectedCount;
future.addListener(listener);
}
```
Hope this helps! | Create a Java method that does the following: "Add a new resource to the resource.". |
Of course, here is the Java code you requested:
```java
public static File getFile(Class resourceClass, String fileName) {
try {
return new File(URLDecoder.decode(resourceClass.getResource(fileName).getFile(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
return new File... | Create a Java method that does the following: "Gets the File from the resource class and the file name.". |
Of course, here is the Java code you requested:
```java
void createGlobalTrafficCounter(ScheduledExecutorService executor) {
if (executor == null) {
throw new NullPointerException("executor");
}
TrafficCounter tc = new TrafficCounter(this, executor, "GlobalTC", checkInterval);
... | Create a Java method that does the following: "Create a TrafficCounter for the global thread.". |
Of course, here is the Java code you requested:
```java
public ChannelFuture handshake(Channel channel) {
if (channel == null) {
throw new NullPointerException("channel");
}
return handshake(channel, channel.newPromise());
}
```
Hope this helps! | Create a Java method that does the following: "Handshake the channel.". |
Of course, here is the Java code you requested:
```java
public final ChannelFuture handshake(Channel channel, final ChannelPromise promise) {
FullHttpRequest request = newHandshakeRequest();
HttpResponseDecoder decoder = channel.pipeline().get(HttpResponseDecoder.class);
if (decoder == null) ... | Create a Java method that does the following: "Perform a HTTP handshake.". |
Of course, here is the Java code you requested:
```java
public final ChannelFuture processHandshake(final Channel channel, HttpResponse response) {
return processHandshake(channel, response, channel.newPromise());
}
```
Hope this helps! | Create a Java method that does the following: "Process a HTTP handshake.". |
Of course, here is the Java code you requested:
```java
public ChannelFuture close(Channel channel, CloseWebSocketFrame frame) {
if (channel == null) {
throw new NullPointerException("channel");
}
return close(channel, frame, channel.newPromise());
}
```
Hope this helps! | Create a Java method that does the following: "Close the WebSocket connection.". |
Of course, here is the Java code you requested:
```java
static String rawPath(URI wsURL) {
String path = wsURL.getRawPath();
String query = wsURL.getRawQuery();
if (query != null && !query.isEmpty()) {
path = path + '?' + query;
}
return path == null || path.isEmpty... | Create a Java method that does the following: "Get the raw path of the URL.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static void setHeader(HttpMessage message, String name, Iterable<?> values) {
message.headers().set(name, values);
}
```
Hope this helps! | Create a Java method that does the following: "Sets the header of the given message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static void addHeader(HttpMessage message, String name, Object value) {
message.headers().add(name, value);
}
```
Hope this helps! | Create a Java method that does the following: "Add a header to the message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static void removeHeader(HttpMessage message, String name) {
message.headers().remove(name);
}
```
Hope this helps! | Create a Java method that does the following: "Removes a header from the message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static int getIntHeader(HttpMessage message, CharSequence name) {
String value = message.headers().get(name);
if (value == null) {
throw new NumberFormatException("header not found: " + name);
}
r... | Create a Java method that does the following: "Gets the value of the specified HTTP header as an int.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static int getIntHeader(HttpMessage message, String name, int defaultValue) {
return message.headers().getInt(name, defaultValue);
}
```
Hope this helps! | Create a Java method that does the following: "Get a header as an int.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static void addIntHeader(HttpMessage message, String name, int value) {
message.headers().add(name, value);
}
```
Hope this helps! | Create a Java method that does the following: "Add a header with an int value.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static void addIntHeader(HttpMessage message, CharSequence name, int value) {
message.headers().addInt(name, value);
}
```
Hope this helps! | Create a Java method that does the following: "Add an int header to the message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static Date getDateHeader(HttpMessage message, CharSequence name) throws ParseException {
String value = message.headers().get(name);
if (value == null) {
throw new ParseException("header not found: " + name, 0);... | Create a Java method that does the following: "Get a Date header from a message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static void setDateHeader(HttpMessage message, CharSequence name, Date value) {
if (value != null) {
message.headers().set(name, DateFormatter.format(value));
} else {
message.headers().set(name, null... | Create a Java method that does the following: "Sets a date header.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static String getHost(HttpMessage message) {
return message.headers().get(HttpHeaderNames.HOST);
}
```
Hope this helps! | Create a Java method that does the following: "Gets the host header from the message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static Date getDate(HttpMessage message) throws ParseException {
return getDateHeader(message, HttpHeaderNames.DATE);
}
```
Hope this helps! | Create a Java method that does the following: "Gets the Date value from the message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static Date getDate(HttpMessage message, Date defaultValue) {
return getDateHeader(message, HttpHeaderNames.DATE, defaultValue);
}
```
Hope this helps! | Create a Java method that does the following: "Gets the Date value from the message.". |
Of course, here is the Java code you requested:
```java
public HttpHeaders add(CharSequence name, Iterable<?> values) {
return add(name.toString(), values);
}
```
Hope this helps! | Create a Java method that does the following: "Add a header with the specified name and values.". |
Of course, here is the Java code you requested:
```java
public HttpHeaders add(HttpHeaders headers) {
if (headers == null) {
throw new NullPointerException("headers");
}
for (Map.Entry<String, String> e: headers) {
add(e.getKey(), e.getValue());
}
return ... | Create a Java method that does the following: "Add a collection of headers to this set.". |
Of course, here is the Java code you requested:
```java
public HttpHeaders set(CharSequence name, Object value) {
return set(name.toString(), value);
}
```
Hope this helps! | Create a Java method that does the following: "Sets a header with the specified name and value.". |
Of course, here is the Java code you requested:
```java
public HttpHeaders set(HttpHeaders headers) {
checkNotNull(headers, "headers");
clear();
if (headers.isEmpty()) {
return this;
}
for (Entry<String, String> entry : headers) {
add(entry.getKey(), e... | Create a Java method that does the following: "Sets the HTTP headers.". |
Of course, here is the Java code you requested:
```java
public static String ipv6toStr(byte[] src) {
assert src.length == 16;
StringBuilder sb = new StringBuilder(39);
ipv6toStr(sb, src, 0, 8);
return sb.toString();
}
```
Hope this helps! | Create a Java method that does the following: "Convert an IPv6 address to a string.". |
Of course, here is the Java code you requested:
```java
protected void readTimedOut(ChannelHandlerContext ctx) throws Exception {
if (!closed) {
ctx.fireExceptionCaught(ReadTimeoutException.INSTANCE);
ctx.close();
closed = true;
}
}
```
Hope this helps! | Create a Java method that does the following: "Called when a read timeout occurs.". |
Of course, here is the Java code you requested:
```java
public static ChannelUDT channelUDT(final Channel channel) {
// bytes
if (channel instanceof NioUdtByteAcceptorChannel) {
return ((NioUdtByteAcceptorChannel) channel).javaChannel();
}
if (channel instanceof NioUdtByteRe... | Create a Java method that does the following: "Get the ChannelUDT object for a given Channel.". |
Of course, here is the Java code you requested:
```java
static ServerSocketChannelUDT newAcceptorChannelUDT(
final TypeUDT type) {
try {
return SelectorProviderUDT.from(type).openServerSocketChannel();
} catch (final IOException e) {
throw new ChannelException("faile... | Create a Java method that does the following: "New acceptor channel udt.". |
Of course, here is the Java code you requested:
```java
private boolean hasOutputChanged(ChannelHandlerContext ctx, boolean first) {
if (observeOutput) {
// We can take this shortcut if the ChannelPromises that got passed into write()
// appear to complete. It indicates "change" on mes... | Create a Java method that does the following: "Checks if the output has changed.". |
Of course, here is the Java code you requested:
```java
static int getUnsignedShort(ByteBuf buf, int offset) {
return (buf.getByte(offset) & 0xFF) << 8 |
buf.getByte(offset + 1) & 0xFF;
}
```
Hope this helps! | Create a Java method that does the following: "Get the unsigned short from the buffer.". |
Of course, here is the Java code you requested:
```java
static int getUnsignedMedium(ByteBuf buf, int offset) {
return (buf.getByte(offset) & 0xFF) << 16 |
(buf.getByte(offset + 1) & 0xFF) << 8 |
buf.getByte(offset + 2) & 0xFF;
}
```
Hope this helps! | Create a Java method that does the following: "Get the unsigned medium from the buffer.". |
Of course, here is the Java code you requested:
```java
static int getUnsignedInt(ByteBuf buf, int offset) {
return (buf.getByte(offset) & 0x7F) << 24 |
(buf.getByte(offset + 1) & 0xFF) << 16 |
(buf.getByte(offset + 2) & 0xFF) << 8 |
buf.getByte(offset + 3) & ... | Create a Java method that does the following: "Get an unsigned int from the buffer.". |
Of course, here is the Java code you requested:
```java
static void validateHeaderName(CharSequence name) {
if (name == null) {
throw new NullPointerException("name");
}
if (name.length() == 0) {
throw new IllegalArgumentException(
"name cannot be len... | Create a Java method that does the following: "Validate the name of a header.". |
Of course, here is the Java code you requested:
```java
boolean allocateSmall(PoolArena<?> area, PooledByteBuf<?> buf, int reqCapacity, int normCapacity) {
return allocate(cacheForSmall(area, normCapacity), buf, reqCapacity);
}
```
Hope this helps! | Create a Java method that does the following: "Allocate a small block of data from the pool.". |
Of course, here is the Java code you requested:
```java
void free(boolean finalizer) {
// As free() may be called either by the finalizer or by FastThreadLocal.onRemoval(...) we need to ensure
// we only call this one time.
if (freed.compareAndSet(false, true)) {
int numFreed = free... | Create a Java method that does the following: "Free the cache.". |
Of course, here is the Java code you requested:
```java
public CorsConfigBuilder exposeHeaders(final CharSequence... headers) {
for (CharSequence header: headers) {
exposeHeaders.add(header.toString());
}
return this;
}
```
Hope this helps! | Create a Java method that does the following: "Expose headers.". |
Of course, here is the Java code you requested:
```java
public CorsConfigBuilder allowedRequestHeaders(final CharSequence... headers) {
for (CharSequence header: headers) {
requestHeaders.add(header.toString());
}
return this;
}
```
Hope this helps! | Create a Java method that does the following: "Add a list of headers to be allowed by the CORS request.". |
Of course, here is the Java code you requested:
```java
public <T> CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Iterable<T> value) {
preflightHeaders.put(name, new ConstantValueGenerator(value));
return this;
}
```
Hope this helps! | Create a Java method that does the following: "Add a preflight response header.". |
Of course, here is the Java code you requested:
```java
public <T> CorsConfigBuilder preflightResponseHeader(final CharSequence name, final Callable<T> valueGenerator) {
preflightHeaders.put(name, valueGenerator);
return this;
}
```
Hope this helps! | Create a Java method that does the following: "Add a preflight response header.". |
Of course, here is the Java code you requested:
```java
protected void cancelScheduledTasks() {
assert inEventLoop();
PriorityQueue<ScheduledFutureTask<?>> scheduledTaskQueue = this.scheduledTaskQueue;
if (isNullOrEmpty(scheduledTaskQueue)) {
return;
}
final Schedul... | Create a Java method that does the following: "Cancel all scheduled tasks.". |
Of course, here is the Java code you requested:
```java
protected final long nextScheduledTaskNano() {
Queue<ScheduledFutureTask<?>> scheduledTaskQueue = this.scheduledTaskQueue;
ScheduledFutureTask<?> scheduledTask = scheduledTaskQueue == null ? null : scheduledTaskQueue.peek();
if (scheduledT... | Create a Java method that does the following: "Gets the number of nanoseconds that the next scheduled task has.". |
Of course, here is the Java code you requested:
```java
protected final boolean hasScheduledTasks() {
Queue<ScheduledFutureTask<?>> scheduledTaskQueue = this.scheduledTaskQueue;
ScheduledFutureTask<?> scheduledTask = scheduledTaskQueue == null ? null : scheduledTaskQueue.peek();
return schedule... | Create a Java method that does the following: "Returns true if there are scheduled tasks in the queue.". |
Of course, here is the Java code you requested:
```java
public static byte[] createByteArrayFromIpAddressString(String ipAddressString) {
if (isValidIpV4Address(ipAddressString)) {
return validIpV4ToBytes(ipAddressString);
}
if (isValidIpV6Address(ipAddressString)) {
i... | Create a Java method that does the following: "Create a byte array from an ipAddress string.". |
Of course, here is the Java code you requested:
```java
static byte[] validIpV4ToBytes(String ip) {
int i;
return new byte[] {
ipv4WordToByte(ip, 0, i = ip.indexOf('.', 1)),
ipv4WordToByte(ip, i + 1, i = ip.indexOf('.', i + 2)),
ipv4WordToByte(ip, i + 1, ... | Create a Java method that does the following: "validIpV4ToBytes returns a byte array containing the bytes of the IP.". |
Of course, here is the Java code you requested:
```java
public static Inet6Address getByName(CharSequence ip, boolean ipv4Mapped) {
byte[] bytes = getIPv6ByName(ip, ipv4Mapped);
if (bytes == null) {
return null;
}
try {
return Inet6Address.getByAddress(null, byte... | Create a Java method that does the following: "Get an Inet6Address from a char sequence.". |
Of course, here is the Java code you requested:
```java
private static byte[] getIPv6ByName(CharSequence ip, boolean ipv4Mapped) {
final byte[] bytes = new byte[IPV6_BYTE_COUNT];
final int ipLength = ip.length();
int compressBegin = 0;
int compressLength = 0;
int currentIndex = ... | Create a Java method that does the following: "Get IPv6 by name.". |
Of course, here is the Java code you requested:
```java
public static String toSocketAddressString(String host, int port) {
String portStr = String.valueOf(port);
return newSocketAddressStringBuilder(
host, portStr, !isValidIpV6Address(host)).append(':').append(portStr).toString();
... | Create a Java method that does the following: "Converts a host name and port number into a string.". |
Of course, here is the Java code you requested:
```java
public static String toAddressString(InetAddress ip, boolean ipv4Mapped) {
if (ip instanceof Inet4Address) {
return ip.getHostAddress();
}
if (!(ip instanceof Inet6Address)) {
throw new IllegalArgumentException("Unh... | Create a Java method that does the following: "Returns the string representation of the given IP address.". |
Of course, here is the Java code you requested:
```java
public static String getHostname(InetSocketAddress addr) {
return PlatformDependent.javaVersion() >= 7 ? addr.getHostString() : addr.getHostName();
}
```
Hope this helps! | Create a Java method that does the following: "Get the host name of the given address.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public final long sslCtxPointer() {
Lock readerLock = ctxLock.readLock();
readerLock.lock();
try {
return SSLContext.getSslCtx(ctx);
} finally {
readerLock.unlock();
}
}
```
Hope... | Create a Java method that does the following: "Get the pointer of the SSL context.". |
Of course, here is the Java code you requested:
```java
@UnstableApi
public final void setPrivateKeyMethod(OpenSslPrivateKeyMethod method) {
ObjectUtil.checkNotNull(method, "method");
Lock writerLock = ctxLock.writeLock();
writerLock.lock();
try {
SSLContext.setPrivateKe... | Create a Java method that does the following: "Sets the private key method.". |
Of course, here is the Java code you requested:
```java
static long toBIO(ByteBufAllocator allocator, X509Certificate... certChain) throws Exception {
if (certChain == null) {
return 0;
}
if (certChain.length == 0) {
throw new IllegalArgumentException("certChain can't b... | Create a Java method that does the following: "Convert a list of X509Certificate to a BIO.". |
Of course, here is the Java code you requested:
```java
static OpenSslKeyMaterialProvider providerFor(KeyManagerFactory factory, String password) {
if (factory instanceof OpenSslX509KeyManagerFactory) {
return ((OpenSslX509KeyManagerFactory) factory).newProvider();
}
X509KeyManager... | Create a Java method that does the following: "Returns a new OpenSslKeyMaterialProvider based on the key manager factory.". |
Of course, here is the Java code you requested:
```java
public static String stackTraceToString(Throwable cause) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream pout = new PrintStream(out);
cause.printStackTrace(pout);
pout.flush();
try {
retur... | Create a Java method that does the following: "This method is used to get a stack trace string from a Throwable.". |
Of course, here is the Java code you requested:
```java
public void addFlush() {
// There is no need to process all entries if there was already a flush before and no new messages
// where added in the meantime.
//
// See https://github.com/netty/netty/issues/2577
Entry entry = ... | Create a Java method that does the following: "Add a flush to the log.". |
Of course, here is the Java code you requested:
```java
public Object current() {
Entry entry = flushedEntry;
if (entry == null) {
return null;
}
return entry.msg;
}
```
Hope this helps! | Create a Java method that does the following: "Returns the current message.". |
Of course, here is the Java code you requested:
```java
public ByteBuffer[] nioBuffers(int maxCount, long maxBytes) {
assert maxCount > 0;
assert maxBytes > 0;
long nioBufferSize = 0;
int nioBufferCount = 0;
final InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.ge... | Create a Java method that does the following: "Returns an array of NIO buffers that can be used to write the data in the buffer.". |
Of course, here is the Java code you requested:
```java
public String applicationProtocol() {
SSLEngine engine = engine();
if (!(engine instanceof ApplicationProtocolAccessor)) {
return null;
}
return ((ApplicationProtocolAccessor) engine).getNegotiatedApplicationProtocol()... | Create a Java method that does the following: "Returns the application protocol of this session.". |
Of course, here is the Java code you requested:
```java
private void wrap(ChannelHandlerContext ctx, boolean inUnwrap) throws SSLException {
ByteBuf out = null;
ChannelPromise promise = null;
ByteBufAllocator alloc = ctx.alloc();
boolean needUnwrap = false;
ByteBuf buf = null;
... | Create a Java method that does the following: "Wrap the handler.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.