Skip to content

Commit 06e1d91

Browse files
committed
Ensure helpers call throwOnError();
JAVA-1254
1 parent 68272c5 commit 06e1d91

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/main/com/mongodb/DB.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ public Object eval( String code , Object ... args ){
470470
* @throws MongoException
471471
*/
472472
public CommandResult getStats() {
473-
return command("dbstats");
473+
CommandResult result = command("dbstats");
474+
result.throwOnError();
475+
return result;
474476
}
475477

476478
/**

src/main/com/mongodb/Mongo.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,9 @@ public CommandResult fsync(boolean async) {
690690
if (async) {
691691
cmd.put("async", 1);
692692
}
693-
return getDB(ADMIN_DATABASE_NAME).command(cmd);
693+
CommandResult result = getDB(ADMIN_DATABASE_NAME).command(cmd);
694+
result.throwOnError();
695+
return result;
694696
}
695697

696698
/**
@@ -704,7 +706,9 @@ public CommandResult fsync(boolean async) {
704706
public CommandResult fsyncAndLock() {
705707
DBObject cmd = new BasicDBObject("fsync", 1);
706708
cmd.put("lock", 1);
707-
return getDB(ADMIN_DATABASE_NAME).command(cmd);
709+
CommandResult result = getDB(ADMIN_DATABASE_NAME).command(cmd);
710+
result.throwOnError();
711+
return result;
708712
}
709713

710714
/**

0 commit comments

Comments
 (0)