Re: [log4j2] Passing Optional parameters

2023-03-11 Thread Lukasz Lenart
sob., 11 mar 2023 o 13:51 Piotr P. Karwasz napisał(a): > However I don't believe that this is the right way to go: IIRC > `Optional.isPresent()` and `Optional.get()` should be replaced with a > single call to `Optional.ifPresent()` whenever possible: > > provider.ifPresent(p -> { > LOG.info("D

Re: [log4j2] Passing Optional parameters

2023-03-11 Thread Piotr P. Karwasz
Hi Łukasz, On Sat, 11 Mar 2023 at 10:36, Lukasz Lenart wrote: > Is it possible to unpack Optional parameters? Yes and no: the default message factories [1] and [2] do treat `Optional` parameter as any other `Object` parameter. In your case: LOG.info("Detected container provider [{}] needs to b

[log4j2] Passing Optional parameters

2023-03-11 Thread Lukasz Lenart
Is it possible to unpack Optional parameters? So instead of doing this: Optional provider = ... if (provider.isPresent()) { LOG.info("Detected container provider [{}] needs to be reloaded.", provider.get()); return true; } I can just use the parameter directly Optional provider = ... if (pr