org.apache.catalina.core

## Class ThreadLocalLeakPreventionListener

- java.lang.Object
- - org.apache.catalina.core.ThreadLocalLeakPreventionListener

- All Implemented Interfaces:
    ContainerListener, LifecycleListener

      public class ThreadLocalLeakPreventionListener
      extends Object
      implements LifecycleListener, ContainerListener

  A `LifecycleListener` that triggers the renewal of threads in Executor pools when a `Context` is being stopped to avoid thread-local related memory leaks.

  Note : active threads will be renewed one by one when they come back to the pool after executing their task, see `ThreadPoolExecutor`.afterExecute().

  This listener must be declared in server.xml to be active.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static StringManager` | `sm` The string manager for this package.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ThreadLocalLeakPreventionListener()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `containerEvent(ContainerEvent event)` Acknowledge the occurrence of the specified event.
    `void` | `lifecycleEvent(LifecycleEvent event)` Listens for `LifecycleEvent` for the start of the `Server` to initialize itself and then for after_stop events of each `Context`.
    `protected void` | `processContainerAddChild(Container parent, Container child)`
    `protected void` | `processContainerRemoveChild(Container parent, Container child)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### sm

          protected static final StringManager sm

      The string manager for this package.

  - ### Constructor Detail

    - #### ThreadLocalLeakPreventionListener

          public ThreadLocalLeakPreventionListener()

  - ### Method Detail

    - #### lifecycleEvent

          public void lifecycleEvent(LifecycleEvent event)

      Listens for `LifecycleEvent` for the start of the `Server` to initialize itself and then for after_stop events of each `Context`.
      Specified by:
        `lifecycleEvent` in interface `LifecycleListener`
      Parameters:
        `event` - LifecycleEvent that has occurred

    - #### containerEvent

          public void containerEvent(ContainerEvent event)

      Description copied from interface: `ContainerListener`
      Acknowledge the occurrence of the specified event.
      Specified by:
        `containerEvent` in interface `ContainerListener`
      Parameters:
        `event` - ContainerEvent that has occurred

    - #### processContainerAddChild

          protected void processContainerAddChild(Container parent,
                                      Container child)

    - #### processContainerRemoveChild

          protected void processContainerRemoveChild(Container parent,
                                         Container child)

Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.