code stringlengths 146 466k | prompt stringlengths 54 1.5k |
|---|---|
Of course, here is the Java code you requested:
```java
public static boolean isEncrypted(ByteBuf buffer) {
if (buffer.readableBytes() < SslUtils.SSL_RECORD_HEADER_LENGTH) {
throw new IllegalArgumentException(
"buffer must have at least " + SslUtils.SSL_RECORD_HEADER_LENGTH + " ... | Create a Java method that does the following: "Checks if the buffer contains encrypted data.". |
Of course, here is the Java code you requested:
```java
private void setHandshakeSuccess() {
handshakePromise.trySuccess(ctx.channel());
if (logger.isDebugEnabled()) {
logger.debug("{} HANDSHAKEN: {}", ctx.channel(), engine.getSession().getCipherSuite());
}
ctx.fireUserEven... | Create a Java method that does the following: "Set the handshake success event.". |
Of course, here is the Java code you requested:
```java
private void setHandshakeFailure(ChannelHandlerContext ctx, Throwable cause) {
setHandshakeFailure(ctx, cause, true, true, false);
}
```
Hope this helps! | Create a Java method that does the following: "Set the handshake failure.". |
Of course, here is the Java code you requested:
```java
private void setHandshakeFailure(ChannelHandlerContext ctx, Throwable cause, boolean closeInbound,
boolean notify, boolean alwaysFlushAndClose) {
try {
// Release all resources such as internal buffers that... | Create a Java method that does the following: "Set the handshake failure flag.". |
Of course, here is the Java code you requested:
```java
@Override
public InterfaceHttpData getBodyHttpData(String name) {
checkDestroyed();
if (!isLastChunk) {
throw new NotEnoughDataDecoderException();
}
List<InterfaceHttpData> list = bodyMapHttpData.get(name);
... | Create a Java method that does the following: "Gets the body http data.". |
Of course, here is the Java code you requested:
```java
@Override
public boolean hasNext() {
checkDestroyed();
if (currentStatus == MultiPartStatus.EPILOGUE) {
// OK except if end of list
if (bodyListHttpDataRank >= bodyListHttpData.size()) {
throw new EndOf... | Create a Java method that does the following: "Returns true if the MultiPart has more data.". |
Of course, here is the Java code you requested:
```java
private void parseBodyAttributes() {
if (!undecodedChunk.hasArray()) {
parseBodyAttributesStandard();
return;
}
SeekAheadOptimize sao = new SeekAheadOptimize(undecodedChunk);
int firstpos = undecodedChunk.re... | Create a Java method that does the following: "Parse the body attributes.". |
Of course, here is the Java code you requested:
```java
@Override
public void destroy() {
// Release all data items, including those not yet pulled
cleanFiles();
destroyed = true;
if (undecodedChunk != null && undecodedChunk.refCnt() > 0) {
undecodedChunk.release();
... | Create a Java method that does the following: "Destroy the base class.". |
Of course, here is the Java code you requested:
```java
public void setTicketKeys(OpenSslSessionTicketKey... keys) {
ObjectUtil.checkNotNull(keys, "keys");
SessionTicketKey[] ticketKeys = new SessionTicketKey[keys.length];
for (int i = 0; i < ticketKeys.length; i++) {
ticketKeys[i] ... | Create a Java method that does the following: "Set the session ticket keys.". |
Of course, here is the Java code you requested:
```java
@Skip
@Override
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress,
ChannelPromise promise) throws Exception {
ctx.bind(localAddress, promise);
}
```
Hope this helps! | Create a Java method that does the following: "Override this method to bind to a local address.". |
Of course, here is the Java code you requested:
```java
static int findNonWhitespace(String sb, int offset) {
int result;
for (result = offset; result < sb.length(); result ++) {
if (!Character.isWhitespace(sb.charAt(result))) {
break;
}
}
return ... | Create a Java method that does the following: "Find the first non - whitespace character in the string.". |
Of course, here is the Java code you requested:
```java
protected final void clearReadPending() {
if (isRegistered()) {
EventLoop eventLoop = eventLoop();
if (eventLoop.inEventLoop()) {
readPending = false;
} else {
eventLoop.execute(clearRead... | Create a Java method that does the following: "Clear the readPending flag.". |
Of course, here is the Java code you requested:
```java
protected EmbeddedChannel newContentDecompressor(final ChannelHandlerContext ctx, CharSequence contentEncoding)
throws Http2Exception {
if (GZIP.contentEqualsIgnoreCase(contentEncoding) || X_GZIP.contentEqualsIgnoreCase(contentEncoding)) {
... | Create a Java method that does the following: "Create an EmbeddedChannel based on the content encoding.". |
Of course, here is the Java code you requested:
```java
private void initDecompressor(ChannelHandlerContext ctx, int streamId, Http2Headers headers, boolean endOfStream)
throws Http2Exception {
final Http2Stream stream = connection.stream(streamId);
if (stream == null) {
return;... | Create a Java method that does the following: "Initialize the decompressor.". |
Of course, here is the Java code you requested:
```java
public static HttpResponseStatus valueOf(int code) {
HttpResponseStatus status = valueOf0(code);
return status != null ? status : new HttpResponseStatus(code);
}
```
Hope this helps! | Create a Java method that does the following: "Gets a new instance of the class with the specified HTTP status code.". |
Of course, here is the Java code you requested:
```java
public static HttpResponseStatus valueOf(int code, String reasonPhrase) {
HttpResponseStatus responseStatus = valueOf0(code);
return responseStatus != null && responseStatus.reasonPhrase().contentEquals(reasonPhrase) ? responseStatus :
... | Create a Java method that does the following: "Gets a new instance of the class with the specified HTTP status code and reason phrase.". |
Of course, here is the Java code you requested:
```java
private static String readString(String fieldName, ByteBuf in) {
int length = in.bytesBefore(MAX_FIELD_LENGTH + 1, (byte) 0);
if (length < 0) {
throw new DecoderException("field '" + fieldName + "' longer than " + MAX_FIELD_LENGTH + " ... | Create a Java method that does the following: "Read a string from the buffer.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("UnusedParameters")
protected ByteBuf extractObject(ChannelHandlerContext ctx, ByteBuf buffer, int index, int length) {
return buffer.retainedSlice(index, length);
}
```
Hope this helps! | Create a Java method that does the following: "Extract the object from the buffer.". |
Of course, here is the Java code you requested:
```java
public static String get(final String key, String def) {
if (key == null) {
throw new NullPointerException("key");
}
if (key.isEmpty()) {
throw new IllegalArgumentException("key must not be empty.");
}
... | Create a Java method that does the following: "Get a system property value.". |
Of course, here is the Java code you requested:
```java
public static int getInt(String key, int def) {
String value = get(key);
if (value == null) {
return def;
}
value = value.trim();
try {
return Integer.parseInt(value);
} catch (Exception e) ... | Create a Java method that does the following: "Get the integer system property value.". |
Of course, here is the Java code you requested:
```java
public static long getLong(String key, long def) {
String value = get(key);
if (value == null) {
return def;
}
value = value.trim();
try {
return Long.parseLong(value);
} catch (Exception e)... | Create a Java method that does the following: "Gets the long system property.". |
Of course, here is the Java code you requested:
```java
@Override
public void channelHandlerContext(ChannelHandlerContext ctx) throws Http2Exception {
this.ctx = checkNotNull(ctx, "ctx");
// Writing the pending bytes will not check writability change and instead a writability change notification
... | Create a Java method that does the following: "Called by the Http2ServerChannelHandler interface to notify the channel that a context has been set.". |
Of course, here is the Java code you requested:
```java
private static int compressionLevel(int blockSize) {
if (blockSize < MIN_BLOCK_SIZE || blockSize > MAX_BLOCK_SIZE) {
throw new IllegalArgumentException(String.format(
"blockSize: %d (expected: %d-%d)", blockSize, MIN_BLOCK_... | Create a Java method that does the following: "Get the compression level of a block size.". |
Of course, here is the Java code you requested:
```java
protected void writeTimedOut(ChannelHandlerContext ctx) throws Exception {
if (!closed) {
ctx.fireExceptionCaught(WriteTimeoutException.INSTANCE);
ctx.close();
closed = true;
}
}
```
Hope this helps! | Create a Java method that does the following: "Called when a write timeout occurs.". |
Of course, here is the Java code you requested:
```java
protected final int doReadBytes(ByteBuf byteBuf) throws Exception {
int writerIndex = byteBuf.writerIndex();
int localReadAmount;
unsafe().recvBufAllocHandle().attemptedBytesRead(byteBuf.writableBytes());
if (byteBuf.hasMemoryAddre... | Create a Java method that does the following: "Read bytes from the socket.". |
Of course, here is the Java code you requested:
```java
protected boolean doConnect(SocketAddress remoteAddress, SocketAddress localAddress) throws Exception {
if (localAddress instanceof InetSocketAddress) {
checkResolvable((InetSocketAddress) localAddress);
}
InetSocketAddress re... | Create a Java method that does the following: "Connect to the remote server.". |
Of course, here is the Java code you requested:
```java
public final Http2FrameStream newStream() {
Http2FrameCodec codec = frameCodec;
if (codec == null) {
throw new IllegalStateException(StringUtil.simpleClassName(Http2FrameCodec.class) + " not found." +
" Has the hand... | Create a Java method that does the following: "Returns a new stream for this handler.". |
Of course, here is the Java code you requested:
```java
@Override
protected Future<SslContext> lookup(ChannelHandlerContext ctx, String hostname) throws Exception {
return mapping.map(hostname, ctx.executor().<SslContext>newPromise());
}
```
Hope this helps! | Create a Java method that does the following: "Lookup a node using the node mapping.". |
Of course, here is the Java code you requested:
```java
public static CharsetDecoder decoder(Charset charset, CodingErrorAction malformedInputAction,
CodingErrorAction unmappableCharacterAction) {
checkNotNull(charset, "charset");
CharsetDecoder d = charset.newD... | Create a Java method that does the following: "Gets a CharsetDecoder instance.". |
Of course, here is the Java code you requested:
```java
protected final void removeMessage(Http2Stream stream, boolean release) {
FullHttpMessage msg = stream.removeProperty(messageKey);
if (release && msg != null) {
msg.release();
}
}
```
Hope this helps! | Create a Java method that does the following: "Remove the message from the stream.". |
Of course, here is the Java code you requested:
```java
protected final void putMessage(Http2Stream stream, FullHttpMessage message) {
FullHttpMessage previous = stream.setProperty(messageKey, message);
if (previous != message && previous != null) {
previous.release();
}
}
```
... | Create a Java method that does the following: "Put the message into the stream.". |
Of course, here is the Java code you requested:
```java
protected FullHttpMessage newMessage(Http2Stream stream, Http2Headers headers, boolean validateHttpHeaders,
ByteBufAllocator alloc)
throws Http2Exception {
return connection.isServer() ? HttpConversionU... | Create a Java method that does the following: "Create a new message.". |
Of course, here is the Java code you requested:
```java
private void processHeadersEnd(ChannelHandlerContext ctx, Http2Stream stream, FullHttpMessage msg,
boolean endOfStream) {
if (endOfStream) {
// Release if the msg from the map is different from the object bei... | Create a Java method that does the following: "Process the end of headers.". |
Of course, here is the Java code you requested:
```java
static List<HpackHeader> headers(HpackHeadersSize size, boolean limitToAscii) {
return headersMap.get(new HeadersKey(size, limitToAscii));
}
```
Hope this helps! | Create a Java method that does the following: "Get the headers.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <T> ChannelOption<T> valueOf(String name) {
return (ChannelOption<T>) pool.valueOf(name);
}
```
Hope this helps! | Create a Java method that does the following: "Get a channel option from the name.". |
Of course, here is the Java code you requested:
```java
OpenSslKeyMaterial chooseKeyMaterial(ByteBufAllocator allocator, String alias) throws Exception {
X509Certificate[] certificates = keyManager.getCertificateChain(alias);
if (certificates == null || certificates.length == 0) {
return nu... | Create a Java method that does the following: "Get the OpenSslKeyMaterial for the given alias.". |
Of course, here is the Java code you requested:
```java
protected final int doWrite0(ChannelOutboundBuffer in) throws Exception {
Object msg = in.current();
if (msg == null) {
// Directly return here so incompleteWrite(...) is not called.
return 0;
}
return doWri... | Create a Java method that does the following: "Write a single record to the channel.". |
Of course, here is the Java code you requested:
```java
public static ResolvedAddressTypes computeResolvedAddressTypes(InternetProtocolFamily... internetProtocolFamilies) {
if (internetProtocolFamilies == null || internetProtocolFamilies.length == 0) {
return DnsNameResolver.DEFAULT_RESOLVE_ADDRESS... | Create a Java method that does the following: "Compute the resolved address types from the Internet Protocol Family array.". |
Of course, here is the Java code you requested:
```java
public DnsNameResolver build() {
if (eventLoop == null) {
throw new IllegalStateException("eventLoop should be specified to build a DnsNameResolver.");
}
if (resolveCache != null && (minTtl != null || maxTtl != null || negativ... | Create a Java method that does the following: "Build a DnsNameResolver.". |
Of course, here is the Java code you requested:
```java
public static HttpMethod valueOf(String name) {
HttpMethod result = methodMap.get(name);
return result != null ? result : new HttpMethod(name);
}
```
Hope this helps! | Create a Java method that does the following: "Returns a HttpMethod object for the given name.". |
Of course, here is the Java code you requested:
```java
protected T build() {
final T instance;
try {
instance = build(connection(), maxContentLength(),
isValidateHttpHeaders(), isPropagateSettings());
} catch (Throwable t) {
throw ne... | Create a Java method that does the following: "Build the HTTP2ToHttpAdapter.". |
Of course, here is the Java code you requested:
```java
@Override
protected void encode(ChannelHandlerContext ctx, HttpObject obj, List<Object> out) throws Exception {
// 100-continue is typically a FullHttpResponse, but the decoded
// Http2HeadersFrame should not be marked as endStream=true
... | Create a Java method that does the following: "Encode a HttpObject into a List of objects.". |
Of course, here is the Java code you requested:
```java
@Override
public Http2FrameCodec build() {
Http2FrameWriter frameWriter = this.frameWriter;
if (frameWriter != null) {
// This is to support our tests and will never be executed by the user as frameWriter(...)
// is pac... | Create a Java method that does the following: "Build the Http2FrameCodec.". |
Of course, here is the Java code you requested:
```java
private Future<Channel> acquireHealthyFromPoolOrNew(final Promise<Channel> promise) {
try {
final Channel ch = pollChannel();
if (ch == null) {
// No Channel left in the pool bootstrap a new Channel
... | Create a Java method that does the following: "Acquires a healthy channel from the pool or creates a new one.". |
Of course, here is the Java code you requested:
```java
private void releaseAndOfferIfHealthy(Channel channel, Promise<Void> promise, Future<Boolean> future)
throws Exception {
if (future.getNow()) { //channel turns out to be healthy, offering and releasing it.
releaseAndOffer(channel, ... | Create a Java method that does the following: "Release the resource if healthy.". |
Of course, here is the Java code you requested:
```java
public byte[] toByteArray(int start, int end) {
return Arrays.copyOfRange(value, start + offset, end + offset);
}
```
Hope this helps! | Create a Java method that does the following: "Returns a byte array containing the specified range of the value.". |
Of course, here is the Java code you requested:
```java
public void copy(int srcIdx, byte[] dst, int dstIdx, int length) {
if (isOutOfBounds(srcIdx, length, length())) {
throw new IndexOutOfBoundsException("expected: " + "0 <= srcIdx(" + srcIdx + ") <= srcIdx + length("
... | Create a Java method that does the following: "Copy the contents of this array into the specified byte array.". |
Of course, here is the Java code you requested:
```java
@Override
public int compareTo(CharSequence string) {
if (this == string) {
return 0;
}
int result;
int length1 = length();
int length2 = string.length();
int minLength = Math.min(length1, length2);... | Create a Java method that does the following: "Compare this sequence to another sequence.". |
Of course, here is the Java code you requested:
```java
public AsciiString concat(CharSequence string) {
int thisLen = length();
int thatLen = string.length();
if (thatLen == 0) {
return this;
}
if (string.getClass() == AsciiString.class) {
AsciiString t... | Create a Java method that does the following: "concat this string with another string.". |
Of course, here is the Java code you requested:
```java
public boolean endsWith(CharSequence suffix) {
int suffixLen = suffix.length();
return regionMatches(length() - suffixLen, suffix, 0, suffixLen);
}
```
Hope this helps! | Create a Java method that does the following: "Returns true if this sequence ends with the specified sequence.". |
Of course, here is the Java code you requested:
```java
public AsciiString subSequence(int start, int end, boolean copy) {
if (isOutOfBounds(start, end - start, length())) {
throw new IndexOutOfBoundsException("expected: 0 <= start(" + start + ") <= end (" + end + ") <= length("
... | Create a Java method that does the following: "Returns a subsequence of this string.". |
Of course, here is the Java code you requested:
```java
public int indexOf(char ch, int start) {
if (ch > MAX_CHAR_VALUE) {
return INDEX_NOT_FOUND;
}
if (start < 0) {
start = 0;
}
final byte chAsByte = c2b0(ch);
final int len = offset + length;
... | Create a Java method that does the following: "Gets the index of the specified character in this array.". |
Of course, here is the Java code you requested:
```java
public boolean regionMatches(int thisStart, CharSequence string, int start, int length) {
if (string == null) {
throw new NullPointerException("string");
}
if (start < 0 || string.length() - start < length) {
retur... | Create a Java method that does the following: "regionMatches This method checks if the specified string region matches this string.". |
Of course, here is the Java code you requested:
```java
public AsciiString toLowerCase() {
boolean lowercased = true;
int i, j;
final int len = length() + arrayOffset();
for (i = arrayOffset(); i < len; ++i) {
byte b = value[i];
if (b >= 'A' && b <= 'Z') {
... | Create a Java method that does the following: "Returns a new string that is lower cased.". |
Of course, here is the Java code you requested:
```java
public static CharSequence trim(CharSequence c) {
if (c.getClass() == AsciiString.class) {
return ((AsciiString) c).trim();
}
if (c instanceof String) {
return ((String) c).trim();
}
int start = 0, l... | Create a Java method that does the following: "Trims a CharSequence.". |
Of course, here is the Java code you requested:
```java
public AsciiString trim() {
int start = arrayOffset(), last = arrayOffset() + length() - 1;
int end = last;
while (start <= end && value[start] <= ' ') {
start++;
}
while (end >= start && value[end] <= ' ') {
... | Create a Java method that does the following: "Trims the contents of this string.". |
Of course, here is the Java code you requested:
```java
public static AsciiString of(CharSequence string) {
return string.getClass() == AsciiString.class ? (AsciiString) string : new AsciiString(string);
}
```
Hope this helps! | Create a Java method that does the following: "Create a new instance of the given string.". |
Of course, here is the Java code you requested:
```java
public static AsciiString cached(String string) {
AsciiString asciiString = new AsciiString(string);
asciiString.string = string;
return asciiString;
}
```
Hope this helps! | Create a Java method that does the following: "Create a cached ASCII string from the given string.". |
Of course, here is the Java code you requested:
```java
public static boolean contains(CharSequence a, CharSequence b) {
return contains(a, b, DefaultCharEqualityComparator.INSTANCE);
}
```
Hope this helps! | Create a Java method that does the following: "Returns true if the two CharSequences are contained in the source.". |
Of course, here is the Java code you requested:
```java
public static boolean containsIgnoreCase(CharSequence a, CharSequence b) {
return contains(a, b, AsciiCaseInsensitiveCharEqualityComparator.INSTANCE);
}
```
Hope this helps! | Create a Java method that does the following: "Checks if the given CharSequences are case insensitive.". |
Of course, here is the Java code you requested:
```java
public static boolean contentEqualsIgnoreCase(CharSequence a, CharSequence b) {
if (a == null || b == null) {
return a == b;
}
if (a.getClass() == AsciiString.class) {
return ((AsciiString) a).contentEqualsIgnoreCa... | Create a Java method that does the following: "contentEqualsIgnoreCase Method.". |
Of course, here is the Java code you requested:
```java
public static boolean containsContentEqualsIgnoreCase(Collection<CharSequence> collection, CharSequence value) {
for (CharSequence v : collection) {
if (contentEqualsIgnoreCase(value, v)) {
return true;
}
}
... | Create a Java method that does the following: "Contains contentEqualsIgnoreCase This method checks if a Collection of CharSequences contains a CharSequence value.". |
Of course, here is the Java code you requested:
```java
public static boolean containsAllContentEqualsIgnoreCase(Collection<CharSequence> a, Collection<CharSequence> b) {
for (CharSequence v : b) {
if (!containsContentEqualsIgnoreCase(a, v)) {
return false;
}
}
... | Create a Java method that does the following: "Checks if all CharSequences in Collection are equal ignoring case.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <T> T retain(T msg) {
if (msg instanceof ReferenceCounted) {
return (T) ((ReferenceCounted) msg).retain();
}
return msg;
}
```
Hope this helps! | Create a Java method that does the following: "Retains a reference counted object.". |
Of course, here is the Java code you requested:
```java
@SuppressWarnings("unchecked")
public static <T> T touch(T msg, Object hint) {
if (msg instanceof ReferenceCounted) {
return (T) ((ReferenceCounted) msg).touch(hint);
}
return msg;
}
```
Hope this helps! | Create a Java method that does the following: "touch a message.". |
Of course, here is the Java code you requested:
```java
public static void safeRelease(Object msg) {
try {
release(msg);
} catch (Throwable t) {
logger.warn("Failed to release a message: {}", msg, t);
}
}
```
Hope this helps! | Create a Java method that does the following: "Release a message.". |
Of course, here is the Java code you requested:
```java
@Deprecated
public static <T> T releaseLater(T msg, int decrement) {
if (msg instanceof ReferenceCounted) {
ThreadDeathWatcher.watch(Thread.currentThread(), new ReleasingTask((ReferenceCounted) msg, decrement));
}
return ms... | Create a Java method that does the following: "Release the message after a given amount of time.". |
Of course, here is the Java code you requested:
```java
static List<String> parseEtcResolverSearchDomains(File etcResolvConf) throws IOException {
String localDomain = null;
List<String> searchDomains = new ArrayList<String>();
FileReader fr = new FileReader(etcResolvConf);
BufferedRea... | Create a Java method that does the following: "Parses the etcResolvConf file to get the list of search domains.". |
Of course, here is the Java code you requested:
```java
static List<HpackHeader> createHeaders(int numHeaders, int nameLength, int valueLength,
boolean limitToAscii) {
List<HpackHeader> hpackHeaders = new ArrayList<HpackHeader>(numHeaders);
for (int i = 0; i <... | Create a Java method that does the following: "Create a list of HpackHeaders.". |
Of course, here is the Java code you requested:
```java
public void configure(long newWriteLimit, long newReadLimit) {
writeLimit = newWriteLimit;
readLimit = newReadLimit;
if (trafficCounter != null) {
trafficCounter.resetAccounting(TrafficCounter.milliSecondFromNano());
}
... | Create a Java method that does the following: "Sets the write and read limits for this class.". |
Of course, here is the Java code you requested:
```java
public void setWriteLimit(long writeLimit) {
this.writeLimit = writeLimit;
if (trafficCounter != null) {
trafficCounter.resetAccounting(TrafficCounter.milliSecondFromNano());
}
}
```
Hope this helps! | Create a Java method that does the following: "Sets the write limit.". |
Of course, here is the Java code you requested:
```java
public void setReadLimit(long readLimit) {
this.readLimit = readLimit;
if (trafficCounter != null) {
trafficCounter.resetAccounting(TrafficCounter.milliSecondFromNano());
}
}
```
Hope this helps! | Create a Java method that does the following: "Sets the readLimit value.". |
Of course, here is the Java code you requested:
```java
void releaseReadSuspended(ChannelHandlerContext ctx) {
Channel channel = ctx.channel();
channel.attr(READ_SUSPENDED).set(false);
channel.config().setAutoRead(true);
}
```
Hope this helps! | Create a Java method that does the following: "Release read suspended flag.". |
Of course, here is the Java code you requested:
```java
void checkWriteSuspend(ChannelHandlerContext ctx, long delay, long queueSize) {
if (queueSize > maxWriteSize || delay > maxWriteDelay) {
setUserDefinedWritability(ctx, false);
}
}
```
Hope this helps! | Create a Java method that does the following: "Check if write suspend is allowed.". |
Of course, here is the Java code you requested:
```java
public DomainMappingBuilder<V> add(String hostname, V output) {
builder.add(hostname, output);
return this;
}
```
Hope this helps! | Create a Java method that does the following: "Add a new domain mapping to the domain mapping.". |
Of course, here is the Java code you requested:
```java
@Override
public void info(String format, Object arg) {
if (logger.isInfoEnabled()) {
FormattingTuple ft = MessageFormatter.format(format, arg);
logger.info(ft.getMessage(), ft.getThrowable());
}
}
```
Hope this he... | Create a Java method that does the following: "Log a message at the INFO level.". |
Of course, here is the Java code you requested:
```java
@Override
public void warn(String format, Object arg) {
if (logger.isWarnEnabled()) {
FormattingTuple ft = MessageFormatter.format(format, arg);
logger.warn(ft.getMessage(), ft.getThrowable());
}
}
```
Hope this he... | Create a Java method that does the following: "Log a warning message with a throwable.". |
Of course, here is the Java code you requested:
```java
@Override
public void error(String format, Object... arguments) {
if (logger.isErrorEnabled()) {
FormattingTuple ft = MessageFormatter.arrayFormat(format, arguments);
logger.error(ft.getMessage(), ft.getThrowable());
}
... | Create a Java method that does the following: "Log an error message with the specified arguments.". |
Of course, here is the Java code you requested:
```java
static HAProxyMessage decodeHeader(String header) {
if (header == null) {
throw new HAProxyProtocolException("header");
}
String[] parts = header.split(" ");
int numParts = parts.length;
if (numParts < 2) {
... | Create a Java method that does the following: "Decode a header string.". |
Of course, here is the Java code you requested:
```java
private static int portStringToInt(String value) {
int port;
try {
port = Integer.parseInt(value);
} catch (NumberFormatException e) {
throw new HAProxyProtocolException("invalid port: " + value, e);
}
... | Create a Java method that does the following: "Convert a string representation of a port number to an int.". |
Of course, here is the Java code you requested:
```java
private static void checkAddress(String address, AddressFamily addrFamily) {
if (addrFamily == null) {
throw new NullPointerException("addrFamily");
}
switch (addrFamily) {
case AF_UNSPEC:
if (addre... | Create a Java method that does the following: "checkAddress is called to check if the address is valid for the given address family". |
Of course, here is the Java code you requested:
```java
public static HttpResponseStatus parseStatus(CharSequence status) throws Http2Exception {
HttpResponseStatus result;
try {
result = parseLine(status);
if (result == HttpResponseStatus.SWITCHING_PROTOCOLS) {
... | Create a Java method that does the following: "Parses the status code from the given status line.". |
Of course, here is the Java code you requested:
```java
public static HttpResponse toHttpResponse(final int streamId,
final Http2Headers http2Headers,
final boolean validateHttpHeaders) throws Http2Exception {
final Htt... | Create a Java method that does the following: "Converts a Http2 headers object to a HTTP response object.". |
Of course, here is the Java code you requested:
```java
public static Http2Headers toHttp2Headers(HttpMessage in, boolean validateHeaders) {
HttpHeaders inHeaders = in.headers();
final Http2Headers out = new DefaultHttp2Headers(validateHeaders, inHeaders.size());
if (in instanceof HttpRequest) ... | Create a Java method that does the following: "Converts a message to a Http2Headers object.". |
Of course, here is the Java code you requested:
```java
static int majorVersion(final String javaSpecVersion) {
final String[] components = javaSpecVersion.split("\\.");
final int[] version = new int[components.length];
for (int i = 0; i < components.length; i++) {
version[i] = Inte... | Create a Java method that does the following: "Get the major version of the class.". |
Of course, here is the Java code you requested:
```java
public static boolean isOutOfBounds(int index, int length, int capacity) {
return (index | length | (index + length) | (capacity - (index + length))) < 0;
}
```
Hope this helps! | Create a Java method that does the following: "Checks if the index is out of bounds.". |
Of course, here is the Java code you requested:
```java
private static int findNodesToRelocate(final int[] array, final int maximumLength) {
int currentNode = array.length - 2;
for (int currentDepth = 1; currentDepth < maximumLength - 1 && currentNode > 1; currentDepth++) {
currentNode = f... | Create a Java method that does the following: "Find nodes to relocate.". |
Of course, here is the Java code you requested:
```java
private static void allocateNodeLengths(final int[] array) {
int firstNode = array.length - 2;
int nextNode = array.length - 1;
for (int currentDepth = 1, availableNodes = 2; availableNodes > 0; currentDepth++) {
final int las... | Create a Java method that does the following: "Allocate node lengths.". |
Of course, here is the Java code you requested:
```java
public int statusCode() {
ByteBuf binaryData = content();
if (binaryData == null || binaryData.capacity() == 0) {
return -1;
}
binaryData.readerIndex(0);
int statusCode = binaryData.readShort();
binaryD... | Create a Java method that does the following: "Gets the status code of the response.". |
Of course, here is the Java code you requested:
```java
public String reasonText() {
ByteBuf binaryData = content();
if (binaryData == null || binaryData.capacity() <= 2) {
return "";
}
binaryData.readerIndex(2);
String reasonText = binaryData.toString(CharsetUtil.U... | Create a Java method that does the following: "Returns the text of the exception.". |
Of course, here is the Java code you requested:
```java
public void close() throws IOException {
for (;;) {
int state = this.state;
if (isClosed(state)) {
return;
}
// Once a close operation happens, the channel is considered shutdown.
... | Create a Java method that does the following: "Close the underlying file descriptor.". |
Of course, here is the Java code you requested:
```java
public static FileDescriptor from(String path) throws IOException {
checkNotNull(path, "path");
int res = open(path);
if (res < 0) {
throw newIOException("open", res);
}
return new FileDescriptor(res);
}
```... | Create a Java method that does the following: "Gets a FileDescriptor from the specified path.". |
Of course, here is the Java code you requested:
```java
public static Http2Exception getEmbeddedHttp2Exception(Throwable cause) {
while (cause != null) {
if (cause instanceof Http2Exception) {
return (Http2Exception) cause;
}
cause = cause.getCause();
... | Create a Java method that does the following: "Gets the embedded Http2Exception from a Throwable.". |
Of course, here is the Java code you requested:
```java
public static ByteBuf toByteBuf(ChannelHandlerContext ctx, Throwable cause) {
if (cause == null || cause.getMessage() == null) {
return Unpooled.EMPTY_BUFFER;
}
return ByteBufUtil.writeUtf8(ctx.alloc(), cause.getMessage());
... | Create a Java method that does the following: "Converts a Throwable to a ByteBuf.". |
Of course, here is the Java code you requested:
```java
public static void writeFrameHeader(ByteBuf out, int payloadLength, byte type,
Http2Flags flags, int streamId) {
out.ensureWritable(FRAME_HEADER_LENGTH + payloadLength);
writeFrameHeaderInternal(out, payloadLength, type, flags, streamI... | Create a Java method that does the following: "Write the header of a HTTP2 frame.". |
Of course, here is the Java code you requested:
```java
public static void headerListSizeExceeded(int streamId, long maxHeaderListSize,
boolean onDecode) throws Http2Exception {
throw headerListSizeError(streamId, PROTOCOL_ERROR, onDecode, "Header size exceeded max... | Create a Java method that does the following: "Thrown when the header list size exceeded.". |
Of course, here is the Java code you requested:
```java
protected static void notifyListener(
EventExecutor eventExecutor, final Future<?> future, final GenericFutureListener<?> listener) {
checkNotNull(eventExecutor, "eventExecutor");
checkNotNull(future, "future");
checkNotNull(li... | Create a Java method that does the following: "Notify a GenericFutureListener with a stack over flow protection.". |
Of course, here is the Java code you requested:
```java
private synchronized Object progressiveListeners() {
Object listeners = this.listeners;
if (listeners == null) {
// No listeners added
return null;
}
if (listeners instanceof DefaultFutureListeners) {
... | Create a Java method that does the following: "Get the progressive listeners.". |
Of course, here is the Java code you requested:
```java
protected final void init(I inboundHandler, O outboundHandler) {
validate(inboundHandler, outboundHandler);
this.inboundHandler = inboundHandler;
this.outboundHandler = outboundHandler;
}
```
Hope this helps! | Create a Java method that does the following: "Initializes the class.". |
Of course, here is the Java code you requested:
```java
public static boolean commonSuffixOfLength(String s, String p, int len) {
return s != null && p != null && len >= 0 && s.regionMatches(s.length() - len, p, p.length() - len, len);
}
```
Hope this helps! | Create a Java method that does the following: "Returns true if s and p are common suffixes of the given length.". |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.