lburgazzoli commented on a change in pull request #4887:
URL: https://github.com/apache/camel/pull/4887#discussion_r557899465



##########
File path: 
core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
##########
@@ -3786,7 +3787,9 @@ public DataFormat resolveDataFormat(String name) {
         final DataFormat answer = dataformats.computeIfAbsent(name, new 
Function<String, DataFormat>() {
             @Override
             public DataFormat apply(String s) {
-                DataFormat df = 
ResolverHelper.lookupDataFormatInRegistryWithFallback(getCamelContextReference(),
 name);
+                DataFormat df = Optional
+                        
.ofNullable(ResolverHelper.lookupDataFormatInRegistryWithFallback(getCamelContextReference(),
 name))
+                        .orElse(getDataFormatResolver().createDataFormat(name, 
getCamelContextReference()));

Review comment:
       You should eiter usean old school null check or use `orElseGet` instead 
of `orElse` as the later will cause the creation of a data format even if the 
former may return something




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to