Class LeakPresenceDetector.ResourceScope

java.lang.Object
io.netty.util.LeakPresenceDetector.ResourceScope
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable
Enclosing class:
LeakPresenceDetector<T>

public static final class LeakPresenceDetector.ResourceScope extends java.lang.Object implements java.io.Closeable
A resource scope keeps track of the resources for a particular set of threads. Different scopes can be checked for leaks separately, to enable parallel test execution.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) int
     
    (package private) final java.util.Map<LeakPresenceDetector.PresenceTracker<?>, java.lang.Throwable>
     
    (package private) final java.lang.String
     
    (package private) final java.util.concurrent.atomic.LongAdder
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResourceScope(java.lang.String name)
    Create a new scope.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
     
    (package private) void
     
    void
    Close this scope.
    boolean
    Check whether there are any open resources left, and close() would throw.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • name

      final java.lang.String name
    • openResourceCounter

      final java.util.concurrent.atomic.LongAdder openResourceCounter
    • creationStacks

      final java.util.Map<LeakPresenceDetector.PresenceTracker<?>, java.lang.Throwable> creationStacks
    • closed

      int closed
  • Constructor Details

    • ResourceScope

      public ResourceScope(java.lang.String name)
      Create a new scope.
      Parameters:
      name - The scope name, used for error reporting
  • Method Details

    • checkOpen

      void checkOpen()
    • check

      void check()
    • hasOpenResources

      public boolean hasOpenResources()
      Check whether there are any open resources left, and close() would throw.
      Returns:
      true if there are open resources
    • close

      public void close()
      Close this scope. Closing a scope will prevent new resources from being allocated (or released) in this scope. The call also throws an exception if there are any resources left open.
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable