Skip to content

Commit 4e93808

Browse files
committed
adding MongoDBStack host safety
1 parent 1f0158f commit 4e93808

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/picoded/dstack/mongodb/MongoDBStack.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ public static String getFullConnectionURL_primary(GenericConvertMap<String, Obje
106106
String protocol = config.getString("protocol", "mongodb");
107107
String user = config.getString("user", null);
108108
String pass = config.getString("pass", null);
109-
String host = config.getString("host", "localhost");
109+
String host = config.getString("host", null);
110110
int port = config.getInt("port", 27017);
111111

112+
// Safety check
113+
if( host == null ) {
114+
throw IllegalArgumentException("Missing valid host setting for MongoDB connection");
115+
}
116+
112117
// Hanlding of option string
113118
GenericConvertMap<String, Object> optMap = config.getGenericConvertStringMap("opt",
114119
defaultOptJson);

0 commit comments

Comments
 (0)