diff --git a/java/src/test/java/org/rocksdb/WriteBatchThreadedTest.java b/java/src/test/java/org/rocksdb/WriteBatchThreadedTest.java index 66e1c8966..e31d83b28 100644 --- a/java/src/test/java/org/rocksdb/WriteBatchThreadedTest.java +++ b/java/src/test/java/org/rocksdb/WriteBatchThreadedTest.java @@ -59,13 +59,14 @@ public class WriteBatchThreadedTest { callables.add(new Callable() { @Override public Void call() throws RocksDBException { - final WriteBatch wb = new WriteBatch(); - for (int i = offset; i < offset + 100; i++) { - wb.put(ByteBuffer.allocate(4).putInt(i).array(), - "parallel rocks test".getBytes()); + try (final WriteBatch wb = new WriteBatch(); + final WriteOptions w_opt = new WriteOptions()) { + for (int i = offset; i < offset + 100; i++) { + wb.put(ByteBuffer.allocate(4).putInt(i).array(), + "parallel rocks test".getBytes()); + } + db.write(w_opt, wb); } - db.write(new WriteOptions(), wb); - return null; } });