This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4de6363b5cd4 CAMEL-27624: camel-arangodb - shut down only an own
client, check host and port at startup (#30985)
4de6363b5cd4 is described below
commit 4de6363b5cd48b171301b1328ab0ec992940d732
Author: allthingssecurity <[email protected]>
AuthorDate: Sat Nov 28 01:19:06 2026 +0530
CAMEL-27624: camel-arangodb - shut down only an own client, check host and
port at startup (#30985)
1. ArangoDbEndpoint.doShutdown() shut down any ArangoDB client, also one set
on the endpoint, set on the component or autowired, which the component
passes to every endpoint. When one endpoint was shut down (a removed
route,
or a toD endpoint evicted from the endpoint cache), the other endpoints
failed with "Connection pool already closed!". The endpoint now shuts
down
only the client that it built in doStart().
2. host without port built a client for port 0, so the endpoint started and
failed on the first message. doStart() now fails when no arangoDB client
is
set and host or port is missing, with a message that names the options.
3. getServiceUrl() returned "null:0" when a client is set and host is not.
It now returns null when host is not set, which EndpointServiceLocation
allows.
4. The database path parameter field of ArangoDbEndpoint was never assigned:
the component puts the path into ArangoDbConfiguration.database, which
the
producer reads. The @UriPath moves to ArangoDbConfiguration.database and
the endpoint field is removed. The metadata of the path parameter is the
same, apart from the configurationClass and configurationField that every
option of the configuration carries.
5. host and port cannot be marked required, as an arangoDB client replaces
them. The check of point 2 covers this: without a client, the endpoint
fails to start unless both are set, instead of the driver failing with
"No host has been set!".
Regenerated arangodb.json (component and catalog copy). Upgrade guide entry
for 4.24 for points 1 and 2.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../apache/camel/catalog/components/arangodb.json | 6 +-
.../apache/camel/component/arangodb/arangodb.json | 6 +-
.../component/arangodb/ArangoDbComponent.java | 4 +-
.../component/arangodb/ArangoDbConfiguration.java | 6 ++
.../camel/component/arangodb/ArangoDbEndpoint.java | 34 +++++---
.../component/arangodb/ArangoDbProducerTest.java | 99 +++++++++++++++++++++-
.../arangodb/integration/BaseArangoDb.java | 10 +++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 11 +++
.../dsl/ArangodbComponentBuilderFactory.java | 4 +-
.../dsl/ArangoDbEndpointBuilderFactory.java | 4 +-
10 files changed, 155 insertions(+), 29 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/arangodb.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/arangodb.json
index ed6e5f6de6f7..9478f134e32f 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/arangodb.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/arangodb.json
@@ -33,7 +33,7 @@
"operation": { "index": 6, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "producer", "required": false, "type": "enum",
"javaType": "org.apache.camel.component.arangodb.ArangoDbOperation", "enum": [
"SAVE_DOCUMENT", "FIND_DOCUMENT_BY_KEY", "UPDATE_DOCUMENT", "DELETE_DOCUMENT",
"AQL_QUERY", "SAVE_VERTEX", "FIND_VERTEX_BY_KEY", "UPDATE_VERTEX",
"DELETE_VERTEX", "SAVE_EDGE", "FIND_EDGE_BY_KEY", "UPDATE_EDGE", "DELETE_EDGE"
], "deprecated": false, "autowir [...]
"port": { "index": 7, "kind": "property", "displayName": "Port", "group":
"producer", "label": "producer", "required": false, "type": "integer",
"javaType": "int", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The port of the ArangoDB
server, for example 8529, the default port of ArangoDB. Must be set together
with host, unless the aran [...]
"vertexCollection": { "index": 8, "kind": "property", "displayName":
"Vertex Collection", "group": "producer", "label": "producer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the vertex
collection of the graph for the operations SAVE_VERTEX, FIND_VERTEX_ [...]
- "arangoDB": { "index": 9, "kind": "property", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": true,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client
for all the endpoints of the component. When it is set or autowired, the host,
port, user, password and vertx options are not used. Each endpoint shuts the
client down when it shut [...]
+ "arangoDB": { "index": 9, "kind": "property", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": true,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client
for all the endpoints of the component. When it is set or autowired, the host,
port, user, password and vertx options are not used, and the endpoints do not
shut the client down." },
"autowiredEnabled": { "index": 10, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching [...]
"vertx": { "index": 11, "kind": "property", "displayName": "Vertx",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "io.vertx.core.Vertx", "deprecated": false, "autowired": true,
"secret": false, "description": "To use a custom io.vertx.core.Vertx instance
for the HTTP connections of the ArangoDB clients that the endpoints create. If
not set, the ArangoDB driver creates its own Vert.x instance. Not used when the
arangoDB option sets a client." },
"password": { "index": 12, "kind": "property", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The password of the user
that the ArangoDB client logs in with. Only used when user is [...]
@@ -54,7 +54,7 @@
"producerOut": { "carriers": [ "unknown" ], "byOption": [ { "option":
"operation", "value": "SAVE_DOCUMENT", "carriers": [ "pojo" ] }, { "option":
"operation", "value": "FIND_DOCUMENT_BY_KEY", "carriers": [ "pojo", "null" ] },
{ "option": "operation", "value": "UPDATE_DOCUMENT", "carriers": [ "pojo" ] },
{ "option": "operation", "value": "DELETE_DOCUMENT", "carriers": [ "pojo" ] },
{ "option": "operation", "value": "AQL_QUERY", "carriers": [ "list" ] }, {
"option": "operation", "valu [...]
},
"properties": {
- "database": { "index": 0, "kind": "path", "displayName": "Database",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "The name of the ArangoDB database that the
producer works on. The producer does not create the database." },
+ "database": { "index": 0, "kind": "path", "displayName": "Database",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the ArangoDB
database that the producer works on. The producer does not create the
database." },
"documentCollection": { "index": 1, "kind": "parameter", "displayName":
"Document Collection", "group": "producer", "label": "producer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the document
collection for the operations SAVE_DOCUMENT, FIND_DOCUMENT_BY [...]
"edgeCollection": { "index": 2, "kind": "parameter", "displayName": "Edge
Collection", "group": "producer", "label": "producer", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the edge
collection of the graph for the operations SAVE_EDGE, FIND_EDGE_BY_KEY, U [...]
"graph": { "index": 3, "kind": "parameter", "displayName": "Graph",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the named
graph for the vertex and edge operations, such as SAVE_VERTEX and SAVE_EDGE.
Use it with ve [...]
@@ -63,7 +63,7 @@
"port": { "index": 6, "kind": "parameter", "displayName": "Port", "group":
"producer", "label": "producer", "required": false, "type": "integer",
"javaType": "int", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The port of the ArangoDB
server, for example 8529, the default port of ArangoDB. Must be set together
with host, unless the ara [...]
"vertexCollection": { "index": 7, "kind": "parameter", "displayName":
"Vertex Collection", "group": "producer", "label": "producer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the vertex
collection of the graph for the operations SAVE_VERTEX, FIND_VERTEX [...]
"lazyStartProducer": { "index": 8, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
- "arangoDB": { "index": 9, "kind": "parameter", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": false,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client.
When it is set, or set on the component, the host, port, user, password and
vertx options are not used. The endpoint shuts the client down when it shuts
down." },
+ "arangoDB": { "index": 9, "kind": "parameter", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": false,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client.
When it is set, or set on the component, the host, port, user, password and
vertx options are not used, and the endpoint does not shut the client down." },
"vertx": { "index": 10, "kind": "parameter", "displayName": "Vertx",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "io.vertx.core.Vertx", "deprecated": false, "autowired": false,
"secret": false, "description": "To use a custom io.vertx.core.Vertx instance
for the HTTP connections of the ArangoDB client that the endpoint creates. If
not set, the ArangoDB driver creates its own Vert.x instance. Not used when the
arangoDB option sets a client." },
"password": { "index": 11, "kind": "parameter", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The password of the user
that the ArangoDB client logs in with. Only used when user i [...]
"user": { "index": 12, "kind": "parameter", "displayName": "User",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the user
that the ArangoDB client logs in with. Only used when password is set as [...]
diff --git
a/components/camel-arangodb/src/generated/resources/META-INF/org/apache/camel/component/arangodb/arangodb.json
b/components/camel-arangodb/src/generated/resources/META-INF/org/apache/camel/component/arangodb/arangodb.json
index ed6e5f6de6f7..9478f134e32f 100644
---
a/components/camel-arangodb/src/generated/resources/META-INF/org/apache/camel/component/arangodb/arangodb.json
+++
b/components/camel-arangodb/src/generated/resources/META-INF/org/apache/camel/component/arangodb/arangodb.json
@@ -33,7 +33,7 @@
"operation": { "index": 6, "kind": "property", "displayName": "Operation",
"group": "producer", "label": "producer", "required": false, "type": "enum",
"javaType": "org.apache.camel.component.arangodb.ArangoDbOperation", "enum": [
"SAVE_DOCUMENT", "FIND_DOCUMENT_BY_KEY", "UPDATE_DOCUMENT", "DELETE_DOCUMENT",
"AQL_QUERY", "SAVE_VERTEX", "FIND_VERTEX_BY_KEY", "UPDATE_VERTEX",
"DELETE_VERTEX", "SAVE_EDGE", "FIND_EDGE_BY_KEY", "UPDATE_EDGE", "DELETE_EDGE"
], "deprecated": false, "autowir [...]
"port": { "index": 7, "kind": "property", "displayName": "Port", "group":
"producer", "label": "producer", "required": false, "type": "integer",
"javaType": "int", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The port of the ArangoDB
server, for example 8529, the default port of ArangoDB. Must be set together
with host, unless the aran [...]
"vertexCollection": { "index": 8, "kind": "property", "displayName":
"Vertex Collection", "group": "producer", "label": "producer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the vertex
collection of the graph for the operations SAVE_VERTEX, FIND_VERTEX_ [...]
- "arangoDB": { "index": 9, "kind": "property", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": true,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client
for all the endpoints of the component. When it is set or autowired, the host,
port, user, password and vertx options are not used. Each endpoint shuts the
client down when it shut [...]
+ "arangoDB": { "index": 9, "kind": "property", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": true,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client
for all the endpoints of the component. When it is set or autowired, the host,
port, user, password and vertx options are not used, and the endpoints do not
shut the client down." },
"autowiredEnabled": { "index": 10, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching [...]
"vertx": { "index": 11, "kind": "property", "displayName": "Vertx",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "io.vertx.core.Vertx", "deprecated": false, "autowired": true,
"secret": false, "description": "To use a custom io.vertx.core.Vertx instance
for the HTTP connections of the ArangoDB clients that the endpoints create. If
not set, the ArangoDB driver creates its own Vert.x instance. Not used when the
arangoDB option sets a client." },
"password": { "index": 12, "kind": "property", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The password of the user
that the ArangoDB client logs in with. Only used when user is [...]
@@ -54,7 +54,7 @@
"producerOut": { "carriers": [ "unknown" ], "byOption": [ { "option":
"operation", "value": "SAVE_DOCUMENT", "carriers": [ "pojo" ] }, { "option":
"operation", "value": "FIND_DOCUMENT_BY_KEY", "carriers": [ "pojo", "null" ] },
{ "option": "operation", "value": "UPDATE_DOCUMENT", "carriers": [ "pojo" ] },
{ "option": "operation", "value": "DELETE_DOCUMENT", "carriers": [ "pojo" ] },
{ "option": "operation", "value": "AQL_QUERY", "carriers": [ "list" ] }, {
"option": "operation", "valu [...]
},
"properties": {
- "database": { "index": 0, "kind": "path", "displayName": "Database",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "The name of the ArangoDB database that the
producer works on. The producer does not create the database." },
+ "database": { "index": 0, "kind": "path", "displayName": "Database",
"group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the ArangoDB
database that the producer works on. The producer does not create the
database." },
"documentCollection": { "index": 1, "kind": "parameter", "displayName":
"Document Collection", "group": "producer", "label": "producer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the document
collection for the operations SAVE_DOCUMENT, FIND_DOCUMENT_BY [...]
"edgeCollection": { "index": 2, "kind": "parameter", "displayName": "Edge
Collection", "group": "producer", "label": "producer", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the edge
collection of the graph for the operations SAVE_EDGE, FIND_EDGE_BY_KEY, U [...]
"graph": { "index": 3, "kind": "parameter", "displayName": "Graph",
"group": "producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the named
graph for the vertex and edge operations, such as SAVE_VERTEX and SAVE_EDGE.
Use it with ve [...]
@@ -63,7 +63,7 @@
"port": { "index": 6, "kind": "parameter", "displayName": "Port", "group":
"producer", "label": "producer", "required": false, "type": "integer",
"javaType": "int", "deprecated": false, "autowired": false, "secret": false,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The port of the ArangoDB
server, for example 8529, the default port of ArangoDB. Must be set together
with host, unless the ara [...]
"vertexCollection": { "index": 7, "kind": "parameter", "displayName":
"Vertex Collection", "group": "producer", "label": "producer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the vertex
collection of the graph for the operations SAVE_VERTEX, FIND_VERTEX [...]
"lazyStartProducer": { "index": 8, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
- "arangoDB": { "index": 9, "kind": "parameter", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": false,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client.
When it is set, or set on the component, the host, port, user, password and
vertx options are not used. The endpoint shuts the client down when it shuts
down." },
+ "arangoDB": { "index": 9, "kind": "parameter", "displayName": "Arango DB",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "com.arangodb.ArangoDB", "deprecated": false, "autowired": false,
"secret": false, "description": "To use a custom com.arangodb.ArangoDB client.
When it is set, or set on the component, the host, port, user, password and
vertx options are not used, and the endpoint does not shut the client down." },
"vertx": { "index": 10, "kind": "parameter", "displayName": "Vertx",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType": "io.vertx.core.Vertx", "deprecated": false, "autowired": false,
"secret": false, "description": "To use a custom io.vertx.core.Vertx instance
for the HTTP connections of the ArangoDB client that the endpoint creates. If
not set, the ArangoDB driver creates its own Vert.x instance. Not used when the
arangoDB option sets a client." },
"password": { "index": 11, "kind": "parameter", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The password of the user
that the ArangoDB client logs in with. Only used when user i [...]
"user": { "index": 12, "kind": "parameter", "displayName": "User",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "security": "secret", "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "The name of the user
that the ArangoDB client logs in with. Only used when password is set as [...]
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
index 67dcb8ea5ba1..d395749c6957 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
@@ -32,8 +32,8 @@ public class ArangoDbComponent extends DefaultComponent {
@Metadata(label = "advanced", autowired = true,
description = "To use a custom com.arangodb.ArangoDB client for
all the endpoints of the component. When it is"
- + " set or autowired, the host, port, user,
password and vertx options are not used. Each endpoint"
- + " shuts the client down when it shuts down.")
+ + " set or autowired, the host, port, user,
password and vertx options are not used, and the"
+ + " endpoints do not shut the client down.")
private ArangoDB arangoDB;
@Metadata(label = "advanced", autowired = true,
description = "To use a custom io.vertx.core.Vertx instance for
the HTTP connections of the ArangoDB clients that"
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
index 175fa69eed5d..c9c4b0b0630c 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
@@ -17,11 +17,17 @@
package org.apache.camel.component.arangodb;
import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
@UriParams
public class ArangoDbConfiguration implements Cloneable {
+
+ @UriPath(description = "The name of the ArangoDB database that the
producer works on. The producer does not create the"
+ + " database.")
+ @Metadata(required = true)
private String database;
@UriParam(label = "producer",
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
index abfd64ef2686..07cb559a95f7 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
@@ -29,10 +29,8 @@ import org.apache.camel.spi.BodyType;
import org.apache.camel.spi.BodyType.Carrier;
import org.apache.camel.spi.BodyTypes;
import org.apache.camel.spi.EndpointServiceLocation;
-import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriPath;
import org.apache.camel.support.DefaultEndpoint;
import org.apache.camel.util.ObjectHelper;
@@ -112,17 +110,15 @@ import org.apache.camel.util.ObjectHelper;
+ " a query that returns
nothing; and true for a delete of a vertex or edge"))
public class ArangoDbEndpoint extends DefaultEndpoint implements
EndpointServiceLocation {
- @UriPath(description = "The name of the ArangoDB database that the
producer works on. The producer does not create the"
- + " database.")
- @Metadata(required = true)
- private String database;
@UriParam
private ArangoDbConfiguration configuration;
@UriParam(label = "advanced",
description = "To use a custom com.arangodb.ArangoDB client.
When it is set, or set on the component, the host,"
- + " port, user, password and vertx options are not
used. The endpoint shuts the client down when"
- + " it shuts down.")
+ + " port, user, password and vertx options are not
used, and the endpoint does not shut the client"
+ + " down.")
private ArangoDB arangoDB;
+ // whether doStart built the client, so the endpoint shuts down only a
client it owns
+ private boolean ownsArangoDB;
@UriParam(label = "advanced",
description = "To use a custom io.vertx.core.Vertx instance for
the HTTP connections of the ArangoDB client that"
+ " the endpoint creates. If not set, the ArangoDB
driver creates its own Vert.x instance. Not used"
@@ -139,6 +135,10 @@ public class ArangoDbEndpoint extends DefaultEndpoint
implements EndpointService
@Override
public String getServiceUrl() {
+ // with a client set or autowired, host and port are not used
+ if (ObjectHelper.isEmpty(configuration.getHost())) {
+ return null;
+ }
return configuration.getHost() + ":" + configuration.getPort();
}
@@ -198,12 +198,16 @@ public class ArangoDbEndpoint extends DefaultEndpoint
implements EndpointService
super.doStart();
if (arangoDB == null) {
+ // fail at startup, rather than connecting to port 0 or failing in
the driver without naming the options
+ if (ObjectHelper.isEmpty(configuration.getHost()) ||
configuration.getPort() <= 0) {
+ throw new IllegalArgumentException(
+ "The host and port options must be set on the arangodb
endpoint, or on the component configuration,"
+ + " unless the arangoDB
option sets a client. host: "
+ + configuration.getHost() +
", port: " + configuration.getPort());
+ }
final ArangoDB.Builder builder = new ArangoDB.Builder();
-
- if (ObjectHelper.isNotEmpty(configuration.getHost()) &&
ObjectHelper.isNotEmpty(configuration.getPort())) {
- builder.host(configuration.getHost(), configuration.getPort());
- }
+ builder.host(configuration.getHost(), configuration.getPort());
if (ObjectHelper.isNotEmpty(configuration.getUser()) &&
ObjectHelper.isNotEmpty(configuration.getPassword())) {
builder.user(configuration.getUser()).password(configuration.getPassword());
@@ -214,6 +218,7 @@ public class ArangoDbEndpoint extends DefaultEndpoint
implements EndpointService
}
arangoDB = builder.build();
+ ownsArangoDB = true;
}
}
@@ -221,8 +226,11 @@ public class ArangoDbEndpoint extends DefaultEndpoint
implements EndpointService
@Override
protected void doShutdown() throws Exception {
super.doShutdown();
- if (arangoDB != null) {
+ // a client that was set or autowired may be shared with other
endpoints: leave it to its owner
+ if (arangoDB != null && ownsArangoDB) {
arangoDB.shutdown();
+ arangoDB = null;
+ ownsArangoDB = false;
}
}
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbProducerTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbProducerTest.java
index 1cb201da7825..a215c8153a02 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbProducerTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbProducerTest.java
@@ -41,6 +41,7 @@ import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -54,6 +55,8 @@ class ArangoDbProducerTest extends CamelTestSupport {
private static final String DOCUMENT_API =
"/_db/testDb/_api/document/coll";
private final List<String> requests = new CopyOnWriteArrayList<>();
+ // the endpoints no longer shut down a client from the registry, and
ArangoDB is not Closeable: the test does it
+ private final List<ArangoDB> clients = new CopyOnWriteArrayList<>();
private HttpServer server;
@Override
@@ -66,10 +69,16 @@ class ArangoDbProducerTest extends CamelTestSupport {
@Override
protected void cleanupResources() throws Exception {
- if (server != null) {
- server.stop(0);
+ try {
+ super.cleanupResources();
+ } finally {
+ // each client has a Vert.x instance of its own, with its threads
+ clients.forEach(ArangoDB::shutdown);
+ clients.clear();
+ if (server != null) {
+ server.stop(0);
+ }
}
- super.cleanupResources();
}
@Override
@@ -146,6 +155,86 @@ class ArangoDbProducerTest extends CamelTestSupport {
}
}
+ @Test
+ void sharedClientKeepsWorkingWhenAnotherEndpointShutsDown() {
+ // the autowired client of the component is shared by every endpoint
+ ArangoDbEndpoint other = context.getEndpoint(
+
"arangodb:testDb?documentCollection=other&operation=SAVE_DOCUMENT",
ArangoDbEndpoint.class);
+ other.start();
+ // as for the endpoint of a removed route, or one evicted from the
endpoint cache of a toD
+ other.stop();
+ other.shutdown();
+
+ Exchange result = template.request("direct:save", exchange ->
exchange.getMessage().setBody(Map.of("name", "foo")));
+
+ // the shut down endpoint closed the shared client, so this send failed
+ assertNull(result.getException(), () -> "the exchange failed with " +
result.getException());
+ assertEquals(1, requests.size(), requests::toString);
+ }
+
+ @Test
+ void endpointShutsDownTheClientItBuilt() throws Exception {
+ try (CamelContext camel = new DefaultCamelContext()) {
+ camel.start();
+ ArangoDbEndpoint endpoint = camel.getEndpoint(
+
"arangodb:testDb?documentCollection=coll&operation=SAVE_DOCUMENT&host=localhost&port="
+ +
server.getAddress().getPort(),
+ ArangoDbEndpoint.class);
+ endpoint.start();
+ assertNotNull(endpoint.getArangoDB());
+
+ endpoint.stop();
+ endpoint.shutdown();
+
+ assertNull(endpoint.getArangoDB());
+ }
+ }
+
+ @Test
+ void hostWithoutPortFailsToStart() throws Exception {
+ // the port was 0, so the endpoint started and failed on the first
message
+
assertStartFailsNamingTheOptions("arangodb:testDb?documentCollection=coll&operation=SAVE_DOCUMENT&host=localhost");
+ }
+
+ @Test
+ void noHostNorClientFailsToStart() throws Exception {
+ // the driver failed with "No host has been set!", which names no
option
+
assertStartFailsNamingTheOptions("arangodb:testDb?documentCollection=coll&operation=SAVE_DOCUMENT");
+ }
+
+ private static void assertStartFailsNamingTheOptions(String uri) throws
Exception {
+ try (CamelContext camel = new DefaultCamelContext()) {
+ camel.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:save").to(uri);
+ }
+ });
+
+ Exception error = assertThrows(Exception.class, camel::start);
+
+ Throwable cause = error;
+ while (cause.getCause() != null) {
+ cause = cause.getCause();
+ }
+ assertInstanceOf(IllegalArgumentException.class, cause, () -> "the
context failed with " + error);
+ assertTrue(cause.getMessage().startsWith("The host and port
options must be set"), cause.getMessage());
+ }
+ }
+
+ @Test
+ void serviceUrlIsNullWithoutHost() {
+ ArangoDbEndpoint withClient = context.getEndpoint(
+
"arangodb:testDb?documentCollection=coll&operation=SAVE_DOCUMENT",
ArangoDbEndpoint.class);
+ ArangoDbEndpoint withHost = context.getEndpoint(
+
"arangodb:testDb?documentCollection=coll&operation=SAVE_DOCUMENT&host=db.example.com&port=8529",
+ ArangoDbEndpoint.class);
+
+ // was null:0
+ assertNull(withClient.getServiceUrl());
+ assertEquals("db.example.com:8529", withHost.getServiceUrl());
+ }
+
/**
* A route that sends to an arangodb endpoint without the operation option.
*/
@@ -160,10 +249,12 @@ class ArangoDbProducerTest extends CamelTestSupport {
private ArangoDB newClient() {
// HTTP/1.1, which the JDK HTTP server speaks
- return new ArangoDB.Builder()
+ ArangoDB client = new ArangoDB.Builder()
.host("localhost", server.getAddress().getPort())
.protocol(Protocol.HTTP_JSON)
.build();
+ clients.add(client);
+ return client;
}
private void reply(HttpExchange http) throws IOException {
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
index 552e8bff7451..4e826f8f451b 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/integration/BaseArangoDb.java
@@ -30,6 +30,7 @@ import
org.apache.camel.test.infra.core.annotations.ContextFixture;
import org.apache.camel.test.infra.core.annotations.RouteFixture;
import org.apache.camel.test.infra.core.api.CamelTestSupportHelper;
import org.apache.camel.test.infra.core.api.ConfigurableRoute;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -62,6 +63,15 @@ public abstract class BaseArangoDb implements
ConfigurableRoute, CamelTestSuppor
this.template = getCamelContextExtension().getProducerTemplate();
}
+ @AfterEach
+ void shutdownClient() {
+ // the endpoints do not shut down the client bound to the registry,
and it is not Closeable
+ if (arangoDb != null) {
+ arangoDb.shutdown();
+ arangoDb = null;
+ }
+ }
+
@ContextFixture
public void createCamelContext(CamelContext ctx) {
arangoDb = new ArangoDB.Builder().host(service.host(),
service.port()).build();
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 06fa8d603aee..17af91664876 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -12458,6 +12458,17 @@ With `useScroll=true`, the
`ElasticsearchScrollRequestIterator` now closes itsel
clears the scroll on the node and, with `disconnect=true`, closes the client
the scroll was read with. Close the
iterator yourself when you stop reading before the end.
+=== camel-arangodb - the endpoint shuts down only a client it built, and
checks host and port at startup
+
+An `arangodb` endpoint no longer shuts down an `arangoDB` client that was set
on the endpoint, set on the component or
+autowired from the registry, as that client is shared by all the endpoints of
the component. The application that
+created the client shuts it down, for example with
`@BindToRegistry(destroyMethod = "shutdown")` on the method that
+creates it (Spring already calls `shutdown` on an `ArangoDB` `@Bean`). A
client that the endpoint built from `host`
+and `port` is shut down with the endpoint, as before.
+
+Without an `arangoDB` client, an endpoint now fails to start when `host` or
`port` is not set. Before, `host` without
+`port` connected to port 0, so each message failed.
+
=== camel-ldif - a body that is not a URL fails with InvalidPayloadException
With `allowUrlBody=true`, a body that does not start with `version: 1` and is
not a valid absolute URL, such as a text
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
index 52cd7b2e2a97..b794fb51df09 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
@@ -217,8 +217,8 @@ public interface ArangodbComponentBuilderFactory {
/**
* To use a custom com.arangodb.ArangoDB client for all the endpoints
of
* the component. When it is set or autowired, the host, port, user,
- * password and vertx options are not used. Each endpoint shuts the
- * client down when it shuts down.
+ * password and vertx options are not used, and the endpoints do not
+ * shut the client down.
*
* The option is a: <code>com.arangodb.ArangoDB</code>
type.
*
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ArangoDbEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ArangoDbEndpointBuilderFactory.java
index d53568e5bb5e..ec65667bf354 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ArangoDbEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/ArangoDbEndpointBuilderFactory.java
@@ -287,7 +287,7 @@ public interface ArangoDbEndpointBuilderFactory {
/**
* To use a custom com.arangodb.ArangoDB client. When it is set, or set
* on the component, the host, port, user, password and vertx options
- * are not used. The endpoint shuts the client down when it shuts down.
+ * are not used, and the endpoint does not shut the client down.
*
* The option is a: <code>com.arangodb.ArangoDB</code> type.
*
@@ -303,7 +303,7 @@ public interface ArangoDbEndpointBuilderFactory {
/**
* To use a custom com.arangodb.ArangoDB client. When it is set, or set
* on the component, the host, port, user, password and vertx options
- * are not used. The endpoint shuts the client down when it shuts down.
+ * are not used, and the endpoint does not shut the client down.
*
* The option will be converted to a <code>com.arangodb.ArangoDB</code>
* type.