Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.release()


    public Packet decodePacket(String string, UUID uuid) throws IOException {
        ByteBuf buf = Unpooled.copiedBuffer(string, CharsetUtil.UTF_8);
        try {
            return null;
        } finally {
            buf.release();
        }
    }

    private static int find(ByteBuf buffer, final char item) {
        int index = buffer.forEachByte(buffer.readerIndex(), buffer.readableBytes(), new ByteBufProcessor() {
View Full Code Here


                                } else {
                                    buf.writeBytes(b);
                                }
                            }
                            finally {
                                b.release();
                            }
                        } else {
                            jsonSupport.writeValue(out, values);
                        }
                    }
View Full Code Here

            // 这里关闭后, 会在pipeline中产生事件,通过具体的close事件来清理数据结构
            RemotingUtil.closeChannel(ctx.channel());
        }
        finally {
            if (null != frame) {
                frame.release();
            }
        }

        return null;
    }
View Full Code Here

        ByteBuf raw = ctx.alloc().buffer(user.length() + pw.length() + 1);
        raw.writeBytes((user + ":" + pw).getBytes(CHARSET));
        ByteBuf encoded = Base64.encode(raw);
        request.headers().add(HttpHeaders.Names.AUTHORIZATION, "Basic " + encoded.toString(CHARSET));
        encoded.release();
        raw.release();
    }

    @Override
    protected CouchbaseResponse decodeResponse(final ChannelHandlerContext ctx, final HttpObject msg) throws Exception {
View Full Code Here

            if (msg.getExtrasLength() > 0) {
                final ByteBuf extrasReleased = msg.getExtras();
                final ByteBuf extras = ctx.alloc().buffer(msg.getExtrasLength());
                extras.writeBytes(extrasReleased, extrasReleased.readerIndex(), extrasReleased.readableBytes());
                flags = extras.getInt(0);
                extras.release();
            }
            response = new GetResponse(status, cas, flags, bucket, content, request);
        } else if (request instanceof GetBucketConfigRequest) {
            response = new GetBucketConfigResponse(status, bucket, content,
                ((GetBucketConfigRequest) request).hostname());
View Full Code Here

        ByteBuf raw = ctx.alloc().buffer(user.length() + pw.length() + 1);
        raw.writeBytes((user + ":" + pw).getBytes(CHARSET));
        ByteBuf encoded = Base64.encode(raw);
        request.headers().add(HttpHeaders.Names.AUTHORIZATION, "Basic " + encoded.toString(CHARSET));
        encoded.release();
        raw.release();
    }

    /**
     * Converts a HTTP status code in its appropriate {@link ResponseStatus} representation.
View Full Code Here

            } finally {
                readLock.unlock();
            }

        } finally {
            input.release();
        }
    }

    protected void decode(ChannelHandlerContext ctx, ByteBuf buffer) throws InterruptedException {
View Full Code Here

                bodyOffset += out.snapshotLength;
            }
            while (metaBuffer.readableBytes() > 0) {
                metaBuffer.readBytes(openWriteFile, metaBuffer.readableBytes());
            }
            metaBuffer.release();
            /* write bytes for each stream id */
            for (TempData out : streamsWithData) {
                synchronized (out.stream) {     // need less confusing variable names for concurrency
                    int toWrite = out.snapshotLength;
                    while (toWrite > 0) {
View Full Code Here

                int written = Snappy.compress(input, 0, input.length, output.array(), output.arrayOffset());
                output.writerIndex(written);
            }
            catch (final Throwable e)
            {
                output.release();
                throw e;
            }
            finally
            {
                //release the old frame
View Full Code Here

                int size = Snappy.uncompress(input, 0, input.length, output.array(), output.arrayOffset());
                output.writerIndex(size);
            }
            catch (final Throwable e)
            {
                output.release();
                throw e;
            }
            finally
            {
                //release the old frame
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.