mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
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:
@@ -16,7 +16,7 @@ import java.io.IOException;
|
||||
* All methods of this class could potentially throw RocksDBException, which
|
||||
* indicates sth wrong at the rocksdb library side and the call failed.
|
||||
*/
|
||||
public class RocksDB implements Closeable {
|
||||
public class RocksDB {
|
||||
public static final int NOT_FOUND = -1;
|
||||
/**
|
||||
* The factory constructor of RocksDB that opens a RocksDB instance given
|
||||
@@ -33,8 +33,8 @@ public class RocksDB implements Closeable {
|
||||
return db;
|
||||
}
|
||||
|
||||
@Override public void close() throws IOException {
|
||||
if (nativeHandle != 0) {
|
||||
public synchronized void close() {
|
||||
if (nativeHandle_ != 0) {
|
||||
close0();
|
||||
}
|
||||
}
|
||||
@@ -80,11 +80,15 @@ public class RocksDB implements Closeable {
|
||||
return get(key, key.length);
|
||||
}
|
||||
|
||||
@Override protected void finalize() {
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor.
|
||||
*/
|
||||
private RocksDB() {
|
||||
nativeHandle = -1;
|
||||
nativeHandle_ = 0;
|
||||
}
|
||||
|
||||
// native methods
|
||||
@@ -99,5 +103,5 @@ public class RocksDB implements Closeable {
|
||||
byte[] key, int keyLen) throws RocksDBException;
|
||||
private native void close0();
|
||||
|
||||
private long nativeHandle;
|
||||
private long nativeHandle_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user