Skip to content

Commit c45dae7

Browse files
committed
Corrected Java 1.6 error message where invalidHostNameAllowed is false
JAVA-2490
1 parent 3db93a2 commit c45dae7

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

driver-core/src/main/com/mongodb/connection/SslSettings.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@ public boolean isInvalidHostNameAllowed() {
121121
SslSettings(final Builder builder) {
122122
enabled = builder.enabled;
123123
invalidHostNameAllowed = builder.invalidHostNameAllowed;
124-
if (enabled && !invalidHostNameAllowed) {
125-
if (System.getProperty("java.version").startsWith("1.6.")) {
126-
throw new MongoInternalException("By default, SSL connections are only supported on Java 7 or later. If the application "
127-
+ "must run on Java 6, you must set the SslSettings.invalidHostNameAllowed property to "
128-
+ "false");
129-
}
124+
if (enabled && !invalidHostNameAllowed && System.getProperty("java.version").startsWith("1.6.")) {
125+
throw new MongoInternalException("By default, SSL connections are only supported on Java 7 or later. If the application "
126+
+ "must run on Java 6, you must set the SslSettings.invalidHostNameAllowed property to "
127+
+ "true");
130128
}
131129
}
132130

driver/src/main/com/mongodb/MongoClientOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ private MongoClientOptions(final Builder builder) {
174174
// The error message from SslSettings needs to be translated to make sense for users of MongoClientOptions
175175
throw new MongoInternalException("By default, SSL connections are only supported on Java 7 or later. If the application "
176176
+ "must run on Java 6, you must set the MongoClientOptions.sslInvalidHostNameAllowed "
177-
+ "property to false");
177+
+ "property to true");
178178
}
179179
}
180180

0 commit comments

Comments
 (0)