zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eolivelli <...@git.apache.org>
Subject [GitHub] zookeeper pull request #669: ZOOKEEPER-3152: Port ZK netty stack to netty4
Date Sat, 20 Oct 2018 20:22:15 GMT
Github user eolivelli commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/669#discussion_r226838972
  
    --- Diff: zookeeper-common/src/test/java/org/apache/zookeeper/common/TestByteBufAllocator.java
---
    @@ -0,0 +1,151 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.zookeeper.common;
    +
    +import io.netty.buffer.ByteBuf;
    +import io.netty.buffer.CompositeByteBuf;
    +import io.netty.buffer.PooledByteBufAllocator;
    +import io.netty.util.ResourceLeakDetector;
    +
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Objects;
    +import java.util.concurrent.atomic.AtomicReference;
    +
    +/**
    + * This is a custom ByteBufAllocator that tracks outstanding allocations and
    + * crashes the program if any of them are leaked.
    + *
    + * Never use this class in production, it will cause your server to run out
    + * of memory! This is because it holds strong references to all allocated
    + * buffers and doesn't release them until checkForLeaks() is called at the
    + * end of a unit test.
    + *
    + * Note: the original code was copied from https://github.com/airlift/drift,
    + * with the permission and encouragement of airlift's author (dain). Airlift
    + * uses the same apache 2.0 license as Zookeeper so this should be ok.
    + *
    + * However, the code was modified to take advantage of Netty's built-in
    + * leak tracking and make a best effort to print details about buffer leaks.
    + */
    +public class TestByteBufAllocator extends PooledByteBufAllocator {
    --- End diff --
    
    Okay, very good


---

Mime
View raw message