Skip to content

ConcurrentModificationException when running @ApplicationModuleTest tests in parallel (2) #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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions