diff --git a/ChangeLog.md b/ChangeLog.md
index 4afd3d9c4..77252bc09 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
## [Unreleased]
+### Changed
+
+- changed `ArangoDB#timeout` to also set the request timeout when using VelocyStream (issue #230)
+
### Fixed
- fixed compatibility of `ArangoCursor#filter` with Java 6
diff --git a/docs/Drivers/Java/Reference/Setup.md b/docs/Drivers/Java/Reference/Setup.md
index 97cf08a5f..8dc314439 100644
--- a/docs/Drivers/Java/Reference/Setup.md
+++ b/docs/Drivers/Java/Reference/Setup.md
@@ -12,7 +12,7 @@ The driver is configured with some default values:
property-key | description | default value |
arangodb.hosts | ArangoDB hosts | 127.0.0.1:8529 |
-arangodb.timeout | socket connect timeout(millisecond) | 0 |
+arangodb.timeout | connect & request timeout(millisecond) | 0 |
arangodb.user | Basic Authentication User | |
arangodb.password | Basic Authentication Password | |
arangodb.useSsl | use SSL connection | false |
diff --git a/src/main/java/com/arangodb/ArangoDB.java b/src/main/java/com/arangodb/ArangoDB.java
index 683b25bbe..1a7b4a73c 100644
--- a/src/main/java/com/arangodb/ArangoDB.java
+++ b/src/main/java/com/arangodb/ArangoDB.java
@@ -75,23 +75,23 @@
/**
* Central access point for applications to communicate with an ArangoDB server.
- *
+ *
*
* Will be instantiated through {@link ArangoDB.Builder}
*
- *
+ *
*
* ArangoDB arango = new ArangoDB.Builder().build();
* ArangoDB arango = new ArangoDB.Builder().host("127.0.0.1", 8529).build();
*
- *
+ *
* @author Mark Vollmary
*/
public interface ArangoDB extends ArangoSerializationAccessor {
/**
* Builder class to build an instance of {@link ArangoDB}.
- *
+ *
* @author Mark Vollmary
*/
public static class Builder extends InternalArangoDBBuilder {
@@ -129,7 +129,7 @@ public Builder loadProperties(final InputStream in) throws ArangoDBException {
/**
* Adds a host to connect to. Multiple hosts can be added to provide fallbacks.
- *
+ *
* @param host
* address of the host
* @param port
@@ -142,19 +142,10 @@ public Builder host(final String host, final int port) {
}
/**
- * Sets the timeout in milliseconds.
- *
- *
- * For network protocol {@link Protocol#VST} it is used as socket timeout when opening a VecloyStream
- * connection.
- *
- *
- * For network protocol {@link Protocol#HTTP_JSON} and {@link Protocol#HTTP_VPACK} it is used as timeout for a
- * single request.
- *
- *
+ * Sets the connection and request timeout in milliseconds.
+ *
* @param timeout
- * timeout in milliseconds
+ * timeout in milliseconds
* @return {@link ArangoDB.Builder}
*/
public Builder timeout(final Integer timeout) {
@@ -164,7 +155,7 @@ public Builder timeout(final Integer timeout) {
/**
* Sets the username to use for authentication.
- *
+ *
* @param user
* the user in the database (default: {@code root})
* @return {@link ArangoDB.Builder}
@@ -176,7 +167,7 @@ public Builder user(final String user) {
/**
* Sets the password for the user for authentication.
- *
+ *
* @param password
* the password of the user in the database (default: {@code null})
* @return {@link ArangoDB.Builder}
@@ -188,7 +179,7 @@ public Builder password(final String password) {
/**
* If set to {@code true} SSL will be used when connecting to an ArangoDB server.
- *
+ *
* @param useSsl
* whether or not use SSL (default: {@code false})
* @return {@link ArangoDB.Builder}
@@ -200,7 +191,7 @@ public Builder useSsl(final Boolean useSsl) {
/**
* Sets the SSL context to be used when {@code true} is passed through {@link #useSsl(Boolean)}.
- *
+ *
* @param sslContext
* SSL context to be used
* @return {@link ArangoDB.Builder}
@@ -212,7 +203,7 @@ public Builder sslContext(final SSLContext sslContext) {
/**
* Sets the chunk size when {@link Protocol#VST} is used.
- *
+ *
* @param chunksize
* size of a chunk in bytes
* @return {@link ArangoDB.Builder}
@@ -224,17 +215,17 @@ public Builder chunksize(final Integer chunksize) {
/**
* Sets the maximum number of connections the built in connection pool will open per host.
- *
+ *
*
* Defaults:
*
- *
+ *
*
* {@link Protocol#VST} == 1
* {@link Protocol#HTTP_JSON} == 20
* {@link Protocol#HTTP_VPACK} == 20
*
- *
+ *
* @param maxConnections
* max number of connections
* @return {@link ArangoDB.Builder}
@@ -246,7 +237,7 @@ public Builder maxConnections(final Integer maxConnections) {
/**
* Set the maximum time to life of a connection. After this time the connection will be closed automatically.
- *
+ *
* @param connectionTtl
* the maximum time to life of a connection.
* @return {@link ArangoDB.Builder}
@@ -259,11 +250,11 @@ public Builder connectionTtl(final Long connectionTtl) {
/**
* Whether or not the driver should acquire a list of available coordinators in an ArangoDB cluster or a single
* server with active failover.
- *
+ *
*
* The host list will be used for failover and load balancing.
*
- *
+ *
* @param acquireHostList
* whether or not automatically acquire a list of available hosts (default: false)
* @return {@link ArangoDB.Builder}
@@ -275,7 +266,7 @@ public Builder acquireHostList(final Boolean acquireHostList) {
/**
* Sets the load balancing strategy to be used in an ArangoDB cluster setup.
- *
+ *
* @param loadBalancingStrategy
* the load balancing strategy to be used (default: {@link LoadBalancingStrategy#NONE}
* @return {@link ArangoDB.Builder}
@@ -288,11 +279,11 @@ public Builder loadBalancingStrategy(final LoadBalancingStrategy loadBalancingSt
/**
* Register a custom {@link VPackSerializer} for a specific type to be used within the internal serialization
* process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param clazz
* the type the serializer should be registered for
* @param serializer
@@ -306,11 +297,11 @@ public Builder registerSerializer(final Class clazz, final VPackSerialize
/**
* Register a special serializer for a member class which can only be identified by its enclosing class.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param clazz
* the type of the enclosing class
* @param serializer
@@ -325,11 +316,11 @@ public Builder registerEnclosingSerializer(final Class clazz, final VPack
/**
* Register a custom {@link VPackDeserializer} for a specific type to be used within the internal serialization
* process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param clazz
* the type the serializer should be registered for
* @param deserializer
@@ -343,11 +334,11 @@ public Builder registerDeserializer(final Class clazz, final VPackDeseria
/**
* Register a custom {@link VPackInstanceCreator} for a specific type to be used within the internal
* serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param clazz
* the type the instance creator should be registered for
* @param creator
@@ -361,11 +352,11 @@ public Builder registerInstanceCreator(final Class clazz, final VPackInst
/**
* Register a custom {@link VPackJsonDeserializer} for a specific type to be used within the internal
* serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param type
* the type the serializer should be registered for
* @param deserializer
@@ -379,11 +370,11 @@ public Builder registerJsonDeserializer(final ValueType type, final VPackJsonDes
/**
* Register a custom {@link VPackJsonDeserializer} for a specific type and attribute name to be used within the
* internal serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param attribute
* @param type
* the type the serializer should be registered for
@@ -401,11 +392,11 @@ public Builder registerJsonDeserializer(
/**
* Register a custom {@link VPackJsonSerializer} for a specific type to be used within the internal
* serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param clazz
* the type the serializer should be registered for
* @param serializer
@@ -419,11 +410,11 @@ public Builder registerJsonSerializer(final Class clazz, final VPackJsonS
/**
* Register a custom {@link VPackJsonSerializer} for a specific type and attribute name to be used within the
* internal serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param attribute
* @param clazz
* the type the serializer should be registered for
@@ -441,11 +432,11 @@ public Builder registerJsonSerializer(
/**
* Register a custom {@link VPackAnnotationFieldFilter} for a specific type to be used within the internal
* serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param type
* the type the serializer should be registered for
* @param fieldFilter
@@ -461,11 +452,11 @@ public Builder annotationFieldFilter(
/**
* Register a custom {@link VPackAnnotationFieldNaming} for a specific type to be used within the internal
* serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param type
* the type the serializer should be registered for
* @param fieldNaming
@@ -480,11 +471,11 @@ public Builder annotationFieldNaming(
/**
* Register a {@link VPackModule} to be used within the internal serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
- *
+ *
* @param module
* module to register
* @return {@link ArangoDB.Builder}
@@ -496,7 +487,7 @@ public Builder registerModule(final VPackModule module) {
/**
* Register a list of {@link VPackModule} to be used within the internal serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
@@ -512,7 +503,7 @@ public Builder registerModules(final VPackModule... modules) {
/**
* Register a {@link VPackParserModule} to be used within the internal serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
@@ -528,7 +519,7 @@ public Builder registerJsonModule(final VPackParserModule module) {
/**
* Register a list of {@link VPackParserModule} to be used within the internal serialization process.
- *
+ *
*
* Attention:can not be used together with {@link #serializer(ArangoSerialization)}
*
@@ -544,10 +535,10 @@ public Builder registerJsonModules(final VPackParserModule... modules) {
/**
* Replace the built-in serializer with the given serializer.
- *
+ *
*
* ATTENTION!: Use at your own risk
- *
+ *
* @param serializer
* custom serializer
* @deprecated use {@link #serializer(ArangoSerialization)} instead
@@ -561,10 +552,10 @@ public Builder setSerializer(final ArangoSerializer serializer) {
/**
* Replace the built-in deserializer with the given deserializer.
- *
+ *
*
* ATTENTION!: Use at your own risk
- *
+ *
* @param deserializer
* custom deserializer
* @deprecated use {@link #serializer(ArangoSerialization)} instead
@@ -578,10 +569,10 @@ public Builder setDeserializer(final ArangoDeserializer deserializer) {
/**
* Replace the built-in serializer/deserializer with the given one.
- *
+ *
*
* ATTENTION!: Any registered custom serializer/deserializer or module will be ignored.
- *
+ *
* @param serialization
* custom serializer/deserializer
* @return {@link ArangoDB.Builder}
@@ -593,7 +584,7 @@ public Builder serializer(final ArangoSerialization serialization) {
/**
* Returns an instance of {@link ArangoDB}.
- *
+ *
* @return {@link ArangoDB}
*/
public synchronized ArangoDB build() {
@@ -635,21 +626,21 @@ public synchronized ArangoDB build() {
/**
* Releases all connections to the server and clear the connection pool.
- *
+ *
* @throws ArangoDBException
*/
void shutdown() throws ArangoDBException;
/**
* Returns a {@code ArangoDatabase} instance for the {@code _system} database.
- *
+ *
* @return database handler
*/
ArangoDatabase db();
/**
* Returns a {@code ArangoDatabase} instance for the given database name.
- *
+ *
* @param name
* Name of the database
* @return database handler
@@ -658,7 +649,7 @@ public synchronized ArangoDB build() {
/**
* Creates a new database with the given name.
- *
+ *
* @see API
* Documentation
* @param name
@@ -670,7 +661,7 @@ public synchronized ArangoDB build() {
/**
* Retrieves a list of all existing databases
- *
+ *
* @see API
* Documentation
* @return a list of all existing databases
@@ -680,7 +671,7 @@ public synchronized ArangoDB build() {
/**
* Retrieves a list of all databases the current user can access
- *
+ *
* @see API
* Documentation
@@ -691,7 +682,7 @@ public synchronized ArangoDB build() {
/**
* List available database to the specified user
- *
+ *
* @see API
* Documentation
@@ -704,7 +695,7 @@ public synchronized ArangoDB build() {
/**
* Returns the server name and version number.
- *
+ *
* @see API
* Documentation
* @return the server version, number
@@ -714,7 +705,7 @@ public synchronized ArangoDB build() {
/**
* Returns the server role.
- *
+ *
* @return the server role
* @throws ArangoDBException
*/
@@ -723,7 +714,7 @@ public synchronized ArangoDB build() {
/**
* Create a new user. This user will not have access to any database. You need permission to the _system database in
* order to execute this call.
- *
+ *
* @see API Documentation
* @param user
* The name of the user
@@ -737,7 +728,7 @@ public synchronized ArangoDB build() {
/**
* Create a new user. This user will not have access to any database. You need permission to the _system database in
* order to execute this call.
- *
+ *
* @see API Documentation
* @param user
* The name of the user
@@ -752,7 +743,7 @@ public synchronized ArangoDB build() {
/**
* Removes an existing user, identified by user. You need access to the _system database.
- *
+ *
* @see API Documentation
* @param user
* The name of the user
@@ -763,7 +754,7 @@ public synchronized ArangoDB build() {
/**
* Fetches data about the specified user. You can fetch information about yourself or you need permission to the
* _system database in order to execute this call.
- *
+ *
* @see API Documentation
* @param user
* The name of the user
@@ -774,7 +765,7 @@ public synchronized ArangoDB build() {
/**
* Fetches data about all users. You can only execute this call if you have access to the _system database.
- *
+ *
* @see API
* Documentation
* @return informations about all users
@@ -785,7 +776,7 @@ public synchronized ArangoDB build() {
/**
* Partially updates the data of an existing user. The name of an existing user must be specified in user. You can
* only change the password of your self. You need access to the _system database to change the active flag.
- *
+ *
* @see API Documentation
* @param user
* The name of the user
@@ -799,7 +790,7 @@ public synchronized ArangoDB build() {
/**
* Replaces the data of an existing user. The name of an existing user must be specified in user. You can only
* change the password of your self. You need access to the _system database to change the active flag.
- *
+ *
* @see API
* Documentation
* @param user
@@ -814,7 +805,7 @@ public synchronized ArangoDB build() {
/**
* Sets the default access level for databases for the user {@code user}. You need permission to the _system
* database in order to execute this call.
- *
+ *
* @param user
* The name of the user
* @param permissions
@@ -827,7 +818,7 @@ public synchronized ArangoDB build() {
/**
* Sets the default access level for collections for the user {@code user}. You need permission to the _system
* database in order to execute this call.
- *
+ *
* @param user
* The name of the user
* @param permissions
@@ -839,7 +830,7 @@ public synchronized ArangoDB build() {
/**
* Generic Execute. Use this method to execute custom FOXX services.
- *
+ *
* @param request
* VelocyStream request
* @return VelocyStream response
@@ -849,7 +840,7 @@ public synchronized ArangoDB build() {
/**
* Generic Execute. Use this method to execute custom FOXX services.
- *
+ *
* @param request
* VelocyStream request
* @param hostHandle
@@ -861,7 +852,7 @@ public synchronized ArangoDB build() {
/**
* Returns fatal, error, warning or info log messages from the server's global log.
- *
+ *
* @see API
* Documentation
@@ -874,7 +865,7 @@ public synchronized ArangoDB build() {
/**
* Returns the server's current loglevel settings.
- *
+ *
* @return the server's current loglevel settings
* @since ArangoDB 3.1.0
* @throws ArangoDBException
@@ -883,7 +874,7 @@ public synchronized ArangoDB build() {
/**
* Modifies and returns the server's current loglevel settings.
- *
+ *
* @param entity
* loglevel settings
* @return the server's current loglevel settings
@@ -894,7 +885,7 @@ public synchronized ArangoDB build() {
/**
* Attention: Please do not use!
- *
+ *
* @param cursorInitializer
* @return ArangoDB
*/
diff --git a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java
index 33f627fec..2d9cb1d93 100644
--- a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java
+++ b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnection.java
@@ -60,7 +60,7 @@ public abstract class VstConnection implements Connection {
private ExecutorService executor;
protected final MessageStore messageStore;
- private final Integer timeout;
+ protected final Integer timeout;
private final Long ttl;
private final Boolean useSsl;
private final SSLContext sslContext;
diff --git a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java
index 35fdf6827..2e8a8b96b 100644
--- a/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java
+++ b/src/main/java/com/arangodb/internal/velocystream/internal/VstConnectionSync.java
@@ -22,9 +22,8 @@
import java.util.Collection;
import java.util.concurrent.Callable;
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;
+import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLContext;
@@ -96,12 +95,8 @@ public Message call() throws Exception {
messageStore.storeMessage(message.getId(), task);
super.writeIntern(message, chunks);
try {
- return task.get();
- } catch (final InterruptedException e) {
- throw new ArangoDBException(e);
- } catch (final ExecutionException e) {
- throw new ArangoDBException(e);
- } catch (final CancellationException e) {
+ return timeout == null || timeout == 0L ? task.get() : task.get(timeout, TimeUnit.MILLISECONDS);
+ } catch (final Exception e) {
throw new ArangoDBException(e);
}
}