Skip to content

Commit

Permalink
[update][plugin][mongowriter] Replace deprecated MongoClient method
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzhao committed Dec 6, 2023
1 parent 5cfae66 commit 7e5dcc4
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import com.wgzhao.addax.common.exception.AddaxException;
import com.wgzhao.addax.plugin.writer.mongodbwriter.MongoDBWriterErrorCode;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;

import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MongoUtil
Expand Down Expand Up @@ -61,7 +61,7 @@ public static MongoClient initCredentialMongoClient(List<Object> addressList, St
}
try {
MongoCredential credential = MongoCredential.createCredential(userName, database, password.toCharArray());
return new MongoClient(parseServerAddress(addressList), Collections.singletonList(credential));
return new MongoClient(parseServerAddress(addressList), credential, new MongoClientOptions.Builder().build());
}
catch (UnknownHostException e) {
throw AddaxException.asAddaxException(MongoDBWriterErrorCode.ILLEGAL_ADDRESS, "不合法的地址");
Expand Down

0 comments on commit 7e5dcc4

Please sign in to comment.