Package org.h2.util

Class CloseWatcher


public class CloseWatcher extends PhantomReference<Object>
A phantom reference to watch for unclosed objects.
  • Constructor Details

  • Method Details

    • pollUnclosed

      public static CloseWatcher pollUnclosed()
      Check for a collected object.
      Returns:
      the first watcher
    • register

      public static CloseWatcher register(Object o, AutoCloseable closeable, boolean stackTrace)
      Register an object. Before calling this method, pollUnclosed() should be called in a loop to remove old references.
      Parameters:
      o - the object
      closeable - the object to close
      stackTrace - whether the stack trace should be registered (this is relatively slow)
      Returns:
      the close watcher
    • unregister

      public static void unregister(CloseWatcher w)
      Unregister an object, so it is no longer tracked.
      Parameters:
      w - the reference
    • getOpenStackTrace

      public String getOpenStackTrace()
      Get the open stack trace or null if none.
      Returns:
      the open stack trace
    • getCloseable

      public AutoCloseable getCloseable()