Java Code Examples for io.netty.util.ResourceLeakDetector#getLevel()

The following examples show how to use io.netty.util.ResourceLeakDetector#getLevel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractByteBufAllocator.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
protected static ByteBuf toLeakAwareBuffer(ByteBuf buf) {
    ResourceLeakTracker<ByteBuf> leak;
    switch (ResourceLeakDetector.getLevel()) {
        case SIMPLE:
            leak = AbstractByteBuf.leakDetector.track(buf);
            if (leak != null) {
                buf = new SimpleLeakAwareByteBuf(buf, leak);
            }
            break;
        case ADVANCED:
        case PARANOID:
            leak = AbstractByteBuf.leakDetector.track(buf);
            if (leak != null) {
                buf = new AdvancedLeakAwareByteBuf(buf, leak);
            }
            break;
        default:
            break;
    }
    return buf;
}
 
Example 2
Source File: AbstractByteBufAllocator.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
protected static CompositeByteBuf toLeakAwareBuffer(CompositeByteBuf buf) {
    ResourceLeakTracker<ByteBuf> leak;
    switch (ResourceLeakDetector.getLevel()) {
        case SIMPLE:
            leak = AbstractByteBuf.leakDetector.track(buf);
            if (leak != null) {
                buf = new SimpleLeakAwareCompositeByteBuf(buf, leak);
            }
            break;
        case ADVANCED:
        case PARANOID:
            leak = AbstractByteBuf.leakDetector.track(buf);
            if (leak != null) {
                buf = new AdvancedLeakAwareCompositeByteBuf(buf, leak);
            }
            break;
        default:
            break;
    }
    return buf;
}
 
Example 3
Source File: AbstractByteBufAllocator.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
protected static ByteBuf toLeakAwareBuffer(ByteBuf buf) {
    ResourceLeak leak;
    switch (ResourceLeakDetector.getLevel()) {
        case SIMPLE:
            leak = AbstractByteBuf.leakDetector.open(buf);
            if (leak != null) {
                buf = new SimpleLeakAwareByteBuf(buf, leak);
            }
            break;
        case ADVANCED:
        case PARANOID:
            leak = AbstractByteBuf.leakDetector.open(buf);
            if (leak != null) {
                buf = new AdvancedLeakAwareByteBuf(buf, leak);
            }
            break;
    }
    return buf;
}
 
Example 4
Source File: DisplayLeaksSubCmd.java    From ViaVersion with MIT License 5 votes vote down vote up
@Override
public boolean execute(ViaCommandSender sender, String[] args) {
    if (ResourceLeakDetector.getLevel() != ResourceLeakDetector.Level.ADVANCED)
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.ADVANCED);
    else
        ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);

    sendMessage(sender, "&6Leak detector is now %s", (ResourceLeakDetector.getLevel() == ResourceLeakDetector.Level.ADVANCED ? "&aenabled" : "&cdisabled"));
    return true;
}
 
Example 5
Source File: LeakDetectorTestSuite.java    From pravega with Apache License 2.0 5 votes vote down vote up
@Override
@Before
public void before() {
    super.before();
    InternalLoggerFactory.setDefaultFactory(new ResourceLeakLoggerFactory());
    this.originalLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
}
 
Example 6
Source File: ResourceLeakDetectorRecordBenchmark.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Setup(Level.Trial)
public void setup() {
    level = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
}
 
Example 7
Source File: TestingPooledByteBufAllocator.java    From drift with Apache License 2.0 4 votes vote down vote up
private static ResourceLeakDetector.Level getAndSetResourceLeakDetectorLevel(ResourceLeakDetector.Level newLevel)
{
    ResourceLeakDetector.Level oldLevel = ResourceLeakDetector.getLevel();
    ResourceLeakDetector.setLevel(newLevel);
    return oldLevel;
}