idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
13,900 | public boolean hasNext ( ) { checkDestroyed ( ) ; if ( currentStatus == MultiPartStatus . EPILOGUE ) { if ( bodyListHttpDataRank >= bodyListHttpData . size ( ) ) { throw new EndOfDataDecoderException ( ) ; } } return ! bodyListHttpData . isEmpty ( ) && bodyListHttpDataRank < bodyListHttpData . size ( ) ; } | True if at current getStatus there is an available decoded InterfaceHttpData from the Body . |
13,901 | protected void addHttpData ( InterfaceHttpData data ) { if ( data == null ) { return ; } List < InterfaceHttpData > datas = bodyMapHttpData . get ( data . getName ( ) ) ; if ( datas == null ) { datas = new ArrayList < InterfaceHttpData > ( 1 ) ; bodyMapHttpData . put ( data . getName ( ) , datas ) ; } datas . add ( data ) ; bodyListHttpData . add ( data ) ; } | Utility function to add a new decoded data |
13,902 | static int findNonWhitespace ( String sb , int offset ) { int result ; for ( result = offset ; result < sb . length ( ) ; result ++ ) { if ( ! Character . isWhitespace ( sb . charAt ( result ) ) ) { break ; } } return result ; } | Find the first non whitespace |
13,903 | static int findEndOfString ( String sb ) { int result ; for ( result = sb . length ( ) ; result > 0 ; result -- ) { if ( ! Character . isWhitespace ( sb . charAt ( result - 1 ) ) ) { break ; } } return result ; } | Find the end of String |
13,904 | public void start ( ) { switch ( WORKER_STATE_UPDATER . get ( this ) ) { case WORKER_STATE_INIT : if ( WORKER_STATE_UPDATER . compareAndSet ( this , WORKER_STATE_INIT , WORKER_STATE_STARTED ) ) { workerThread . start ( ) ; } break ; case WORKER_STATE_STARTED : break ; case WORKER_STATE_SHUTDOWN : throw new IllegalStateException ( "cannot be started once stopped" ) ; default : throw new Error ( "Invalid WorkerState" ) ; } while ( startTime == 0 ) { try { startTimeInitialized . await ( ) ; } catch ( InterruptedException ignore ) { } } } | Starts the background thread explicitly . The background thread will start automatically on demand even if you did not call this method . |
13,905 | 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 + " chars" ) ; } String value = in . readSlice ( length ) . toString ( CharsetUtil . US_ASCII ) ; in . skipBytes ( 1 ) ; return value ; } | Reads a variable - length NUL - terminated string as defined in SOCKS4 . |
13,906 | long allocate ( ) { if ( elemSize == 0 ) { return toHandle ( 0 ) ; } if ( numAvail == 0 || ! doNotDestroy ) { return - 1 ; } final int bitmapIdx = getNextAvail ( ) ; int q = bitmapIdx >>> 6 ; int r = bitmapIdx & 63 ; assert ( bitmap [ q ] >>> r & 1 ) == 0 ; bitmap [ q ] |= 1L << r ; if ( -- numAvail == 0 ) { removeFromPool ( ) ; } return toHandle ( bitmapIdx ) ; } | Returns the bitmap index of the subpage allocation . |
13,907 | 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_SIZE , MAX_BLOCK_SIZE ) ) ; } int compressionLevel = 32 - Integer . numberOfLeadingZeros ( blockSize - 1 ) ; compressionLevel = Math . max ( 0 , compressionLevel - COMPRESSION_LEVEL_BASE ) ; return compressionLevel ; } | Calculates compression level on the basis of block size . |
13,908 | protected void writeTimedOut ( ChannelHandlerContext ctx ) throws Exception { if ( ! closed ) { ctx . fireExceptionCaught ( WriteTimeoutException . INSTANCE ) ; ctx . close ( ) ; closed = true ; } } | Is called when a write timeout was detected |
13,909 | protected boolean doConnect ( SocketAddress remoteAddress , SocketAddress localAddress ) throws Exception { if ( localAddress instanceof InetSocketAddress ) { checkResolvable ( ( InetSocketAddress ) localAddress ) ; } InetSocketAddress remoteSocketAddr = remoteAddress instanceof InetSocketAddress ? ( InetSocketAddress ) remoteAddress : null ; if ( remoteSocketAddr != null ) { checkResolvable ( remoteSocketAddr ) ; } if ( remote != null ) { throw new AlreadyConnectedException ( ) ; } if ( localAddress != null ) { socket . bind ( localAddress ) ; } boolean connected = doConnect0 ( remoteAddress ) ; if ( connected ) { remote = remoteSocketAddr == null ? remoteAddress : computeRemoteAddr ( remoteSocketAddr , socket . remoteAddress ( ) ) ; } local = socket . localAddress ( ) ; return connected ; } | Connect to the remote peer |
13,910 | static String base64 ( byte [ ] data ) { ByteBuf encodedData = Unpooled . wrappedBuffer ( data ) ; ByteBuf encoded = Base64 . encode ( encodedData ) ; String encodedString = encoded . toString ( CharsetUtil . UTF_8 ) ; encoded . release ( ) ; return encodedString ; } | Performs base64 encoding on the specified data |
13,911 | static int randomNumber ( int minimum , int maximum ) { assert minimum < maximum ; double fraction = PlatformDependent . threadLocalRandom ( ) . nextDouble ( ) ; return ( int ) ( minimum + fraction * ( maximum - minimum ) ) ; } | Generates a pseudo - random number |
13,912 | protected final void removeMessage ( Http2Stream stream , boolean release ) { FullHttpMessage msg = stream . removeProperty ( messageKey ) ; if ( release && msg != null ) { msg . release ( ) ; } } | The stream is out of scope for the HTTP message flow and will no longer be tracked |
13,913 | protected void fireChannelRead ( ChannelHandlerContext ctx , FullHttpMessage msg , boolean release , Http2Stream stream ) { removeMessage ( stream , release ) ; HttpUtil . setContentLength ( msg , msg . content ( ) . readableBytes ( ) ) ; ctx . fireChannelRead ( msg ) ; } | Set final headers and fire a channel read event |
13,914 | protected final int doWrite0 ( ChannelOutboundBuffer in ) throws Exception { Object msg = in . current ( ) ; if ( msg == null ) { return 0 ; } return doWriteInternal ( in , in . current ( ) ) ; } | Write objects to the OS . |
13,915 | public DnsNameResolverBuilder searchDomains ( Iterable < String > searchDomains ) { checkNotNull ( searchDomains , "searchDomains" ) ; final List < String > list = new ArrayList < String > ( 4 ) ; for ( String f : searchDomains ) { if ( f == null ) { break ; } if ( list . contains ( f ) ) { continue ; } list . add ( f ) ; } this . searchDomains = list . toArray ( new String [ 0 ] ) ; return this ; } | Set the list of search domains of the resolver . |
13,916 | static InternalLogger wrapLogger ( Logger logger ) { return logger instanceof LocationAwareLogger ? new LocationAwareSlf4JLogger ( ( LocationAwareLogger ) logger ) : new Slf4JLogger ( logger ) ; } | package - private for testing . |
13,917 | private Future < Channel > acquireHealthyFromPoolOrNew ( final Promise < Channel > promise ) { try { final Channel ch = pollChannel ( ) ; if ( ch == null ) { Bootstrap bs = bootstrap . clone ( ) ; bs . attr ( POOL_KEY , this ) ; ChannelFuture f = connectChannel ( bs ) ; if ( f . isDone ( ) ) { notifyConnect ( f , promise ) ; } else { f . addListener ( new ChannelFutureListener ( ) { public void operationComplete ( ChannelFuture future ) throws Exception { notifyConnect ( future , promise ) ; } } ) ; } return promise ; } EventLoop loop = ch . eventLoop ( ) ; if ( loop . inEventLoop ( ) ) { doHealthCheck ( ch , promise ) ; } else { loop . execute ( new Runnable ( ) { public void run ( ) { doHealthCheck ( ch , promise ) ; } } ) ; } } catch ( Throwable cause ) { promise . tryFailure ( cause ) ; } return promise ; } | Tries to retrieve healthy channel from the pool if any or creates a new channel otherwise . |
13,918 | private void releaseAndOfferIfHealthy ( Channel channel , Promise < Void > promise , Future < Boolean > future ) throws Exception { if ( future . getNow ( ) ) { releaseAndOffer ( channel , promise ) ; } else { handler . channelReleased ( channel ) ; promise . setSuccess ( null ) ; } } | Adds the channel back to the pool only if the channel is healthy . |
13,919 | 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(" + length + ") <= srcLen(" + length ( ) + ')' ) ; } System . arraycopy ( value , srcIdx + offset , checkNotNull ( dst , "dst" ) , dstIdx , length ) ; } | Copies the content of this string to a byte array . |
13,920 | 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 ) ; for ( int i = 0 , j = arrayOffset ( ) ; i < minLength ; i ++ , j ++ ) { result = b2c ( value [ j ] ) - string . charAt ( i ) ; if ( result != 0 ) { return result ; } } return length1 - length2 ; } | Compares the specified string to this string using the ASCII values of the characters . Returns 0 if the strings contain the same characters in the same order . Returns a negative integer if the first non - equal character in this string has an ASCII value which is less than the ASCII value of the character at the same position in the specified string or if this string is a prefix of the specified string . Returns a positive integer if the first non - equal character in this string has a ASCII value which is greater than the ASCII value of the character at the same position in the specified string or if the specified string is a prefix of this string . |
13,921 | public AsciiString concat ( CharSequence string ) { int thisLen = length ( ) ; int thatLen = string . length ( ) ; if ( thatLen == 0 ) { return this ; } if ( string . getClass ( ) == AsciiString . class ) { AsciiString that = ( AsciiString ) string ; if ( isEmpty ( ) ) { return that ; } byte [ ] newValue = PlatformDependent . allocateUninitializedArray ( thisLen + thatLen ) ; System . arraycopy ( value , arrayOffset ( ) , newValue , 0 , thisLen ) ; System . arraycopy ( that . value , that . arrayOffset ( ) , newValue , thisLen , thatLen ) ; return new AsciiString ( newValue , false ) ; } if ( isEmpty ( ) ) { return new AsciiString ( string ) ; } byte [ ] newValue = PlatformDependent . allocateUninitializedArray ( thisLen + thatLen ) ; System . arraycopy ( value , arrayOffset ( ) , newValue , 0 , thisLen ) ; for ( int i = thisLen , j = 0 ; i < newValue . length ; i ++ , j ++ ) { newValue [ i ] = c2b ( string . charAt ( j ) ) ; } return new AsciiString ( newValue , false ) ; } | Concatenates this string and the specified string . |
13,922 | public boolean endsWith ( CharSequence suffix ) { int suffixLen = suffix . length ( ) ; return regionMatches ( length ( ) - suffixLen , suffix , 0 , suffixLen ) ; } | Compares the specified string to this string to determine if the specified string is a suffix . |
13,923 | public boolean contentEqualsIgnoreCase ( CharSequence string ) { if ( string == null || string . length ( ) != length ( ) ) { return false ; } if ( string . getClass ( ) == AsciiString . class ) { AsciiString rhs = ( AsciiString ) string ; for ( int i = arrayOffset ( ) , j = rhs . arrayOffset ( ) ; i < length ( ) ; ++ i , ++ j ) { if ( ! equalsIgnoreCase ( value [ i ] , rhs . value [ j ] ) ) { return false ; } } return true ; } for ( int i = arrayOffset ( ) , j = 0 ; i < length ( ) ; ++ i , ++ j ) { if ( ! equalsIgnoreCase ( b2c ( value [ i ] ) , string . charAt ( j ) ) ) { return false ; } } return true ; } | Compares the specified string to this string ignoring the case of the characters and returns true if they are equal . |
13,924 | public char [ ] toCharArray ( int start , int end ) { int length = end - start ; if ( length == 0 ) { return EmptyArrays . EMPTY_CHARS ; } if ( isOutOfBounds ( start , length , length ( ) ) ) { throw new IndexOutOfBoundsException ( "expected: " + "0 <= start(" + start + ") <= srcIdx + length(" + length + ") <= srcLen(" + length ( ) + ')' ) ; } final char [ ] buffer = new char [ length ] ; for ( int i = 0 , j = start + arrayOffset ( ) ; i < length ; i ++ , j ++ ) { buffer [ i ] = b2c ( value [ j ] ) ; } return buffer ; } | Copies the characters in this string to a character array . |
13,925 | public void copy ( int srcIdx , char [ ] dst , int dstIdx , int length ) { if ( dst == null ) { throw new NullPointerException ( "dst" ) ; } if ( isOutOfBounds ( srcIdx , length , length ( ) ) ) { throw new IndexOutOfBoundsException ( "expected: " + "0 <= srcIdx(" + srcIdx + ") <= srcIdx + length(" + length + ") <= srcLen(" + length ( ) + ')' ) ; } final int dstEnd = dstIdx + length ; for ( int i = dstIdx , j = srcIdx + arrayOffset ( ) ; i < dstEnd ; i ++ , j ++ ) { dst [ i ] = b2c ( value [ j ] ) ; } } | Copied the content of this string to a character array . |
13,926 | 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(" + length ( ) + ')' ) ; } if ( start == 0 && end == length ( ) ) { return this ; } if ( end == start ) { return EMPTY_STRING ; } return new AsciiString ( value , start + offset , end - start , copy ) ; } | Either copy or share a subset of underlying sub - sequence of bytes . |
13,927 | public int indexOf ( CharSequence subString , int start ) { final int subCount = subString . length ( ) ; if ( start < 0 ) { start = 0 ; } if ( subCount <= 0 ) { return start < length ? start : length ; } if ( subCount > length - start ) { return INDEX_NOT_FOUND ; } final char firstChar = subString . charAt ( 0 ) ; if ( firstChar > MAX_CHAR_VALUE ) { return INDEX_NOT_FOUND ; } final byte firstCharAsByte = c2b0 ( firstChar ) ; final int len = offset + length - subCount ; for ( int i = start + offset ; i <= len ; ++ i ) { if ( value [ i ] == firstCharAsByte ) { int o1 = i , o2 = 0 ; while ( ++ o2 < subCount && b2c ( value [ ++ o1 ] ) == subString . charAt ( o2 ) ) { } if ( o2 == subCount ) { return i - offset ; } } } return INDEX_NOT_FOUND ; } | Searches in this string for the index of the specified string . The search for the string starts at the specified offset and moves towards the end of this string . |
13,928 | 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 ) { return false ; } final int thisLen = length ( ) ; if ( thisStart < 0 || thisLen - thisStart < length ) { return false ; } if ( length <= 0 ) { return true ; } final int thatEnd = start + length ; for ( int i = start , j = thisStart + arrayOffset ( ) ; i < thatEnd ; i ++ , j ++ ) { if ( b2c ( value [ j ] ) != string . charAt ( i ) ) { return false ; } } return true ; } | Compares the specified string to this string and compares the specified range of characters to determine if they are the same . |
13,929 | public boolean regionMatches ( boolean ignoreCase , int thisStart , CharSequence string , int start , int length ) { if ( ! ignoreCase ) { return regionMatches ( thisStart , string , start , length ) ; } if ( string == null ) { throw new NullPointerException ( "string" ) ; } final int thisLen = length ( ) ; if ( thisStart < 0 || length > thisLen - thisStart ) { return false ; } if ( start < 0 || length > string . length ( ) - start ) { return false ; } thisStart += arrayOffset ( ) ; final int thisEnd = thisStart + length ; while ( thisStart < thisEnd ) { if ( ! equalsIgnoreCase ( b2c ( value [ thisStart ++ ] ) , string . charAt ( start ++ ) ) ) { return false ; } } return true ; } | Compares the specified string to this string and compares the specified range of characters to determine if they are the same . When ignoreCase is true the case of the characters is ignored during the comparison . |
13,930 | public AsciiString replace ( char oldChar , char newChar ) { if ( oldChar > MAX_CHAR_VALUE ) { return this ; } final byte oldCharAsByte = c2b0 ( oldChar ) ; final byte newCharAsByte = c2b ( newChar ) ; final int len = offset + length ; for ( int i = offset ; i < len ; ++ i ) { if ( value [ i ] == oldCharAsByte ) { byte [ ] buffer = PlatformDependent . allocateUninitializedArray ( length ( ) ) ; System . arraycopy ( value , offset , buffer , 0 , i - offset ) ; buffer [ i - offset ] = newCharAsByte ; ++ i ; for ( ; i < len ; ++ i ) { byte oldValue = value [ i ] ; buffer [ i - offset ] = oldValue != oldCharAsByte ? oldValue : newCharAsByte ; } return new AsciiString ( buffer , false ) ; } } return this ; } | Copies this string replacing occurrences of the specified character with another character . |
13,931 | 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' ) { lowercased = false ; break ; } } if ( lowercased ) { return this ; } final byte [ ] newValue = PlatformDependent . allocateUninitializedArray ( length ( ) ) ; for ( i = 0 , j = arrayOffset ( ) ; i < newValue . length ; ++ i , ++ j ) { newValue [ i ] = toLowerCase ( value [ j ] ) ; } return new AsciiString ( newValue , false ) ; } | Converts the characters in this string to lowercase using the default Locale . |
13,932 | public AsciiString toUpperCase ( ) { boolean uppercased = true ; int i , j ; final int len = length ( ) + arrayOffset ( ) ; for ( i = arrayOffset ( ) ; i < len ; ++ i ) { byte b = value [ i ] ; if ( b >= 'a' && b <= 'z' ) { uppercased = false ; break ; } } if ( uppercased ) { return this ; } final byte [ ] newValue = PlatformDependent . allocateUninitializedArray ( length ( ) ) ; for ( i = 0 , j = arrayOffset ( ) ; i < newValue . length ; ++ i , ++ j ) { newValue [ i ] = toUpperCase ( value [ j ] ) ; } return new AsciiString ( newValue , false ) ; } | Converts the characters in this string to uppercase using the default Locale . |
13,933 | 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 , last = c . length ( ) - 1 ; int end = last ; while ( start <= end && c . charAt ( start ) <= ' ' ) { start ++ ; } while ( end >= start && c . charAt ( end ) <= ' ' ) { end -- ; } if ( start == 0 && end == last ) { return c ; } return c . subSequence ( start , end ) ; } | Copies this string removing white space characters from the beginning and end of the string and tries not to copy if possible . |
13,934 | public AsciiString trim ( ) { int start = arrayOffset ( ) , last = arrayOffset ( ) + length ( ) - 1 ; int end = last ; while ( start <= end && value [ start ] <= ' ' ) { start ++ ; } while ( end >= start && value [ end ] <= ' ' ) { end -- ; } if ( start == 0 && end == last ) { return this ; } return new AsciiString ( value , start , end - start + 1 , false ) ; } | Duplicates this string removing white space characters from the beginning and end of the string without copying . |
13,935 | public static boolean regionMatches ( final CharSequence cs , final boolean ignoreCase , final int csStart , final CharSequence string , final int start , final int length ) { if ( cs == null || string == null ) { return false ; } if ( cs instanceof String && string instanceof String ) { return ( ( String ) cs ) . regionMatches ( ignoreCase , csStart , ( String ) string , start , length ) ; } if ( cs instanceof AsciiString ) { return ( ( AsciiString ) cs ) . regionMatches ( ignoreCase , csStart , string , start , length ) ; } return regionMatchesCharSequences ( cs , csStart , string , start , length , ignoreCase ? GeneralCaseInsensitiveCharEqualityComparator . INSTANCE : DefaultCharEqualityComparator . INSTANCE ) ; } | This methods make regionMatches operation correctly for any chars in strings |
13,936 | public static < T > T releaseLater ( T msg , int decrement ) { if ( msg instanceof ReferenceCounted ) { ThreadDeathWatcher . watch ( Thread . currentThread ( ) , new ReleasingTask ( ( ReferenceCounted ) msg , decrement ) ) ; } return msg ; } | Schedules the specified object to be released when the caller thread terminates . Note that this operation is intended to simplify reference counting of ephemeral objects during unit tests . Do not use it beyond the intended use case . |
13,937 | public void windowUpdateRatio ( float ratio ) { assert ctx == null || ctx . executor ( ) . inEventLoop ( ) ; checkValidRatio ( ratio ) ; windowUpdateRatio = ratio ; } | The window update ratio is used to determine when a window update must be sent . If the ratio of bytes processed since the last update has meet or exceeded this ratio then a window update will be sent . This is the global window update ratio that will be used for new streams . |
13,938 | void releaseReadSuspended ( ChannelHandlerContext ctx ) { Channel channel = ctx . channel ( ) ; channel . attr ( READ_SUSPENDED ) . set ( false ) ; channel . config ( ) . setAutoRead ( true ) ; } | Release the Read suspension |
13,939 | void checkWriteSuspend ( ChannelHandlerContext ctx , long delay , long queueSize ) { if ( queueSize > maxWriteSize || delay > maxWriteDelay ) { setUserDefinedWritability ( ctx , false ) ; } } | Check the writability according to delay and size for the channel . Set if necessary setUserDefinedWritability status . |
13,940 | static HAProxyMessage decodeHeader ( String header ) { if ( header == null ) { throw new HAProxyProtocolException ( "header" ) ; } String [ ] parts = header . split ( " " ) ; int numParts = parts . length ; if ( numParts < 2 ) { throw new HAProxyProtocolException ( "invalid header: " + header + " (expected: 'PROXY' and proxied protocol values)" ) ; } if ( ! "PROXY" . equals ( parts [ 0 ] ) ) { throw new HAProxyProtocolException ( "unknown identifier: " + parts [ 0 ] ) ; } HAProxyProxiedProtocol protAndFam ; try { protAndFam = HAProxyProxiedProtocol . valueOf ( parts [ 1 ] ) ; } catch ( IllegalArgumentException e ) { throw new HAProxyProtocolException ( e ) ; } if ( protAndFam != HAProxyProxiedProtocol . TCP4 && protAndFam != HAProxyProxiedProtocol . TCP6 && protAndFam != HAProxyProxiedProtocol . UNKNOWN ) { throw new HAProxyProtocolException ( "unsupported v1 proxied protocol: " + parts [ 1 ] ) ; } if ( protAndFam == HAProxyProxiedProtocol . UNKNOWN ) { return V1_UNKNOWN_MSG ; } if ( numParts != 6 ) { throw new HAProxyProtocolException ( "invalid TCP4/6 header: " + header + " (expected: 6 parts)" ) ; } return new HAProxyMessage ( HAProxyProtocolVersion . V1 , HAProxyCommand . PROXY , protAndFam , parts [ 2 ] , parts [ 3 ] , parts [ 4 ] , parts [ 5 ] ) ; } | Decodes a version 1 human - readable proxy protocol header . |
13,941 | private static String ipBytesToString ( ByteBuf header , int addressLen ) { StringBuilder sb = new StringBuilder ( ) ; if ( addressLen == 4 ) { sb . append ( header . readByte ( ) & 0xff ) ; sb . append ( '.' ) ; sb . append ( header . readByte ( ) & 0xff ) ; sb . append ( '.' ) ; sb . append ( header . readByte ( ) & 0xff ) ; sb . append ( '.' ) ; sb . append ( header . readByte ( ) & 0xff ) ; } else { sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; sb . append ( ':' ) ; sb . append ( Integer . toHexString ( header . readUnsignedShort ( ) ) ) ; } return sb . toString ( ) ; } | Convert ip address bytes to string representation |
13,942 | private static int portStringToInt ( String value ) { int port ; try { port = Integer . parseInt ( value ) ; } catch ( NumberFormatException e ) { throw new HAProxyProtocolException ( "invalid port: " + value , e ) ; } if ( port <= 0 || port > 65535 ) { throw new HAProxyProtocolException ( "invalid port: " + value + " (expected: 1 ~ 65535)" ) ; } return port ; } | Convert port to integer |
13,943 | public static FullHttpResponse toFullHttpResponse ( int streamId , Http2Headers http2Headers , ByteBufAllocator alloc , boolean validateHttpHeaders ) throws Http2Exception { HttpResponseStatus status = parseStatus ( http2Headers . status ( ) ) ; FullHttpResponse msg = new DefaultFullHttpResponse ( HttpVersion . HTTP_1_1 , status , alloc . buffer ( ) , validateHttpHeaders ) ; try { addHttp2ToHttpHeaders ( streamId , http2Headers , msg , false ) ; } catch ( Http2Exception e ) { msg . release ( ) ; throw e ; } catch ( Throwable t ) { msg . release ( ) ; throw streamError ( streamId , PROTOCOL_ERROR , t , "HTTP/2 to HTTP/1.x headers conversion error" ) ; } return msg ; } | Create a new object to contain the response data |
13,944 | public static FullHttpRequest toFullHttpRequest ( int streamId , Http2Headers http2Headers , ByteBufAllocator alloc , boolean validateHttpHeaders ) throws Http2Exception { final CharSequence method = checkNotNull ( http2Headers . method ( ) , "method header cannot be null in conversion to HTTP/1.x" ) ; final CharSequence path = checkNotNull ( http2Headers . path ( ) , "path header cannot be null in conversion to HTTP/1.x" ) ; FullHttpRequest msg = new DefaultFullHttpRequest ( HttpVersion . HTTP_1_1 , HttpMethod . valueOf ( method . toString ( ) ) , path . toString ( ) , alloc . buffer ( ) , validateHttpHeaders ) ; try { addHttp2ToHttpHeaders ( streamId , http2Headers , msg , false ) ; } catch ( Http2Exception e ) { msg . release ( ) ; throw e ; } catch ( Throwable t ) { msg . release ( ) ; throw streamError ( streamId , PROTOCOL_ERROR , t , "HTTP/2 to HTTP/1.x headers conversion error" ) ; } return msg ; } | Create a new object to contain the request data |
13,945 | public static HttpRequest toHttpRequest ( int streamId , Http2Headers http2Headers , boolean validateHttpHeaders ) throws Http2Exception { final CharSequence method = checkNotNull ( http2Headers . method ( ) , "method header cannot be null in conversion to HTTP/1.x" ) ; final CharSequence path = checkNotNull ( http2Headers . path ( ) , "path header cannot be null in conversion to HTTP/1.x" ) ; HttpRequest msg = new DefaultHttpRequest ( HttpVersion . HTTP_1_1 , HttpMethod . valueOf ( method . toString ( ) ) , path . toString ( ) , validateHttpHeaders ) ; try { addHttp2ToHttpHeaders ( streamId , http2Headers , msg . headers ( ) , msg . protocolVersion ( ) , false , true ) ; } catch ( Http2Exception e ) { throw e ; } catch ( Throwable t ) { throw streamError ( streamId , PROTOCOL_ERROR , t , "HTTP/2 to HTTP/1.x headers conversion error" ) ; } return msg ; } | Create a new object to contain the request data . |
13,946 | public static HttpResponse toHttpResponse ( final int streamId , final Http2Headers http2Headers , final boolean validateHttpHeaders ) throws Http2Exception { final HttpResponseStatus status = parseStatus ( http2Headers . status ( ) ) ; final HttpResponse msg = new DefaultHttpResponse ( HttpVersion . HTTP_1_1 , status , validateHttpHeaders ) ; try { addHttp2ToHttpHeaders ( streamId , http2Headers , msg . headers ( ) , msg . protocolVersion ( ) , false , true ) ; } catch ( final Http2Exception e ) { throw e ; } catch ( final Throwable t ) { throw streamError ( streamId , PROTOCOL_ERROR , t , "HTTP/2 to HTTP/1.x headers conversion error" ) ; } return msg ; } | Create a new object to contain the response data . |
13,947 | static void setHttp2Authority ( String authority , Http2Headers out ) { if ( authority != null ) { if ( authority . isEmpty ( ) ) { out . authority ( EMPTY_STRING ) ; } else { int start = authority . indexOf ( '@' ) + 1 ; int length = authority . length ( ) - start ; if ( length == 0 ) { throw new IllegalArgumentException ( "authority: " + authority ) ; } out . authority ( new AsciiString ( authority , start , length ) ) ; } } } | package - private for testing only |
13,948 | 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 ] = Integer . parseInt ( components [ i ] ) ; } if ( version [ 0 ] == 1 ) { assert version [ 1 ] >= 6 ; return version [ 1 ] ; } else { return version [ 0 ] ; } } | Package - private for testing only |
13,949 | private static void setExtendedParentPointers ( final int [ ] array ) { final int length = array . length ; array [ 0 ] += array [ 1 ] ; for ( int headNode = 0 , tailNode = 1 , topNode = 2 ; tailNode < length - 1 ; tailNode ++ ) { int temp ; if ( topNode >= length || array [ headNode ] < array [ topNode ] ) { temp = array [ headNode ] ; array [ headNode ++ ] = tailNode ; } else { temp = array [ topNode ++ ] ; } if ( topNode >= length || ( headNode < tailNode && array [ headNode ] < array [ topNode ] ) ) { temp += array [ headNode ] ; array [ headNode ++ ] = tailNode + length ; } else { temp += array [ topNode ++ ] ; } array [ tailNode ] = temp ; } } | Fills the code array with extended parent pointers . |
13,950 | 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 = first ( array , currentNode - 1 , 0 ) ; } return currentNode ; } | Finds the number of nodes to relocate in order to achieve a given code length limit . |
13,951 | 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 lastNode = firstNode ; firstNode = first ( array , lastNode - 1 , 0 ) ; for ( int i = availableNodes - ( lastNode - firstNode ) ; i > 0 ; i -- ) { array [ nextNode -- ] = currentDepth ; } availableNodes = ( lastNode - firstNode ) << 1 ; } } | A final allocation pass with no code length limit . |
13,952 | private static void allocateNodeLengthsWithRelocation ( final int [ ] array , final int nodesToMove , final int insertDepth ) { int firstNode = array . length - 2 ; int nextNode = array . length - 1 ; int currentDepth = insertDepth == 1 ? 2 : 1 ; int nodesLeftToMove = insertDepth == 1 ? nodesToMove - 2 : nodesToMove ; for ( int availableNodes = currentDepth << 1 ; availableNodes > 0 ; currentDepth ++ ) { final int lastNode = firstNode ; firstNode = firstNode <= nodesToMove ? firstNode : first ( array , lastNode - 1 , nodesToMove ) ; int offset = 0 ; if ( currentDepth >= insertDepth ) { offset = Math . min ( nodesLeftToMove , 1 << ( currentDepth - insertDepth ) ) ; } else if ( currentDepth == insertDepth - 1 ) { offset = 1 ; if ( array [ firstNode ] == lastNode ) { firstNode ++ ; } } for ( int i = availableNodes - ( lastNode - firstNode + offset ) ; i > 0 ; i -- ) { array [ nextNode -- ] = currentDepth ; } nodesLeftToMove -= offset ; availableNodes = ( lastNode - firstNode + offset ) << 1 ; } } | A final allocation pass that relocates nodes in order to achieve a maximum code length limit . |
13,953 | static void allocateHuffmanCodeLengths ( final int [ ] array , final int maximumLength ) { switch ( array . length ) { case 2 : array [ 1 ] = 1 ; case 1 : array [ 0 ] = 1 ; return ; } setExtendedParentPointers ( array ) ; int nodesToRelocate = findNodesToRelocate ( array , maximumLength ) ; if ( array [ 0 ] % array . length >= nodesToRelocate ) { allocateNodeLengths ( array ) ; } else { int insertDepth = maximumLength - ( 32 - Integer . numberOfLeadingZeros ( nodesToRelocate - 1 ) ) ; allocateNodeLengthsWithRelocation ( array , nodesToRelocate , insertDepth ) ; } } | Allocates Canonical Huffman code lengths in place based on a sorted frequency array . |
13,954 | public void close ( ) throws IOException { for ( ; ; ) { int state = this . state ; if ( isClosed ( state ) ) { return ; } if ( casState ( state , state | STATE_ALL_MASK ) ) { break ; } } int res = close ( fd ) ; if ( res < 0 ) { throw newIOException ( "close" , res ) ; } } | Close the file descriptor . |
13,955 | protected final void init ( I inboundHandler , O outboundHandler ) { validate ( inboundHandler , outboundHandler ) ; this . inboundHandler = inboundHandler ; this . outboundHandler = outboundHandler ; } | Initialized this handler with the specified handlers . |
13,956 | 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 ) ; } | Checks if two strings have the same suffix of specified length |
13,957 | public static < T extends Appendable > T byteToHexString ( T buf , int value ) { try { buf . append ( byteToHexString ( value ) ) ; } catch ( IOException e ) { PlatformDependent . throwException ( e ) ; } return buf ; } | Converts the specified byte value into a hexadecimal integer and appends it to the specified buffer . |
13,958 | public static byte decodeHexByte ( CharSequence s , int pos ) { int hi = decodeHexNibble ( s . charAt ( pos ) ) ; int lo = decodeHexNibble ( s . charAt ( pos + 1 ) ) ; if ( hi == - 1 || lo == - 1 ) { throw new IllegalArgumentException ( String . format ( "invalid hex byte '%s' at index %d of '%s'" , s . subSequence ( pos , pos + 2 ) , pos , s ) ) ; } return ( byte ) ( ( hi << 4 ) + lo ) ; } | Decode a 2 - digit hex byte from within a string . |
13,959 | protected final String exceptionMessage ( String msg ) { if ( msg == null ) { msg = "" ; } StringBuilder buf = new StringBuilder ( 128 + msg . length ( ) ) . append ( protocol ( ) ) . append ( ", " ) . append ( authScheme ( ) ) . append ( ", " ) . append ( proxyAddress ) . append ( " => " ) . append ( destinationAddress ) ; if ( ! msg . isEmpty ( ) ) { buf . append ( ", " ) . append ( msg ) ; } return buf . toString ( ) ; } | Decorates the specified exception message with the common information such as the current protocol authentication scheme proxy address and destination address . |
13,960 | static void closeOnFlush ( Channel ch ) { if ( ch . isActive ( ) ) { ch . writeAndFlush ( Unpooled . EMPTY_BUFFER ) . addListener ( ChannelFutureListener . CLOSE ) ; } } | Closes the specified channel after all queued write requests are flushed . |
13,961 | public Future < AddressedEnvelope < DnsResponse , InetSocketAddress > > query ( DnsQuestion question , Iterable < DnsRecord > additionals ) { return query ( nextNameServerAddress ( ) , question , additionals ) ; } | Sends a DNS query with the specified question with additional records . |
13,962 | public Future < AddressedEnvelope < DnsResponse , InetSocketAddress > > query ( InetSocketAddress nameServerAddr , DnsQuestion question ) { return query0 ( nameServerAddr , question , EMPTY_ADDITIONALS , true , ch . newPromise ( ) , ch . eventLoop ( ) . < AddressedEnvelope < ? extends DnsResponse , InetSocketAddress > > newPromise ( ) ) ; } | Sends a DNS query with the specified question using the specified name server list . |
13,963 | public Future < AddressedEnvelope < DnsResponse , InetSocketAddress > > query ( InetSocketAddress nameServerAddr , DnsQuestion question , Iterable < DnsRecord > additionals ) { return query0 ( nameServerAddr , question , toArray ( additionals , false ) , true , ch . newPromise ( ) , ch . eventLoop ( ) . < AddressedEnvelope < ? extends DnsResponse , InetSocketAddress > > newPromise ( ) ) ; } | Sends a DNS query with the specified question with additional records using the specified name server list . |
13,964 | static int getIndex ( CharSequence name ) { Integer index = STATIC_INDEX_BY_NAME . get ( name ) ; if ( index == null ) { return - 1 ; } return index ; } | Returns the lowest index value for the given header field name in the static table . Returns - 1 if the header field name is not in the static table . |
13,965 | static int getIndex ( CharSequence name , CharSequence value ) { int index = getIndex ( name ) ; if ( index == - 1 ) { return - 1 ; } while ( index <= length ) { HpackHeaderField entry = getEntry ( index ) ; if ( equalsConstantTime ( name , entry . name ) == 0 ) { break ; } if ( equalsConstantTime ( value , entry . value ) != 0 ) { return index ; } index ++ ; } return - 1 ; } | Returns the index value for the given header field in the static table . Returns - 1 if the header field is not in the static table . |
13,966 | private static CharSequenceMap < Integer > createMap ( ) { int length = STATIC_TABLE . size ( ) ; @ SuppressWarnings ( "unchecked" ) CharSequenceMap < Integer > ret = new CharSequenceMap < Integer > ( true , UnsupportedValueConverter . < Integer > instance ( ) , length ) ; for ( int index = length ; index > 0 ; index -- ) { HpackHeaderField entry = getEntry ( index ) ; CharSequence name = entry . name ; ret . set ( name , index ) ; } return ret ; } | create a map CharSequenceMap header name to index value to allow quick lookup |
13,967 | protected void reportUntracedLeak ( String resourceType ) { logger . error ( "LEAK: {}.release() was not called before it's garbage-collected. " + "Enable advanced leak reporting to find out where the leak occurred. " + "To enable advanced leak reporting, " + "specify the JVM option '-D{}={}' or call {}.setLevel() " + "See http://netty.io/wiki/reference-counted-objects.html for more information." , resourceType , PROP_LEVEL , Level . ADVANCED . name ( ) . toLowerCase ( ) , simpleClassName ( this ) ) ; } | This method is called when an untraced leak is detected . It can be overridden for tracking how many times leaks have been detected . |
13,968 | public synchronized void stop ( ) { if ( ! monitorActive ) { return ; } monitorActive = false ; resetAccounting ( milliSecondFromNano ( ) ) ; if ( trafficShapingHandler != null ) { trafficShapingHandler . doAccounting ( this ) ; } if ( scheduledFuture != null ) { scheduledFuture . cancel ( true ) ; } } | Stop the monitoring process . |
13,969 | synchronized void resetAccounting ( long newLastTime ) { long interval = newLastTime - lastTime . getAndSet ( newLastTime ) ; if ( interval == 0 ) { return ; } if ( logger . isDebugEnabled ( ) && interval > checkInterval ( ) << 1 ) { logger . debug ( "Acct schedule not ok: " + interval + " > 2*" + checkInterval ( ) + " from " + name ) ; } lastReadBytes = currentReadBytes . getAndSet ( 0 ) ; lastWrittenBytes = currentWrittenBytes . getAndSet ( 0 ) ; lastReadThroughput = lastReadBytes * 1000 / interval ; lastWriteThroughput = lastWrittenBytes * 1000 / interval ; realWriteThroughput = realWrittenBytes . getAndSet ( 0 ) * 1000 / interval ; lastWritingTime = Math . max ( lastWritingTime , writingTime ) ; lastReadingTime = Math . max ( lastReadingTime , readingTime ) ; } | Reset the accounting on Read and Write . |
13,970 | public void configure ( long newCheckInterval ) { long newInterval = newCheckInterval / 10 * 10 ; if ( checkInterval . getAndSet ( newInterval ) != newInterval ) { if ( newInterval <= 0 ) { stop ( ) ; lastTime . set ( milliSecondFromNano ( ) ) ; } else { start ( ) ; } } } | Change checkInterval between two computations in millisecond . |
13,971 | private void updateParentsAlloc ( int id ) { while ( id > 1 ) { int parentId = id >>> 1 ; byte val1 = value ( id ) ; byte val2 = value ( id ^ 1 ) ; byte val = val1 < val2 ? val1 : val2 ; setValue ( parentId , val ) ; id = parentId ; } } | Update method used by allocate This is triggered only when a successor is allocated and all its predecessors need to update their state The minimal depth at which subtree rooted at id has some free space |
13,972 | private int allocateNode ( int d ) { int id = 1 ; int initial = - ( 1 << d ) ; byte val = value ( id ) ; if ( val > d ) { return - 1 ; } while ( val < d || ( id & initial ) == 0 ) { id <<= 1 ; val = value ( id ) ; if ( val > d ) { id ^= 1 ; val = value ( id ) ; } } byte value = value ( id ) ; assert value == d && ( id & initial ) == 1 << d : String . format ( "val = %d, id & initial = %d, d = %d" , value , id & initial , d ) ; setValue ( id , unusable ) ; updateParentsAlloc ( id ) ; return id ; } | Algorithm to allocate an index in memoryMap when we query for a free node at depth d |
13,973 | void free ( long handle , ByteBuffer nioBuffer ) { int memoryMapIdx = memoryMapIdx ( handle ) ; int bitmapIdx = bitmapIdx ( handle ) ; if ( bitmapIdx != 0 ) { PoolSubpage < T > subpage = subpages [ subpageIdx ( memoryMapIdx ) ] ; assert subpage != null && subpage . doNotDestroy ; PoolSubpage < T > head = arena . findSubpagePoolHead ( subpage . elemSize ) ; synchronized ( head ) { if ( subpage . free ( head , bitmapIdx & 0x3FFFFFFF ) ) { return ; } } } freeBytes += runLength ( memoryMapIdx ) ; setValue ( memoryMapIdx , depth ( memoryMapIdx ) ) ; updateParentsFree ( memoryMapIdx ) ; if ( nioBuffer != null && cachedNioBuffers != null && cachedNioBuffers . size ( ) < PooledByteBufAllocator . DEFAULT_MAX_CACHED_BYTEBUFFERS_PER_CHUNK ) { cachedNioBuffers . offer ( nioBuffer ) ; } } | Free a subpage or a run of pages When a subpage is freed from PoolSubpage it might be added back to subpage pool of the owning PoolArena If the subpage pool in PoolArena has at least one other PoolSubpage of given elemSize we can completely free the owning Page so it is available for subsequent allocations |
13,974 | private static int readRawVarint32 ( ByteBuf buffer ) { if ( ! buffer . isReadable ( ) ) { return 0 ; } buffer . markReaderIndex ( ) ; byte tmp = buffer . readByte ( ) ; if ( tmp >= 0 ) { return tmp ; } else { int result = tmp & 127 ; if ( ! buffer . isReadable ( ) ) { buffer . resetReaderIndex ( ) ; return 0 ; } if ( ( tmp = buffer . readByte ( ) ) >= 0 ) { result |= tmp << 7 ; } else { result |= ( tmp & 127 ) << 7 ; if ( ! buffer . isReadable ( ) ) { buffer . resetReaderIndex ( ) ; return 0 ; } if ( ( tmp = buffer . readByte ( ) ) >= 0 ) { result |= tmp << 14 ; } else { result |= ( tmp & 127 ) << 14 ; if ( ! buffer . isReadable ( ) ) { buffer . resetReaderIndex ( ) ; return 0 ; } if ( ( tmp = buffer . readByte ( ) ) >= 0 ) { result |= tmp << 21 ; } else { result |= ( tmp & 127 ) << 21 ; if ( ! buffer . isReadable ( ) ) { buffer . resetReaderIndex ( ) ; return 0 ; } result |= ( tmp = buffer . readByte ( ) ) << 28 ; if ( tmp < 0 ) { throw new CorruptedFrameException ( "malformed varint." ) ; } } } } return result ; } } | Reads variable length 32bit int from buffer |
13,975 | public static int splice ( int fd , long offIn , int fdOut , long offOut , long len ) throws IOException { int res = splice0 ( fd , offIn , fdOut , offOut , len ) ; if ( res >= 0 ) { return res ; } return ioResult ( "splice" , res , SPLICE_CONNECTION_RESET_EXCEPTION , SPLICE_CLOSED_CHANNEL_EXCEPTION ) ; } | File - descriptor operations |
13,976 | void recycle ( ) { for ( int i = 0 ; i < size ; i ++ ) { array [ i ] = null ; } size = 0 ; insertSinceRecycled = false ; recycler . recycle ( this ) ; } | Recycle the array which will clear it and null out all entries in the internal storage . |
13,977 | private static int contentLength ( Object msg ) { if ( msg instanceof MemcacheContent ) { return ( ( MemcacheContent ) msg ) . content ( ) . readableBytes ( ) ; } if ( msg instanceof ByteBuf ) { return ( ( ByteBuf ) msg ) . readableBytes ( ) ; } if ( msg instanceof FileRegion ) { return ( int ) ( ( FileRegion ) msg ) . count ( ) ; } throw new IllegalStateException ( "unexpected message type: " + StringUtil . simpleClassName ( msg ) ) ; } | Determine the content length of the given object . |
13,978 | static String normalizeHostname ( String hostname ) { if ( needsNormalization ( hostname ) ) { hostname = IDN . toASCII ( hostname , IDN . ALLOW_UNASSIGNED ) ; } return hostname . toLowerCase ( Locale . US ) ; } | IDNA ASCII conversion and case normalization |
13,979 | public void setMaxHeaderTableSize ( long maxHeaderTableSize ) throws Http2Exception { if ( maxHeaderTableSize < MIN_HEADER_TABLE_SIZE || maxHeaderTableSize > MAX_HEADER_TABLE_SIZE ) { throw connectionError ( PROTOCOL_ERROR , "Header Table Size must be >= %d and <= %d but was %d" , MIN_HEADER_TABLE_SIZE , MAX_HEADER_TABLE_SIZE , maxHeaderTableSize ) ; } maxDynamicTableSize = maxHeaderTableSize ; if ( maxDynamicTableSize < encoderMaxDynamicTableSize ) { maxDynamicTableSizeChangeRequired = true ; hpackDynamicTable . setCapacity ( maxDynamicTableSize ) ; } } | Set the maximum table size . If this is below the maximum size of the dynamic table used by the encoder the beginning of the next header block MUST signal this change . |
13,980 | private static int maxOutputBufferLength ( int inputLength ) { double factor ; if ( inputLength < 200 ) { factor = 1.5 ; } else if ( inputLength < 500 ) { factor = 1.2 ; } else if ( inputLength < 1000 ) { factor = 1.1 ; } else if ( inputLength < 10000 ) { factor = 1.05 ; } else { factor = 1.02 ; } return 13 + ( int ) ( inputLength * factor ) ; } | Calculates maximum possible size of output buffer for not compressible data . |
13,981 | public ChannelFuture close ( Channel channel , CloseWebSocketFrame frame , ChannelPromise promise ) { return channel . writeAndFlush ( frame , promise ) ; } | Echo back the closing frame |
13,982 | public void setBodyHttpDatas ( List < InterfaceHttpData > datas ) throws ErrorDataEncoderException { if ( datas == null ) { throw new NullPointerException ( "datas" ) ; } globalBodySize = 0 ; bodyListDatas . clear ( ) ; currentFileUpload = null ; duringMixedMode = false ; multipartHttpDatas . clear ( ) ; for ( InterfaceHttpData data : datas ) { addBodyHttpData ( data ) ; } } | Set the Body HttpDatas list |
13,983 | public void addBodyAttribute ( String name , String value ) throws ErrorDataEncoderException { String svalue = value != null ? value : StringUtil . EMPTY_STRING ; Attribute data = factory . createAttribute ( request , checkNotNull ( name , "name" ) , svalue ) ; addBodyHttpData ( data ) ; } | Add a simple attribute in the body as Name = Value |
13,984 | public void addBodyFileUploads ( String name , File [ ] file , String [ ] contentType , boolean [ ] isText ) throws ErrorDataEncoderException { if ( file . length != contentType . length && file . length != isText . length ) { throw new IllegalArgumentException ( "Different array length" ) ; } for ( int i = 0 ; i < file . length ; i ++ ) { addBodyFileUpload ( name , file [ i ] , contentType [ i ] , isText [ i ] ) ; } } | Add a series of Files associated with one File parameter |
13,985 | @ SuppressWarnings ( "unchecked" ) private String encodeAttribute ( String s , Charset charset ) throws ErrorDataEncoderException { if ( s == null ) { return "" ; } try { String encoded = URLEncoder . encode ( s , charset . name ( ) ) ; if ( encoderMode == EncoderMode . RFC3986 ) { for ( Map . Entry < Pattern , String > entry : percentEncodings ) { String replacement = entry . getValue ( ) ; encoded = entry . getKey ( ) . matcher ( encoded ) . replaceAll ( replacement ) ; } } return encoded ; } catch ( UnsupportedEncodingException e ) { throw new ErrorDataEncoderException ( charset . name ( ) , e ) ; } } | Encode one attribute |
13,986 | void createHuffmanDecodingTables ( ) { final int alphabetSize = this . alphabetSize ; for ( int table = 0 ; table < tableCodeLengths . length ; table ++ ) { final int [ ] tableBases = codeBases [ table ] ; final int [ ] tableLimits = codeLimits [ table ] ; final int [ ] tableSymbols = codeSymbols [ table ] ; final byte [ ] codeLengths = tableCodeLengths [ table ] ; int minimumLength = HUFFMAN_DECODE_MAX_CODE_LENGTH ; int maximumLength = 0 ; for ( int i = 0 ; i < alphabetSize ; i ++ ) { final byte currLength = codeLengths [ i ] ; maximumLength = Math . max ( currLength , maximumLength ) ; minimumLength = Math . min ( currLength , minimumLength ) ; } minimumLengths [ table ] = minimumLength ; for ( int i = 0 ; i < alphabetSize ; i ++ ) { tableBases [ codeLengths [ i ] + 1 ] ++ ; } for ( int i = 1 , b = tableBases [ 0 ] ; i < HUFFMAN_DECODE_MAX_CODE_LENGTH + 2 ; i ++ ) { b += tableBases [ i ] ; tableBases [ i ] = b ; } for ( int i = minimumLength , code = 0 ; i <= maximumLength ; i ++ ) { int base = code ; code += tableBases [ i + 1 ] - tableBases [ i ] ; tableBases [ i ] = base - tableBases [ i ] ; tableLimits [ i ] = code - 1 ; code <<= 1 ; } for ( int bitLength = minimumLength , codeIndex = 0 ; bitLength <= maximumLength ; bitLength ++ ) { for ( int symbol = 0 ; symbol < alphabetSize ; symbol ++ ) { if ( codeLengths [ symbol ] == bitLength ) { tableSymbols [ codeIndex ++ ] = symbol ; } } } } currentTable = selectors [ 0 ] ; } | Constructs Huffman decoding tables from lists of Canonical Huffman code lengths . |
13,987 | int nextSymbol ( ) { if ( ++ groupPosition % HUFFMAN_GROUP_RUN_LENGTH == 0 ) { groupIndex ++ ; if ( groupIndex == selectors . length ) { throw new DecompressionException ( "error decoding block" ) ; } currentTable = selectors [ groupIndex ] & 0xff ; } final Bzip2BitReader reader = this . reader ; final int currentTable = this . currentTable ; final int [ ] tableLimits = codeLimits [ currentTable ] ; final int [ ] tableBases = codeBases [ currentTable ] ; final int [ ] tableSymbols = codeSymbols [ currentTable ] ; int codeLength = minimumLengths [ currentTable ] ; int codeBits = reader . readBits ( codeLength ) ; for ( ; codeLength <= HUFFMAN_DECODE_MAX_CODE_LENGTH ; codeLength ++ ) { if ( codeBits <= tableLimits [ codeLength ] ) { return tableSymbols [ codeBits - tableBases [ codeLength ] ] ; } codeBits = codeBits << 1 | reader . readBits ( 1 ) ; } throw new DecompressionException ( "a valid code was not recognised" ) ; } | Decodes and returns the next symbol . |
13,988 | public long number ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionNumber ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the current number of sessions in the internal session cache . |
13,989 | public long connectRenegotiate ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionConnectRenegotiate ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of start renegotiations in client mode . |
13,990 | public long acceptRenegotiate ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionAcceptRenegotiate ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of start renegotiations in server mode . |
13,991 | public long cbHits ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionCbHits ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of successfully retrieved sessions from the external session cache in server mode . |
13,992 | public long misses ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionMisses ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of sessions proposed by clients that were not found in the internal session cache in server mode . |
13,993 | public long cacheFull ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionCacheFull ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of sessions that were removed because the maximum session cache size was exceeded . |
13,994 | public long ticketKeyFail ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionTicketKeyFail ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of times a client presented a ticket that did not match any key in the list . |
13,995 | public long ticketKeyNew ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionTicketKeyNew ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of times a client did not present a ticket and we issued a new one |
13,996 | public long ticketKeyRenew ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionTicketKeyRenew ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of times a client presented a ticket derived from an older key and we upgraded to the primary key . |
13,997 | public long ticketKeyResume ( ) { Lock readerLock = context . ctxLock . readLock ( ) ; readerLock . lock ( ) ; try { return SSLContext . sessionTicketKeyResume ( context . ctx ) ; } finally { readerLock . unlock ( ) ; } } | Returns the number of times a client presented a ticket derived from the primary key . |
13,998 | public void setup ( ) { System . setProperty ( "io.netty.buffer.checkAccessible" , checkAccessible ) ; System . setProperty ( "io.netty.buffer.checkBounds" , checkBounds ) ; buffer = bufferType . newBuffer ( ) ; } | applies only to readBatch benchmark |
13,999 | @ SuppressWarnings ( "deprecation" ) private static int unsignedShortBE ( ByteBuf buffer , int offset ) { return buffer . order ( ) == ByteOrder . BIG_ENDIAN ? buffer . getUnsignedShort ( offset ) : buffer . getUnsignedShortLE ( offset ) ; } | Reads a big - endian unsigned short integer from the buffer |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.