#vulnerable code 
                                void _close() {
        if (!isClosed.getAndSet(true)) {
            headerWritten = false;
            final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
            ChannelBufferOutputStream c = new ChannelBufferOutputStream(buffer);
            try {
                c.write(ENDCHUNK);
                channel.write(buffer).addListener(new ChannelFutureListener() {
                    @Override
                    public void operationComplete(ChannelFuture future) throws Exception {
                        if (!keepAlive) {
                            channel.close().awaitUninterruptibly();
                        }
                    }
                });

            } catch (IOException e) {
                logger.trace("Close error", e);
            }
        }
    } 
                            #location 7 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                void _close() {
        if (!isClosed.getAndSet(true)) {
            headerWritten = false;
            final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
            buffer.writeBytes(ENDCHUNK);
            channel.write(buffer).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    if (!keepAlive) {
                        channel.close().awaitUninterruptibly();
                    }
                }
            });
        }
    }