Minor fix in rocksdb jni library, RocksDB now does not implement Closeable.

Summary:
* [java] RocksDB now does not implement Closeable.
* [java] RocksDB.close() is now synchronized.
* [c++] Fix a bug in rocksjni.cc that does not release a java reference before
        throwing an exception.

Test Plan:
make jni
make jtest

Reviewers: haobo, sdong

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D17355
This commit is contained in:
Yueh-Hsuan Chiang
2014-03-31 21:46:10 -07:00
parent 8e81caf01a
commit a73383e8ac
4 changed files with 17 additions and 16 deletions

View File

@@ -21,9 +21,10 @@ public class RocksDBSample {
String db_path = args[0];
System.out.println("RocksDBSample");
RocksDB db = null;
try {
RocksDB db = RocksDB.open(db_path);
db = RocksDB.open(db_path);
db.put("hello".getBytes(), "world".getBytes());
byte[] value = db.get("hello".getBytes());
System.out.format("Get('hello') = %s\n",
@@ -67,13 +68,11 @@ public class RocksDBSample {
assert(len == RocksDB.NOT_FOUND);
len = db.get(testKey, enoughArray);
assert(len == testValue.length);
try {
db.close();
} catch (IOException e) {
System.err.println(e);
}
} catch (RocksDBException e) {
System.err.println(e);
}
if (db != null) {
db.close();
}
}
}