Skip to content

Commit fd0e235

Browse files
author
mpv1989
committed
Add properties validation arangodb.host
1 parent 2669017 commit fd0e235

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
v4.2.x (xxxx-xx-xx)
22
---------------------------
33
* fixed ArangoDatabase.transaction(): ignore null result
4+
* added properties validation arangodb.host
45

56
v4.2.3 (2017-07-31)
67
---------------------------

src/main/java/com/arangodb/internal/InternalArangoDB.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ protected static void loadHosts(final Properties properties, final Collection<Ho
9090
}
9191

9292
protected static String loadHost(final Properties properties, final String currentValue) {
93-
return getProperty(properties, PROPERTY_KEY_HOST, currentValue, ArangoDBConstants.DEFAULT_HOST);
93+
final String host = getProperty(properties, PROPERTY_KEY_HOST, currentValue, ArangoDBConstants.DEFAULT_HOST);
94+
if (host.contains(":")) {
95+
throw new ArangoDBException(String.format(
96+
"Could not load property-value arangodb.host=%s. Expect only ip. Do you mean arangodb.hosts=ip:port ?",
97+
host));
98+
}
99+
return host;
94100
}
95101

96102
protected static Integer loadPort(final Properties properties, final int currentValue) {

src/test/java/com/arangodb/ArangoDBTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,11 @@ public void loadproperties() {
433433
new ArangoDB.Builder().loadProperties(ArangoDBTest.class.getResourceAsStream("/arangodb-bad.properties"));
434434
}
435435

436+
@Test(expected = ArangoDBException.class)
437+
public void loadproperties2() {
438+
new ArangoDB.Builder().loadProperties(ArangoDBTest.class.getResourceAsStream("/arangodb-bad2.properties"));
439+
}
440+
436441
@Test
437442
public void accessMultipleDatabases() {
438443
try {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
arangodb.host=127.0.0.1:8529

0 commit comments

Comments
 (0)