-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
do not clear a subset of MDC keys when scope exits (DAT-16500) (#5416)
* do not clear a subset of MDC keys when scope exits * move method to util class --------- Co-authored-by: obovsunivskyii <baqaua@gmail.com>
- Loading branch information
1 parent
8743812
commit de976e5
Showing
7 changed files
with
95 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
liquibase-standard/src/main/java/liquibase/util/LogUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package liquibase.util; | ||
|
||
import liquibase.Scope; | ||
import liquibase.logging.mdc.MdcKey; | ||
|
||
public class LogUtil { | ||
|
||
|
||
/** | ||
* In {@link LiquibaseCommandLine#addEmptyMdcValues()}, baseline values are added to the MDC with empty strings. | ||
* It is desired that {@link MdcKey#CHANGESET_ID}, {@link MdcKey#CHANGESET_AUTHOR} and {@link MdcKey#LIQUIBASE_SYSTEM_USER} | ||
* are not ever cleared from the scope, except when the command finishes executing (or they are replaced with a new | ||
* value). When the command finishes executing, these keys must be set back to an empty string so that incorrect | ||
* values do not persist outside of command execution (like would occur during flow). {@link MdcKey#LIQUIBASE_SYSTEM_USER} | ||
* is purposefully excluded from this method because it does not need to be reset when command execution finishes | ||
* because it should be constant throughout the entire Liquibase execution. | ||
*/ | ||
public static void setPersistedMdcKeysToEmptyString() { | ||
Scope.getCurrentScope().addMdcValue(MdcKey.CHANGESET_ID, "", false); | ||
Scope.getCurrentScope().addMdcValue(MdcKey.CHANGESET_AUTHOR, "", false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters