Skip to content

Instantly share code, notes, and snippets.

View chemicL's full-sized avatar

Dariusz Jędrzejczyk chemicL

View GitHub Profile
@chemicL
chemicL / TestMdc.java
Last active March 25, 2024 16:16
Automatic context propagation with MDC using Project Reactor
@Test
void testMDC() {
Logger log = LoggerFactory.getLogger("test");
Hooks.enableAutomaticContextPropagation();
// To deal with the entire MDC (if we ensured no third-party code modifies it):
// ContextRegistry.getInstance().registerThreadLocalAccessor(new MdcAccessor());
// To deal with an individual key in the MDC:
@chemicL
chemicL / MonoOptionalBenchmark.java
Created January 16, 2023 11:29
Benchmark of Mono::singleOptional vs map + defaultIfEmpty
@BenchmarkMode({Mode.AverageTime})
@Warmup(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 5, timeUnit = TimeUnit.SECONDS)
@Fork(value = 1)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Benchmark)
public class MonoOptionalBenchmark {
private static final Throwable EXCEPTION = new RuntimeException() {
@Override