Skip to content

Commit 553772f

Browse files
committed
FIX NPE
1 parent 410ff01 commit 553772f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/io/cdap/plugin/MongoDBConfig.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ public void validate() {
160160
if (!containsMacro(MongoDBConstants.HOST) && Strings.isNullOrEmpty(host)) {
161161
throw new InvalidConfigPropertyException("Host must be specified", MongoDBConstants.HOST);
162162
}
163-
if ((!containsMacro(MongoDBConstants.CONNECT_USING_SRV_STRING) && !connectUsingSRVString) &&
164-
!containsMacro(MongoDBConstants.PORT)) {
163+
if (!containsMacro(MongoDBConstants.PORT) && port != null && !containsMacro(
164+
MongoDBConstants.CONNECT_USING_SRV_STRING) && connectUsingSRVString != null && !connectUsingSRVString) {
165+
// Port is not required when SRV is used
165166
if (port < 1) {
166167
throw new InvalidConfigPropertyException("Port number must be greater than 0", MongoDBConstants.PORT);
167168
}

0 commit comments

Comments
 (0)