Skip to content

Commit b8e38fe

Browse files
committed
Updated Javadoc for MongoClient, Mongo, and ServerAddress constructors to indicate that UnknownHostException and MongoException
are no longer thrown. JAVA-1625
1 parent 6b2059c commit b8e38fe

File tree

3 files changed

+36
-37
lines changed

3 files changed

+36
-37
lines changed

src/main/com/mongodb/Mongo.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ public static DB connect( DBAddress addr ){
137137
/**
138138
* Creates a Mongo instance based on a (single) mongodb node (localhost, default port)
139139
*
140-
* @throws UnknownHostException
141-
* @throws MongoException
140+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
141+
* compatibility. The exception will be removed from the declaration in the next major release of the
142+
* driver.
142143
* @deprecated Replaced by {@link MongoClient#MongoClient()})
143144
*/
144145
@Deprecated
@@ -150,8 +151,9 @@ public Mongo() throws UnknownHostException {
150151
* Creates a Mongo instance based on a (single) mongodb node (default port)
151152
*
152153
* @param host server to connect to
153-
* @throws UnknownHostException if the database host cannot be resolved
154-
* @throws MongoException
154+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
155+
* compatibility. The exception will be removed from the declaration in the next major release of the
156+
* driver.
155157
* @deprecated Replaced by {@link MongoClient#MongoClient(String)}
156158
*/
157159
@Deprecated
@@ -165,8 +167,9 @@ public Mongo(String host)
165167
*
166168
* @param host server to connect to
167169
* @param options default query options
168-
* @throws UnknownHostException if the database host cannot be resolved
169-
* @throws MongoException
170+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
171+
* compatibility. The exception will be removed from the declaration in the next major release of the
172+
* driver.
170173
* @deprecated Replaced by {@link MongoClient#MongoClient(String, MongoClientOptions)}
171174
*/
172175
@Deprecated
@@ -180,8 +183,9 @@ public Mongo(String host, MongoOptions options)
180183
*
181184
* @param host the database's host address
182185
* @param port the port on which the database is running
183-
* @throws UnknownHostException if the database host cannot be resolved
184-
* @throws MongoException
186+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
187+
* compatibility. The exception will be removed from the declaration in the next major release of the
188+
* driver.
185189
* @deprecated Replaced by {@link MongoClient#MongoClient(String, int)}
186190
*/
187191
@Deprecated
@@ -194,7 +198,6 @@ public Mongo(String host, int port)
194198
* Creates a Mongo instance based on a (single) mongodb node
195199
*
196200
* @param addr the database address
197-
* @throws MongoException
198201
* @see com.mongodb.ServerAddress
199202
* @deprecated Replaced by {@link MongoClient#MongoClient(ServerAddress)}
200203
*/
@@ -208,7 +211,6 @@ public Mongo(ServerAddress addr) {
208211
*
209212
* @param addr the database address
210213
* @param options default query options
211-
* @throws MongoException
212214
* @see com.mongodb.ServerAddress
213215
* @deprecated Replaced by {@link MongoClient#MongoClient(ServerAddress, MongoClientOptions)}
214216
*/
@@ -224,7 +226,6 @@ public Mongo(ServerAddress addr, MongoOptions options) {
224226
* @param left left side of the pair
225227
* @param right right side of the pair
226228
* @throws MongoException
227-
* @see com.mongodb.ServerAddress
228229
*/
229230
@Deprecated
230231
public Mongo(ServerAddress left, ServerAddress right) {
@@ -238,7 +239,6 @@ public Mongo(ServerAddress left, ServerAddress right) {
238239
* @param left left side of the pair
239240
* @param right right side of the pair
240241
* @param options the optional settings for the Mongo instance
241-
* @throws MongoException
242242
* @see com.mongodb.ServerAddress
243243
* @deprecated Please use {@link MongoClient#MongoClient(java.util.List, MongoClientOptions)} instead.
244244
*/
@@ -257,7 +257,6 @@ public Mongo(ServerAddress left, ServerAddress right, MongoOptions options) {
257257
*
258258
* @param seeds Put as many servers as you can in the list and the system will figure out the rest. This can either be a list of mongod
259259
* servers in the same replica set or a list of mongos servers in the same sharded cluster.
260-
* @throws MongoException
261260
* @see com.mongodb.ServerAddress
262261
* @deprecated Replaced by {@link MongoClient#MongoClient(java.util.List)}
263262
*/
@@ -277,7 +276,6 @@ public Mongo(List<ServerAddress> seeds) {
277276
* @param seeds Put as many servers as you can in the list and the system will figure out the rest. This can either be a list of
278277
* mongod servers in the same replica set or a list of mongos servers in the same sharded cluster.
279278
* @param options for configuring this Mongo instance
280-
* @throws MongoException
281279
* @see com.mongodb.ServerAddress
282280
* @deprecated Replaced by {@link MongoClient#MongoClient(java.util.List, MongoClientOptions)}
283281
*/
@@ -297,7 +295,6 @@ public Mongo( List<ServerAddress> seeds , MongoOptions options ) {
297295
* </ul>
298296
*
299297
* @param uri URI to connect to, optionally containing additional information like credentials
300-
* @throws MongoException
301298
* @mongodb.driver.manual reference/connection-string Connection String URI Format
302299
* @see MongoURI
303300
* @deprecated Replaced by {@link MongoClient#MongoClient(MongoClientURI)}

src/main/com/mongodb/MongoClient.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ public class MongoClient extends Mongo {
7171
/**
7272
* Creates an instance based on a (single) mongodb node (localhost, default port).
7373
*
74-
* @throws UnknownHostException
75-
* @throws MongoException
74+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
75+
* compatibility. The exception will be removed from the declaration in the next major release of the
76+
* driver.
7677
*/
7778
public MongoClient() throws UnknownHostException {
7879
this(new ServerAddress());
@@ -82,8 +83,9 @@ public MongoClient() throws UnknownHostException {
8283
* Creates a Mongo instance based on a (single) mongodb node.
8384
*
8485
* @param host server to connect to in format host[:port]
85-
* @throws UnknownHostException if the database host cannot be resolved
86-
* @throws MongoException
86+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
87+
* compatibility. The exception will be removed from the declaration in the next major release of the
88+
* driver.
8789
*/
8890
public MongoClient(String host) throws UnknownHostException {
8991
this(new ServerAddress(host));
@@ -94,8 +96,9 @@ public MongoClient(String host) throws UnknownHostException {
9496
*
9597
* @param host server to connect to in format host[:port]
9698
* @param options default query options
97-
* @throws UnknownHostException if the database host cannot be resolved
98-
* @throws MongoException
99+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
100+
* compatibility. The exception will be removed from the declaration in the next major release of the
101+
* driver.
99102
*/
100103
public MongoClient(String host, MongoClientOptions options) throws UnknownHostException {
101104
this(new ServerAddress(host), options);
@@ -106,8 +109,9 @@ public MongoClient(String host, MongoClientOptions options) throws UnknownHostEx
106109
*
107110
* @param host the database's host address
108111
* @param port the port on which the database is running
109-
* @throws UnknownHostException if the database host cannot be resolved
110-
* @throws MongoException
112+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
113+
* compatibility. The exception will be removed from the declaration in the next major release of the
114+
* driver.
111115
*/
112116
public MongoClient(String host, int port) throws UnknownHostException {
113117
this(new ServerAddress(host, port));
@@ -117,7 +121,6 @@ public MongoClient(String host, int port) throws UnknownHostException {
117121
* Creates a Mongo instance based on a (single) mongodb node
118122
*
119123
* @param addr the database address
120-
* @throws MongoException
121124
* @see com.mongodb.ServerAddress
122125
*/
123126
public MongoClient(ServerAddress addr) {
@@ -129,7 +132,6 @@ public MongoClient(ServerAddress addr) {
129132
*
130133
* @param addr the database address
131134
* @param credentialsList the list of credentials used to authenticate all connections
132-
* @throws MongoException
133135
* @see com.mongodb.ServerAddress
134136
* @since 2.11.0
135137
*/
@@ -142,7 +144,6 @@ public MongoClient(ServerAddress addr, List<MongoCredential> credentialsList) {
142144
*
143145
* @param addr the database address
144146
* @param options default options
145-
* @throws MongoException
146147
* @see com.mongodb.ServerAddress
147148
*/
148149
public MongoClient(ServerAddress addr, MongoClientOptions options) {
@@ -155,7 +156,6 @@ public MongoClient(ServerAddress addr, MongoClientOptions options) {
155156
* @param addr the database address
156157
* @param credentialsList the list of credentials used to authenticate all connections
157158
* @param options default options
158-
* @throws MongoException
159159
* @see com.mongodb.ServerAddress
160160
* @since 2.11.0
161161
*/
@@ -175,7 +175,6 @@ public MongoClient(ServerAddress addr, List<MongoCredential> credentialsList, Mo
175175
*
176176
* @param seeds Put as many servers as you can in the list and the system will figure out the rest. This can either be a list of mongod
177177
* servers in the same replica set or a list of mongos servers in the same sharded cluster.
178-
* @throws MongoException
179178
* @see com.mongodb.ServerAddress
180179
*/
181180
public MongoClient(List<ServerAddress> seeds) {
@@ -193,7 +192,6 @@ public MongoClient(List<ServerAddress> seeds) {
193192
* @param seeds Put as many servers as you can in the list and the system will figure out the rest. This can either be a list
194193
* of mongod servers in the same replica set or a list of mongos servers in the same sharded cluster. \
195194
* @param credentialsList the list of credentials used to authenticate all connections
196-
* @throws MongoException
197195
* @see com.mongodb.ServerAddress
198196
* @since 2.11.0
199197
*/
@@ -212,7 +210,6 @@ public MongoClient(List<ServerAddress> seeds, List<MongoCredential> credentialsL
212210
* @param seeds Put as many servers as you can in the list and the system will figure out the rest. This can either be a list of
213211
* mongod servers in the same replica set or a list of mongos servers in the same sharded cluster.
214212
* @param options default options
215-
* @throws MongoException
216213
* @see com.mongodb.ServerAddress
217214
*/
218215
public MongoClient(List<ServerAddress> seeds, MongoClientOptions options) {
@@ -231,7 +228,6 @@ public MongoClient(List<ServerAddress> seeds, MongoClientOptions options) {
231228
* of mongod servers in the same replica set or a list of mongos servers in the same sharded cluster.
232229
* @param credentialsList the list of credentials used to authenticate all connections
233230
* @param options default options
234-
* @throws MongoException
235231
* @see com.mongodb.ServerAddress
236232
* @since 2.11.0
237233
*/
@@ -246,8 +242,9 @@ public MongoClient(List<ServerAddress> seeds, List<MongoCredential> credentialsL
246242
* nodes.
247243
*
248244
* @param uri the URI
249-
* @throws MongoException
250-
* @throws UnknownHostException
245+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
246+
* compatibility. The exception will be removed from the declaration in the next major release of the
247+
* driver.
251248
* @see MongoURI
252249
* @dochub connections
253250
*/

src/main/com/mongodb/ServerAddress.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public class ServerAddress {
3131
/**
3232
* Creates a ServerAddress with default host and port
3333
*
34-
* @throws UnknownHostException
34+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
35+
* compatibility. The exception will be removed from the declaration in the next major release of the
36+
* driver.
3537
*/
3638
public ServerAddress()
3739
throws UnknownHostException {
@@ -42,7 +44,9 @@ public ServerAddress()
4244
* Creates a ServerAddress with default port
4345
*
4446
* @param host hostname
45-
* @throws UnknownHostException
47+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
48+
* compatibility. The exception will be removed from the declaration in the next major release of the
49+
* driver.
4650
*/
4751
public ServerAddress( String host )
4852
throws UnknownHostException {
@@ -54,7 +58,9 @@ public ServerAddress( String host )
5458
*
5559
* @param host hostname
5660
* @param port mongod port
57-
* @throws UnknownHostException
61+
* @throws UnknownHostException This exception is no longer thrown, but leaving in throws clause so as not to break source
62+
* compatibility. The exception will be removed from the declaration in the next major release of the
63+
* driver.
5864
*/
5965
public ServerAddress( String host , int port )
6066
throws UnknownHostException {
@@ -190,7 +196,6 @@ public int getPort() {
190196
* Gets the underlying socket address
191197
*
192198
* @return socket address
193-
* @throws MongoException.Network if the host can not be resolved
194199
* @throws java.net.UnknownHostException
195200
*/
196201
public InetSocketAddress getSocketAddress() throws UnknownHostException {

0 commit comments

Comments
 (0)