Class PortManager.PortRef

java.lang.Object
org.terracotta.utilities.test.net.PortManager.PortRef
All Implemented Interfaces:
AutoCloseable
Enclosing class:
PortManager

public static class PortManager.PortRef extends Object implements AutoCloseable
Represents a reserved TCP port. When use of the port is no longer needed, this reference should be closed to release the reservation.
  • Field Details

  • Constructor Details

    • PortRef

      private PortRef(int port)
  • Method Details

    • onClose

      void onClose(IntConsumer action)
      Prepends a close action to this PortRef. Actions are executed in reverse order of their addition. Each action is passed the port number being closed.
      Parameters:
      action - the action to take to close this PortRef instance
    • closers

      private AtomicReference<IntConsumer> closers()
      Gets the "closers" AtomicReference for use during weak-reference release.
      Returns:
      the AtomicReference instance to call for closing this PortRef
    • port

      public int port()
      Gets the reserved port number.
      Returns:
      the port number
    • isClosed

      public boolean isClosed()
      Returns whether or not this PortRef is closed.
      Returns:
      true if this PortRef has been closed; false otherwise
    • close

      public void close()
      Closes this PortRef.
      Specified by:
      close in interface AutoCloseable