Skip to content

Avoid ConcurrentModificationException in PackageName #1319

@ajax-semenov-y

Description

@ajax-semenov-y

Hello, and thank you for the quick fix in #1295. Unfortunately, tests are still failing with a ConcurrentModificationException.

The error occurs in the ModuleTestExecution.of method when calling PackageName.ofType(type), which internally invokes:

static PackageName of(String name) {
    Assert.notNull(name, "Name must not be null!");
    var defaulted = name.isBlank() ? DEFAULT : name;
    return PACKAGE_NAMES.computeIfAbsent(defaulted, PackageName::new);
}

Since PACKAGE_NAMES is a plain HashMap and not thread-safe, concurrent accesses cause the exception. The same fix proposed in PR #1298 should help: replace the HashMap with a concurrent map implementation.

Metadata

Metadata

Assignees

Labels

in: coreCore module meta modeltype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions