File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -827,12 +827,12 @@ public String getConnectionString() {
827
827
828
828
829
829
/**
830
- * Gets the credentials.
830
+ * Gets the credentials in an immutable list. The list will be empty if no credentials were specified in the connection string .
831
831
*
832
- * @return the credentials
832
+ * @return the credentials in an immutable list
833
833
*/
834
834
public List <MongoCredential > getCredentialList () {
835
- return credentials != null ? asList (credentials ) : new ArrayList <MongoCredential >();
835
+ return credentials != null ? singletonList (credentials ) : Collections . <MongoCredential >emptyList ();
836
836
}
837
837
838
838
/**
Original file line number Diff line number Diff line change @@ -252,6 +252,18 @@ class ConnectionStringSpecification extends Specification {
252
252
.withMechanismProperty(' SERVICE_REALM' , ' AWESOME' ))
253
253
}
254
254
255
+ @Unroll
256
+ def ' should create immutable credential list' () {
257
+ when :
258
+ uri. credentialList. add(createGSSAPICredential(' user' ))
259
+
260
+ then :
261
+ thrown(UnsupportedOperationException )
262
+
263
+ where :
264
+ uri << [new ConnectionString (' mongodb://jeff:123@localhost' ), new ConnectionString (' mongodb://localhost' )]
265
+ }
266
+
255
267
def ' should support thrown an IllegalArgumentException when given invalid authMechanismProperties' () {
256
268
when :
257
269
new ConnectionString (' mongodb://jeff@localhost/?' +
You can’t perform that action at this time.
0 commit comments