@@ -259,37 +259,48 @@ public CommandResult command( DBObject cmd, DBEncoder encoder ){
259259 }
260260
261261 /**
262- * Executes a database command.
263- * This method calls {@link DB#command(com.mongodb.DBObject, int, com.mongodb.ReadPreference, com.mongodb.DBEncoder) } with a null readPrefs.
262+ * Executes a database command. This method calls
263+ * {@link DB#command(com.mongodb.DBObject, int, com.mongodb.ReadPreference, com.mongodb.DBEncoder) } with the database default read
264+ * preference. The only option used by this method was "slave ok", therefore this method has been replaced with
265+ * {@link com.mongodb.DB#command(DBObject, ReadPreference, DBEncoder)}.
264266 *
265267 * @param cmd {@code DBObject} representation the command to be executed
266268 * @param options query options to use
267269 * @param encoder {@link DBEncoder} to be used for command encoding
268270 * @return result of the command execution
269271 * @throws MongoException
270272 * @dochub commands
273+ * @mongodb.driver.manual reference/method/db.runCommand/ runCommand
274+ * @deprecated Use {@link com.mongodb.DB#command(DBObject, ReadPreference, DBEncoder)} instead
271275 */
276+ @ Deprecated
272277 public CommandResult command ( DBObject cmd , int options , DBEncoder encoder ){
273278 return command (cmd , options , getReadPreference (), encoder );
274279 }
275280
276281 /**
277- * Executes a database command.
278- * This method calls {@link DB#command(com.mongodb.DBObject, int, com.mongodb.ReadPreference, com.mongodb.DBEncoder) } with a default encoder.
282+ * Executes a database command. This method calls
283+ * {@link DB#command(com.mongodb.DBObject, int, com.mongodb.ReadPreference, com.mongodb.DBEncoder) } with a default encoder. The only
284+ * option used by this method was "slave ok", therefore this method has been replaced
285+ * with {@link com.mongodb.DB#command(DBObject, ReadPreference)}.
279286 *
280287 * @param cmd {@code DBObject} representation the command to be executed
281288 * @param options query options to use
282289 * @param readPrefs {@link ReadPreference} for this command (nodes selection is the biggest part of this)
283290 * @return result of the command execution
284291 * @throws MongoException
285292 * @dochub commands
293+ * @mongodb.driver.manual reference/method/db.runCommand/ runCommand
294+ * @deprecated Use {@link com.mongodb.DB#command(DBObject, ReadPreference)} instead
286295 */
296+ @ Deprecated
287297 public CommandResult command ( DBObject cmd , int options , ReadPreference readPrefs ){
288298 return command (cmd , options , readPrefs , DefaultDBEncoder .FACTORY .create ());
289299 }
290300
291301 /**
292- * Executes a database command.
302+ * Executes a database command. The only option used by this method was "slave ok", therefore this method
303+ * has been replaced with {@link com.mongodb.DB#command(DBObject, ReadPreference, DBEncoder)}.
293304 *
294305 * @param cmd {@code DBObject} representation the command to be executed
295306 * @param options query options to use
@@ -298,7 +309,10 @@ public CommandResult command( DBObject cmd , int options, ReadPreference readPre
298309 * @return result of the command execution
299310 * @throws MongoException
300311 * @dochub commands
312+ * @mongodb.driver.manual reference/method/db.runCommand/ runCommand
313+ * @deprecated Use {@link com.mongodb.DB#command(DBObject, ReadPreference, DBEncoder)} instead
301314 */
315+ @ Deprecated
302316 public CommandResult command ( DBObject cmd , int options , ReadPreference readPrefs , DBEncoder encoder ){
303317 ReadPreference effectiveReadPrefs = getCommandReadPreference (cmd , readPrefs );
304318 cmd = wrapCommand (cmd , effectiveReadPrefs );
@@ -316,6 +330,20 @@ public CommandResult command( DBObject cmd , int options, ReadPreference readPre
316330 return cr ;
317331 }
318332
333+ /**
334+ * Executes a database command with the selected readPreference, and encodes the command using the given encoder.
335+ *
336+ * @param cmd The {@code DBObject} representation the command to be executed
337+ * @param readPrefs Where to execute the command - this will only be applied for a subset of commands
338+ * @param encoder The DBEncoder that knows how to serialise the cmd
339+ * @return The result of executing the command, success or failure
340+ * @mongodb.driver.manual reference/method/db.runCommand/ runCommand
341+ * @since 2.12
342+ */
343+ public CommandResult command ( final DBObject cmd , final ReadPreference readPrefs , final DBEncoder encoder ){
344+ return command (cmd , 0 , readPrefs , encoder );
345+ }
346+
319347 // Only append $readPreference meta-operator if connected to a mongos, read preference is not primary
320348 // or secondary preferred,
321349 // and command is an instance of BasicDBObject. The last condition is unfortunate, but necessary in case
@@ -352,13 +380,13 @@ public CommandResult command(DBObject cmd, int options) {
352380 * Executes the command against the database with the given read preference. This method is the preferred way of setting read
353381 * preference, use this instead of {@link DB#command(com.mongodb.DBObject, int) }
354382 *
355- * @param cmd{@code DBObject} representation the command to be executed
356- * @param readPreference where to execute the command
357- * @return the result of executing the command, success or failure
383+ * @param cmd The {@code DBObject} representation the command to be executed
384+ * @param readPreference Where to execute the command
385+ * @return The result of executing the command, success or failure
358386 * @mongodb.driver.manual reference/method/db.runCommand/ runCommand
359387 * @since 2.12
360388 */
361- public CommandResult command (DBObject cmd , ReadPreference readPreference ) {
389+ public CommandResult command (final DBObject cmd , final ReadPreference readPreference ) {
362390 return command (cmd , 0 , readPreference );
363391 }
364392
0 commit comments