This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 06961100f2b CAMEL-21404: camel-core - Routes loader should skip
failing if file has no extension and its optional. (#16123)
06961100f2b is described below
commit 06961100f2b8c122e6913b65a36fc21cc3d9cc07
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Oct 30 12:14:32 2024 +0100
CAMEL-21404: camel-core - Routes loader should skip failing if file has no
extension and its optional. (#16123)
---
.../org/apache/camel/impl/engine/DefaultRoutesLoader.java | 13 ++++++-------
.../main/java/org/apache/camel/main/RoutesConfigurer.java | 13 ++++++-------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoutesLoader.java
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoutesLoader.java
index 309d8bb4047..7fcd12ab306 100644
---
a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoutesLoader.java
+++
b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/DefaultRoutesLoader.java
@@ -306,20 +306,19 @@ public class DefaultRoutesLoader extends ServiceSupport
implements RoutesLoader,
}
protected RoutesBuilderLoader resolveRoutesBuilderLoader(Resource
resource, boolean optional) throws Exception {
+ RoutesBuilderLoader answer = null;
+
// the loader to use is derived from the file extension
final String extension = FileUtil.onlyExt(resource.getLocation(),
false);
- if (ObjectHelper.isEmpty(extension)) {
- throw new IllegalArgumentException(
- "Unable to determine file extension for resource: " +
resource.getLocation());
+ if (extension != null) {
+ answer = getRoutesLoader(extension);
}
-
- RoutesBuilderLoader loader = getRoutesLoader(extension);
- if (!optional && loader == null) {
+ if (!optional && answer == null) {
throw new IllegalArgumentException(
"Cannot find RoutesBuilderLoader in classpath supporting
file extension: " + extension);
}
- return loader;
+ return answer;
}
}
diff --git
a/core/camel-main/src/main/java/org/apache/camel/main/RoutesConfigurer.java
b/core/camel-main/src/main/java/org/apache/camel/main/RoutesConfigurer.java
index 382fd797394..68022f19af8 100644
--- a/core/camel-main/src/main/java/org/apache/camel/main/RoutesConfigurer.java
+++ b/core/camel-main/src/main/java/org/apache/camel/main/RoutesConfigurer.java
@@ -39,7 +39,6 @@ import org.apache.camel.spi.StartupStepRecorder;
import org.apache.camel.support.OrderedComparator;
import org.apache.camel.support.PluginHelper;
import org.apache.camel.util.FileUtil;
-import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StopWatch;
import org.apache.camel.util.TimeUtils;
import org.slf4j.Logger;
@@ -474,16 +473,16 @@ public class RoutesConfigurer {
CamelContext camelContext, Resource resource,
boolean optional)
throws Exception {
+
+ RoutesBuilderLoader answer = null;
+
// the loader to use is derived from the file extension
final String extension = FileUtil.onlyExt(resource.getLocation(),
false);
- if (ObjectHelper.isEmpty(extension)) {
- throw new IllegalArgumentException(
- "Unable to determine file extension for resource: " +
resource.getLocation());
+ if (extension != null) {
+ RoutesLoader loader = PluginHelper.getRoutesLoader(camelContext);
+ answer = loader.getRoutesLoader(extension);
}
-
- RoutesLoader loader = PluginHelper.getRoutesLoader(camelContext);
- RoutesBuilderLoader answer = loader.getRoutesLoader(extension);
if (!optional && answer == null) {
throw new IllegalArgumentException(
"Cannot find RoutesBuilderLoader in classpath supporting
file extension: " + extension);