Skip to content

Confusing example in Thread Context documentation #3177

@MaxAller

Description

@MaxAller

Description

On this page (in source), this example is given:

LOGGER.debug("Starting background thread for user");

Map<String, String> mdc = ThreadContext.getImmutableContext(); // (1)
List<String> ndc = ThreadContext.getImmutableStack().asList(); // (1)

executor.submit(() -> {
    try (CloseableThreadContext.Instance ignored = CloseableThreadContext
            .putAll(values) // (2)
            .pushAll(messages)) { // (2)

        LOGGER.debug("Processing for user started");
        // ...

    }
});

However...there's no connection between the (1) and (2) items. Is values supposed to be mdc, and messages should be ndc?

Metadata

Metadata

Assignees

Labels

documentationPull requests or issues that affect documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions