You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2021/04/15 15:01:17 UTC

[camel-k-runtime] branch master updated: fix(core): solve NPE when missing source type (#660)

This is an automated email from the ASF dual-hosted git repository.

nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d706da  fix(core): solve NPE when missing source type (#660)
4d706da is described below

commit 4d706da444397556e8f3542f79c72567620cf9d2
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Apr 15 17:01:09 2021 +0200

    fix(core): solve NPE when missing source type (#660)
    
    Patch to avoid NPE such as in https://github.com/apache/camel-k/pull/2216
    
    Ref #658
---
 .../src/main/java/org/apache/camel/k/listener/SourcesConfigurer.java   | 3 +++
 .../test/java/org/apache/camel/k/listener/SourceConfigurerTest.java    | 1 -
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/camel-k-core/support/src/main/java/org/apache/camel/k/listener/SourcesConfigurer.java b/camel-k-core/support/src/main/java/org/apache/camel/k/listener/SourcesConfigurer.java
index cbaae05..69c061c 100644
--- a/camel-k-core/support/src/main/java/org/apache/camel/k/listener/SourcesConfigurer.java
+++ b/camel-k-core/support/src/main/java/org/apache/camel/k/listener/SourcesConfigurer.java
@@ -102,6 +102,9 @@ public class SourcesConfigurer extends AbstractPhaseListener {
         // We must ensure the source order as defined in SourceType enum
         Arrays.sort(sources,
                 (a, b) -> {
+                    if (a.getType() == null && b.getType() == null) {
+                        return 0;
+                    }
                     if (a.getType() == null) {
                         return SourceType.source.compareTo(b.getType());
                     } else if (b.getType() == null) {
diff --git a/camel-k-core/support/src/test/java/org/apache/camel/k/listener/SourceConfigurerTest.java b/camel-k-core/support/src/test/java/org/apache/camel/k/listener/SourceConfigurerTest.java
index 2aae80e..afd1dab 100644
--- a/camel-k-core/support/src/test/java/org/apache/camel/k/listener/SourceConfigurerTest.java
+++ b/camel-k-core/support/src/test/java/org/apache/camel/k/listener/SourceConfigurerTest.java
@@ -89,7 +89,6 @@ public class SourceConfigurerTest {
                 "camel.k.sources[0].type", "template",
                 "camel.k.sources[1].name", "source1",
                 "camel.k.sources[2].name", "source2",
-                "camel.k.sources[2].type", "source",
                 "camel.k.sources[3].name", "errorHandler1",
                 "camel.k.sources[3].type", "errorHandler"
         ));