Skip to content
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
2 changes: 1 addition & 1 deletion log4j-to-slf4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
org.jspecify;transitive=false
</bnd-extra-module-options>

<slf4j2.version>2.0.16</slf4j2.version>
<slf4j2.version>2.0.17</slf4j2.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
import org.apache.logging.log4j.spi.ThreadContextMap;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.Issue;
import org.slf4j.MDCTestHelper;
import org.slf4j.spi.MDCAdapter;

class MDCContextMapTest {

@Test
@Issue("https://github.com/apache/logging-log4j2/issues/1426")
void nonNullGetCopy() {
void nonNullGetCopy() throws Exception {
final ThreadContextMap contextMap = new MDCContextMap();
final MDCAdapter mockAdapter = mock(MDCAdapter.class);
when(mockAdapter.getCopyOfContextMap()).thenReturn(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.slf4j;
package org.apache.logging.slf4j;

import java.lang.reflect.Field;
import org.slf4j.MDC;
import org.slf4j.spi.MDCAdapter;

public class MDCTestHelper {
class MDCTestHelper {

public static MDCAdapter replaceMDCAdapter(final MDCAdapter adapter) {
final MDCAdapter old = MDC.mdcAdapter;
MDC.mdcAdapter = adapter;
static MDCAdapter replaceMDCAdapter(final MDCAdapter adapter) throws Exception {
Field mdcAdapterField = MDC.class.getDeclaredField("MDC_ADAPTER");
mdcAdapterField.setAccessible(true);
final MDCAdapter old = (MDCAdapter) mdcAdapterField.get(null);
mdcAdapterField.set(null, adapter);
return old;
}
}
Loading