[RocksJava] Addressed comments in D28971

This commit is contained in:
fyrz 2014-11-25 23:08:53 +01:00
parent fcc2dfd9f9
commit f193deea31
4 changed files with 18 additions and 11 deletions

View File

@ -51,7 +51,7 @@ endif
JAVA_TESTS = org.rocksdb.test.BackupableDBOptionsTest\
org.rocksdb.test.BackupableDBTest\
org.rocksdb.test.BlockBasedTableConfigTest\
org.rocksdb.test.CheckpointTest\
org.rocksdb.test.CheckPointTest\
org.rocksdb.test.ColumnFamilyOptionsTest\
org.rocksdb.test.ColumnFamilyTest\
org.rocksdb.test.ComparatorOptionsTest\

View File

@ -17,15 +17,21 @@ public class Checkpoint extends RocksObject {
*
* @param db {@link RocksDB} instance.
* @return a Checkpoint instance.
*
* @throws java.lang.IllegalArgumentException if {@link RocksDB}
* instance is null.
* @throws java.lang.IllegalStateException if {@link RocksDB}
* instance is not initialized.
*/
public static Checkpoint create(RocksDB db) {
if (db == null || !db.isInitialized()) {
if (db == null) {
throw new IllegalArgumentException(
"RocksDB instance needs to be initialized.");
"RocksDB instance shall not be null.");
} else if (!db.isInitialized()) {
throw new IllegalStateException(
"RocksDB instance must be initialized.");
}
Checkpoint checkpoint = new Checkpoint(
newCheckpoint(db.nativeHandle_));
checkpoint.db_ = db;
Checkpoint checkpoint = new Checkpoint(db);
return checkpoint;
}
@ -50,9 +56,10 @@ public class Checkpoint extends RocksObject {
disposeInternal(nativeHandle_);
}
private Checkpoint(long handle) {
private Checkpoint(RocksDB db) {
super();
nativeHandle_ = handle;
nativeHandle_ = newCheckpoint(db.nativeHandle_);
db_ = db;
}
RocksDB db_;

View File

@ -12,7 +12,7 @@ import org.rocksdb.RocksDBException;
import static org.assertj.core.api.Assertions.assertThat;
public class CheckpointTest {
public class CheckPointTest {
@ClassRule
public static final RocksMemoryResource rocksMemoryResource =
@ -74,7 +74,7 @@ public class CheckpointTest {
Checkpoint.create(null);
}
@Test(expected = IllegalArgumentException.class)
@Test(expected = IllegalStateException.class)
public void failIfDbNotInitialized() throws RocksDBException {
RocksDB db = RocksDB.open(dbFolder.getRoot().getAbsolutePath());
db.dispose();