Skip to content

Commit

Permalink
Merge pull request #402 from jamezp/LOGMGR-327
Browse files Browse the repository at this point in the history
[LOGMGR-327] Add an isEmpty() method for MDC.
  • Loading branch information
jamezp authored Jun 8, 2023
2 parents 5dcb531 + 82a157f commit d8ad0db
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
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

0 comments on commit d8ad0db

Please sign in to comment.