lburgazzoli commented on a change in pull request #648:
URL: https://github.com/apache/camel-k-runtime/pull/648#discussion_r612515550



##########
File path: 
camel-k-core/support/src/main/java/org/apache/camel/k/listener/SourcesConfigurer.java
##########
@@ -64,14 +67,49 @@ protected void accept(Runtime runtime) {
         // property that can't be bound to this configurer.
         //
         PropertiesSupport.bindProperties(
-            runtime.getCamelContext(),
-            this,
-            k -> k.startsWith(CAMEL_K_SOURCES_PREFIX),
-            CAMEL_K_PREFIX);
+                runtime.getCamelContext(),
+                this,
+                k -> k.startsWith(CAMEL_K_SOURCES_PREFIX),
+                CAMEL_K_PREFIX);
+
+        checkUniqueErrorHandler();
+        sortSources();
 
         if (ObjectHelper.isNotEmpty(this.getSources())) {
             SourcesSupport.loadSources(runtime, this.getSources());
         }
     }
 
+    private void checkUniqueErrorHandler() {
+        checkUniqueErrorHandler(this.sources);
+    }
+
+    static void checkUniqueErrorHandler(SourceDefinition[] sources) {
+        long errorHandlers = sources == null ? 0 : 
Arrays.stream(sources).filter(s -> s.getType() == 
SourceType.errorHandler).count();
+        if (errorHandlers > 1) {
+            throw new IllegalArgumentException("Expected only one error 
handler source type, got " + errorHandlers);
+        }
+    }
+
+    private void sortSources() {
+        sortSources(this.getSources());
+    }
+
+    static void sortSources(SourceDefinition[] sources) {
+        if (sources == null) {
+            return;
+        }
+        // We must ensure the source order as defined in SourceType enum
+        Arrays.sort(sources,

Review comment:
       yes




-- 
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