Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LOGMGR-327] Add an isEmpty() method for MDC. #402

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/main/java/org/jboss/logmanager/MDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,15 @@ public static Map<String, Object> copyObject() {
return mdcProvider.copyObject();
}

/**
* Checks of the MDC map is empty.
*
* @return {@code true} if the MDC map is empty, otherwise {@code false}
*/
public static boolean isEmpty() {
return mdcProvider.isEmpty();
}

/**
* Clear the current MDC map.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/jboss/logmanager/MDCProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public interface MDCProvider {
*/
Map<String, Object> copyObject();

/**
* Returns {@code true} if the backing MDC map is empty, otherwise {@code false}.
*
* @return {@code true} if the MDC map is empty
*/
boolean isEmpty();

/**
* Clear the current MDC map.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/jboss/logmanager/ThreadLocalMDC.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public Map<String, Object> copyObject() {
return mdc.get().clone();
}

@Override
public boolean isEmpty() {
return mdc.get().isEmpty();
}

@Override
public void clear() {
mdc.get().clear();
Expand Down