Fix errors when changing core and executing `detekt` by BraisGabin · Pull Request #9246 · detekt/detekt · GitHub
Skip to content

Fix errors when changing core and executing detekt#9246

Draft
BraisGabin wants to merge 2 commits intomainfrom
fix-2957-1
Draft

Fix errors when changing core and executing detekt#9246
BraisGabin wants to merge 2 commits intomainfrom
fix-2957-1

Conversation

@BraisGabin
Copy link
Copy Markdown
Member

Fixes #2957

We have a ClassLoader cache. The problem was that we didn't invalidate the cache correctly. We were just looking at changes in the paths of the classpath. But if the content of any of those paths changes we should invalidate it too. That's what this PR does. Instead of hashing the paths I'm now hashing the content of those paths.

There are two "problems" with this implementation:

  1. With this change we "invalidate" the cache more times, so we are going to leak more ClassLoaders in that ConcurrentHashMap. We had the leak already but this PR makes it even worst.
  2. I don't like to sort a classpath. The order in a classpath is important (class shadowing). But the problem is that in the current implementation, at detekt, we are creating 5 ClassLoaders. But with my new implementation we create a ClassLoader per module. That's bad! But If I sort the classpath that problem goes away.

For the point 1 I propose to use Caffeine. For the point 2 I think that we can assume that class shadowing is not something that we don't care (because it should not happen).

@detekt-ci
Copy link
Copy Markdown
Collaborator

detekt-ci commented Apr 13, 2026

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 14, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changing any core class invalidates cached detekt classloader

2 participants