Skip to content

ThreadLocal Hubs should be cleaned up #2079

@adinauer

Description

@adinauer

Problem Statement

At the moment Hub instances are stored in ThreadLocal variables. They are never cleaned up and thus cause servers like Tomcat to issue warnings as can be seen here #2074, here #420 and here #487. While there are mechanisms to clean up these leaks in Tomcat we should not rely on them and clean up instead.

private static final @NotNull ThreadLocal<IHub> currentHub = new ThreadLocal<>();

Solution Brainstorm

We may have to move away from ThreadLocal variables at some point to support Webflux and similar. Until then we could try and unset the ThreadLocal after a request is done (ServletRequestListener.requestDestroyed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    ImprovementIssue typeThreadLocalHubProblemIssues caused by Hub being ThreadLocal and no or no easy way to clone the hub

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions