CAMEL-11216: REST-DSL - Producer fails with NPE or other exceptions if you have 
not set a hostname


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

Branch: refs/heads/camel-2.19.x
Commit: 69e40893cd245f5527fec788ad655251a53d00f3
Parents: 743849a
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue May 23 10:02:04 2017 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue May 23 11:12:50 2017 +0200

----------------------------------------------------------------------
 .../java/org/apache/camel/component/rest/RestEndpoint.java     | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/69e40893/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java 
b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
index e4c95fa..9f8da0a 100644
--- a/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/rest/RestEndpoint.java
@@ -271,6 +271,12 @@ public class RestEndpoint extends DefaultEndpoint {
 
     @Override
     public Producer createProducer() throws Exception {
+        if (ObjectHelper.isEmpty(host)) {
+            // hostname must be provided
+            throw new IllegalArgumentException("Hostname must be configured on 
either restConfiguration"
+                + " or in the rest endpoint uri as a query parameter with name 
host, eg rest:" + method + ":" + path + "?host=someserver");
+        }
+
         RestProducerFactory apiDocFactory = null;
         RestProducerFactory factory = null;
 

Reply via email to