提交 f193deea 编写于 作者: F fyrz

[RocksJava] Addressed comments in D28971

上级 fcc2dfd9
......@@ -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\
......
......@@ -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_;
......
......@@ -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();
......
......@@ -58,4 +58,4 @@ void Java_org_rocksdb_Checkpoint_createCheckpoint(
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册