You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/03/27 08:30:18 UTC

[1/2] camel git commit: Fix potential NPE in camel-rest

Repository: camel
Updated Branches:
  refs/heads/camel-2.18.x bf2991301 -> c67728c6d
  refs/heads/master 9f23caf01 -> 8a75c3f97


Fix potential NPE in camel-rest


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8a75c3f9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8a75c3f9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8a75c3f9

Branch: refs/heads/master
Commit: 8a75c3f97933d3a09b48d810578226d5cbe54f3d
Parents: 9f23caf
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Mar 27 10:05:28 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 27 10:18:33 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/model/rest/RestDefinition.java | 58 ++++++++++----------
 1 file changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8a75c3f9/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index fd30e91..6973f8c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -835,37 +835,39 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
             }
 
             // each {} is a parameter (url templating)
-            String[] arr = allPath.split("\\/");
-            for (String a : arr) {
-                // need to resolve property placeholders first
-                try {
-                    a = camelContext.resolvePropertyPlaceholders(a);
-                } catch (Exception e) {
-                    throw ObjectHelper.wrapRuntimeCamelException(e);
-                }
-                if (a.startsWith("{") && a.endsWith("}")) {
-                    String key = a.substring(1, a.length() - 1);
-                    //  merge if exists
-                    boolean found = false;
-                    for (RestOperationParamDefinition param : verb.getParams()) {
-                        // name is mandatory
-                        String name = param.getName();
-                        ObjectHelper.notEmpty(name, "parameter name");
-                        // need to resolve property placeholders first
-                        try {
-                            name = camelContext.resolvePropertyPlaceholders(name);
-                        } catch (Exception e) {
-                            throw ObjectHelper.wrapRuntimeCamelException(e);
+            if (allPath != null) {
+                String[] arr = allPath.split("\\/");
+                for (String a : arr) {
+                    // need to resolve property placeholders first
+                    try {
+                        a = camelContext.resolvePropertyPlaceholders(a);
+                    } catch (Exception e) {
+                        throw ObjectHelper.wrapRuntimeCamelException(e);
+                    }
+                    if (a.startsWith("{") && a.endsWith("}")) {
+                        String key = a.substring(1, a.length() - 1);
+                        //  merge if exists
+                        boolean found = false;
+                        for (RestOperationParamDefinition param : verb.getParams()) {
+                            // name is mandatory
+                            String name = param.getName();
+                            ObjectHelper.notEmpty(name, "parameter name");
+                            // need to resolve property placeholders first
+                            try {
+                                name = camelContext.resolvePropertyPlaceholders(name);
+                            } catch (Exception e) {
+                                throw ObjectHelper.wrapRuntimeCamelException(e);
+                            }
+                            if (name.equalsIgnoreCase(key)) {
+                                param.type(RestParamType.path);
+                                found = true;
+                                break;
+                            }
                         }
-                        if (name.equalsIgnoreCase(key)) {
-                            param.type(RestParamType.path);
-                            found = true;
-                            break;
+                        if (!found) {
+                            param(verb).name(key).type(RestParamType.path).endParam();
                         }
                     }
-                    if (!found) {
-                        param(verb).name(key).type(RestParamType.path).endParam();
-                    }
                 }
             }
 


[2/2] camel git commit: Fix potential NPE in camel-rest

Posted by da...@apache.org.
Fix potential NPE in camel-rest


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/c67728c6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c67728c6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c67728c6

Branch: refs/heads/camel-2.18.x
Commit: c67728c6d5d9b08256c0f468747d7d6a43a2ea83
Parents: bf29913
Author: Claus Ibsen <da...@apache.org>
Authored: Mon Mar 27 10:05:28 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Mon Mar 27 10:30:11 2017 +0200

----------------------------------------------------------------------
 .../apache/camel/model/rest/RestDefinition.java | 58 ++++++++++----------
 1 file changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c67728c6/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
index c7ba4b8..d0b1c9c 100644
--- a/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestDefinition.java
@@ -815,37 +815,39 @@ public class RestDefinition extends OptionalIdentifiedDefinition<RestDefinition>
             }
 
             // each {} is a parameter (url templating)
-            String[] arr = allPath.split("\\/");
-            for (String a : arr) {
-                // need to resolve property placeholders first
-                try {
-                    a = camelContext.resolvePropertyPlaceholders(a);
-                } catch (Exception e) {
-                    throw ObjectHelper.wrapRuntimeCamelException(e);
-                }
-                if (a.startsWith("{") && a.endsWith("}")) {
-                    String key = a.substring(1, a.length() - 1);
-                    //  merge if exists
-                    boolean found = false;
-                    for (RestOperationParamDefinition param : verb.getParams()) {
-                        // name is mandatory
-                        String name = param.getName();
-                        ObjectHelper.notEmpty(name, "parameter name");
-                        // need to resolve property placeholders first
-                        try {
-                            name = camelContext.resolvePropertyPlaceholders(name);
-                        } catch (Exception e) {
-                            throw ObjectHelper.wrapRuntimeCamelException(e);
+            if (allPath != null) {
+                String[] arr = allPath.split("\\/");
+                for (String a : arr) {
+                    // need to resolve property placeholders first
+                    try {
+                        a = camelContext.resolvePropertyPlaceholders(a);
+                    } catch (Exception e) {
+                        throw ObjectHelper.wrapRuntimeCamelException(e);
+                    }
+                    if (a.startsWith("{") && a.endsWith("}")) {
+                        String key = a.substring(1, a.length() - 1);
+                        //  merge if exists
+                        boolean found = false;
+                        for (RestOperationParamDefinition param : verb.getParams()) {
+                            // name is mandatory
+                            String name = param.getName();
+                            ObjectHelper.notEmpty(name, "parameter name");
+                            // need to resolve property placeholders first
+                            try {
+                                name = camelContext.resolvePropertyPlaceholders(name);
+                            } catch (Exception e) {
+                                throw ObjectHelper.wrapRuntimeCamelException(e);
+                            }
+                            if (name.equalsIgnoreCase(key)) {
+                                param.type(RestParamType.path);
+                                found = true;
+                                break;
+                            }
                         }
-                        if (name.equalsIgnoreCase(key)) {
-                            param.type(RestParamType.path);
-                            found = true;
-                            break;
+                        if (!found) {
+                            param(verb).name(key).type(RestParamType.path).endParam();
                         }
                     }
-                    if (!found) {
-                        param(verb).name(key).type(RestParamType.path).endParam();
-                    }
                 }
             }