You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/01/15 06:33:06 UTC

[GitHub] [camel] lburgazzoli commented on a change in pull request #4887: CAMEL-16032 [camel-main] autoconfiguration does not bind dataformat i…

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:
users@infra.apache.org