Skip to content

Deprecate usage of TCCL in Loader/LoaderUtil #2850

Open
@ppkarwasz

Description

@ppkarwasz

As a complement to #1977, we should probably remove the usage of the thread context classloader from Loader and LoaderUtil in 2.x

The usage of Loader.loadClass(String) and LoaderUtil.loadClass(String) and similar methods is extremely prone to memory leaks, since the result of such a call is often assigned to a static field.

The thread context classloader is often the classloader of a web application that can be stopped and restarted at will. Any object that we obtain from it must be kept in a weak reference.

IMHO, we should always provide an explicit classloader to load a class by name and we can only choose between:

  • the classloader that loaded log4j-core or log4j-api,
  • the classloader associated with the current LoggerContext.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions