From fbd603d04ad3348430dbbd57fa95858ea6f53fe7 Mon Sep 17 00:00:00 2001 From: Alan Paxton Date: Fri, 10 Mar 2023 12:26:09 -0800 Subject: [PATCH] Reverse wrong order of parameter names for Java WriteBatchWithIndex#iteratorWithBase (#11280) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fix for https://github.com/facebook/rocksdb/issues/11008 `Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase` takes parameters `(… jlong jwbwi_handle, jlong jcf_handle, jlong jbase_iterator_handle, jlong jread_opts_handle)` while `WriteBatchWithIndex.java` declares `private native long iteratorWithBase(final long handle, final long baseIteratorHandle, final long cfHandle, final long readOptionsHandle)`. Luckily the only call to `iteratorWithBase` passes the parameters in the correct order for the implementation `(… cfHandle, baseIteratorHandle …)` This type checks because the types are the same (long words). The code is currently used correctly, it is just extremely misleading. Swap the names of the 2 parameters in the Java method so that the correct usage is clear. There already exist test methods which call the API correctly and only succeed because of that. These continue to work. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11280 Reviewed By: cbi42 Differential Revision: D43874798 Pulled By: ajkr fbshipit-source-id: b59bc930bf579f4e0804f0effd4fb17f4225d60c --- java/src/main/java/org/rocksdb/WriteBatchWithIndex.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/src/main/java/org/rocksdb/WriteBatchWithIndex.java b/java/src/main/java/org/rocksdb/WriteBatchWithIndex.java index c73bd7dda..d85b8e3f7 100644 --- a/java/src/main/java/org/rocksdb/WriteBatchWithIndex.java +++ b/java/src/main/java/org/rocksdb/WriteBatchWithIndex.java @@ -346,8 +346,8 @@ public class WriteBatchWithIndex extends AbstractWriteBatch { final boolean overwriteKey); private native long iterator0(final long handle); private native long iterator1(final long handle, final long cfHandle); - private native long iteratorWithBase(final long handle, final long baseIteratorHandle, - final long cfHandle, final long readOptionsHandle); + private native long iteratorWithBase(final long handle, final long cfHandle, + final long baseIteratorHandle, final long readOptionsHandle); private native byte[] getFromBatch(final long handle, final long optHandle, final byte[] key, final int keyLen); private native byte[] getFromBatch(final long handle, final long optHandle,