This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new b1aad9e CAMEL-15109: The rest-opeanpi component fails to start if the
a component is configured on the rest configuration as the component assumes
there is a 'rest-openapi' component
b1aad9e is described below
commit b1aad9e670b26705262268535a0f2b62929b2aa5
Author: lburgazzoli <[email protected]>
AuthorDate: Mon May 25 13:07:43 2020 +0200
CAMEL-15109: The rest-opeanpi component fails to start if the a component
is configured on the rest configuration as the component assumes there is a
'rest-openapi' component
---
.../camel/component/rest/openapi/RestOpenApiEndpoint.java | 13 +++----------
.../camel/component/rest/swagger/RestSwaggerEndpoint.java | 13 +++----------
2 files changed, 6 insertions(+), 20 deletions(-)
diff --git
a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
index 6bc961a..43b068c 100644
---
a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
+++
b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
@@ -99,9 +99,6 @@ public final class RestOpenApiEndpoint extends
DefaultEndpoint {
*/
Map<String, Object> parameters = Collections.emptyMap();
- /** The name of the Camel component, be it `rest-openapi` or `petstore` */
- private String assignedComponentName;
-
@UriParam(
description = "API basePath, for example \"`/v2`\". Default is unset,
if set overrides the value present in"
+ " OpenApi specification and in the component configuration.",
@@ -161,8 +158,6 @@ public final class RestOpenApiEndpoint extends
DefaultEndpoint {
super(notEmpty(uri, "uri"), notNull(component, "component"));
this.parameters = parameters;
- assignedComponentName = before(uri, ":");
-
final URI componentSpecificationUri = component.getSpecificationUri();
specificationUri = before(remaining, "#",
StringHelper::trimToNull).map(URI::create)
@@ -350,7 +345,7 @@ public final class RestOpenApiEndpoint extends
DefaultEndpoint {
}
final CamelContext camelContext = getCamelContext();
- final RestConfiguration restConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, assignedComponentName);
+ final RestConfiguration restConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, null,
determineComponentName());
final String restConfigurationBasePath =
restConfiguration.getContextPath();
if (isNotEmpty(restConfigurationBasePath)) {
@@ -555,7 +550,7 @@ public final class RestOpenApiEndpoint extends
DefaultEndpoint {
}
final CamelContext camelContext = getCamelContext();
- final RestConfiguration globalRestConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, assignedComponentName);
+ final RestConfiguration globalRestConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, null,
determineComponentName());
final String globalConfigurationHost =
hostFrom(globalRestConfiguration);
if (globalConfigurationHost != null) {
@@ -572,12 +567,10 @@ public final class RestOpenApiEndpoint extends
DefaultEndpoint {
}
}
- final boolean areTheSame =
"rest-openapi".equals(assignedComponentName);
-
throw new IllegalStateException("Unable to determine destination host
for requests. The OpenApi specification"
+ " does not specify `scheme` and `host` parameters, the
specification URI is not absolute with `http` or"
+ " `https` scheme, and no RestConfigurations configured with
`scheme`, `host` and `port` were found for `"
- + (areTheSame ? "rest-openapi` component" : assignedComponentName
+ "` or `rest-openapi` components")
+ + (determineComponentName() != null ? determineComponentName() :
"default" + "` component")
+ " and there is no global RestConfiguration with those
properties");
}
diff --git
a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
index 7e9740e..f635e6e 100644
---
a/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
+++
b/components/camel-rest-swagger/src/main/java/org/apache/camel/component/rest/swagger/RestSwaggerEndpoint.java
@@ -89,9 +89,6 @@ public final class RestSwaggerEndpoint extends
DefaultEndpoint {
*/
Map<String, Object> parameters = Collections.emptyMap();
- /** The name of the Camel component, be it `rest-swagger` or `petstore` */
- private String assignedComponentName;
-
@UriParam(
description = "API basePath, for example \"`/v2`\". Default is unset,
if set overrides the value present in"
+ " Swagger specification and in the component configuration.",
@@ -154,8 +151,6 @@ public final class RestSwaggerEndpoint extends
DefaultEndpoint {
super(notEmpty(uri, "uri"), notNull(component, "component"));
this.parameters = parameters;
- assignedComponentName = before(uri, ":");
-
final URI componentSpecificationUri = component.getSpecificationUri();
specificationUri = before(remaining, "#",
StringHelper::trimToNull).map(URI::create)
@@ -333,7 +328,7 @@ public final class RestSwaggerEndpoint extends
DefaultEndpoint {
}
final CamelContext camelContext = getCamelContext();
- final RestConfiguration restConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, assignedComponentName);
+ final RestConfiguration restConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, null,
determineComponentName());
final String restConfigurationBasePath =
restConfiguration.getContextPath();
if (isNotEmpty(restConfigurationBasePath)) {
@@ -428,7 +423,7 @@ public final class RestSwaggerEndpoint extends
DefaultEndpoint {
}
final CamelContext camelContext = getCamelContext();
- final RestConfiguration globalRestConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, assignedComponentName);
+ final RestConfiguration globalRestConfiguration =
CamelContextHelper.getRestConfiguration(camelContext, null,
determineComponentName());
final String globalConfigurationHost =
hostFrom(globalRestConfiguration);
if (globalConfigurationHost != null) {
@@ -445,12 +440,10 @@ public final class RestSwaggerEndpoint extends
DefaultEndpoint {
}
}
- final boolean areTheSame =
"rest-swagger".equals(assignedComponentName);
-
throw new IllegalStateException("Unable to determine destination host
for requests. The Swagger specification"
+ " does not specify `scheme` and `host` parameters, the
specification URI is not absolute with `http` or"
+ " `https` scheme, and no RestConfigurations configured with
`scheme`, `host` and `port` were found for `"
- + (areTheSame ? "rest-swagger` component" : assignedComponentName
+ "` or `rest-swagger` components")
+ + (determineComponentName() != null ? determineComponentName() :
"default" + "` component")
+ " and there is no global RestConfiguration with those
properties");
}