From 2c3a780901379a52c9d75930e432f5df4eba53b6 Mon Sep 17 00:00:00 2001 From: Si Ke Date: Fri, 4 Feb 2022 16:00:39 -0800 Subject: [PATCH] Fixed all RocksJava test failures in Centos and Alpine (#9395) Summary: Fixed all RocksJava test failures in Centos and Alpine 32 bit and 64 bit OSes Pull Request resolved: https://github.com/facebook/rocksdb/pull/9395 Reviewed By: mrambacher Differential Revision: D33771987 Pulled By: ajkr fbshipit-source-id: fed91033b8df08f191ad65e1fb745a9264bbfa70 --- java/rocksjni/lru_cache.cc | 2 +- java/rocksjni/write_batch_with_index.cc | 2 +- java/src/test/java/org/rocksdb/EnvOptionsTest.java | 6 +++--- java/src/test/java/org/rocksdb/EventListenerTest.java | 2 +- java/src/test/java/org/rocksdb/ReadOptionsTest.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/java/rocksjni/lru_cache.cc b/java/rocksjni/lru_cache.cc index cfdcb525b..7b62702c6 100644 --- a/java/rocksjni/lru_cache.cc +++ b/java/rocksjni/lru_cache.cc @@ -26,7 +26,7 @@ jlong Java_org_rocksdb_LRUCache_newLRUCache(JNIEnv* /*env*/, jclass /*jcls*/, static_cast(jcapacity), static_cast(jnum_shard_bits), static_cast(jstrict_capacity_limit), static_cast(jhigh_pri_pool_ratio))); - return reinterpret_cast(sptr_lru_cache); + return reinterpret_cast(sptr_lru_cache); } /* diff --git a/java/rocksjni/write_batch_with_index.cc b/java/rocksjni/write_batch_with_index.cc index 7d3e207f6..eaf126d0a 100644 --- a/java/rocksjni/write_batch_with_index.cc +++ b/java/rocksjni/write_batch_with_index.cc @@ -551,7 +551,7 @@ jlong Java_org_rocksdb_WriteBatchWithIndex_iteratorWithBase( jread_opts_handle); auto* iterator = wbwi->NewIteratorWithBase(cf_handle, base_iterator, read_opts); - return reinterpret_cast(iterator); + return reinterpret_cast(iterator); } /* diff --git a/java/src/test/java/org/rocksdb/EnvOptionsTest.java b/java/src/test/java/org/rocksdb/EnvOptionsTest.java index 75768e2ae..0f3d8e234 100644 --- a/java/src/test/java/org/rocksdb/EnvOptionsTest.java +++ b/java/src/test/java/org/rocksdb/EnvOptionsTest.java @@ -105,7 +105,7 @@ public class EnvOptionsTest { @Test public void compactionReadaheadSize() { try (final EnvOptions envOptions = new EnvOptions()) { - final int intValue = rand.nextInt(); + final int intValue = rand.nextInt(2147483647); envOptions.setCompactionReadaheadSize(intValue); assertThat(envOptions.compactionReadaheadSize()).isEqualTo(intValue); } @@ -114,7 +114,7 @@ public class EnvOptionsTest { @Test public void randomAccessMaxBufferSize() { try (final EnvOptions envOptions = new EnvOptions()) { - final int intValue = rand.nextInt(); + final int intValue = rand.nextInt(2147483647); envOptions.setRandomAccessMaxBufferSize(intValue); assertThat(envOptions.randomAccessMaxBufferSize()).isEqualTo(intValue); } @@ -123,7 +123,7 @@ public class EnvOptionsTest { @Test public void writableFileMaxBufferSize() { try (final EnvOptions envOptions = new EnvOptions()) { - final int intValue = rand.nextInt(); + final int intValue = rand.nextInt(2147483647); envOptions.setWritableFileMaxBufferSize(intValue); assertThat(envOptions.writableFileMaxBufferSize()).isEqualTo(intValue); } diff --git a/java/src/test/java/org/rocksdb/EventListenerTest.java b/java/src/test/java/org/rocksdb/EventListenerTest.java index c6b8f940a..92d0c736b 100644 --- a/java/src/test/java/org/rocksdb/EventListenerTest.java +++ b/java/src/test/java/org/rocksdb/EventListenerTest.java @@ -399,8 +399,8 @@ public class EventListenerTest { @Override public void onFileTruncateFinish(final FileOperationInfo fileOperationInfo) { - assertEquals(fileOperationInfoTestData, fileOperationInfo); super.onFileTruncateFinish(fileOperationInfo); + assertEquals(fileOperationInfoTestData, fileOperationInfo); } @Override diff --git a/java/src/test/java/org/rocksdb/ReadOptionsTest.java b/java/src/test/java/org/rocksdb/ReadOptionsTest.java index 06aafe77c..156dd3730 100644 --- a/java/src/test/java/org/rocksdb/ReadOptionsTest.java +++ b/java/src/test/java/org/rocksdb/ReadOptionsTest.java @@ -143,9 +143,9 @@ public class ReadOptionsTest { public void readaheadSize() { try (final ReadOptions opt = new ReadOptions()) { final Random rand = new Random(); - final long longValue = rand.nextLong(); - opt.setReadaheadSize(longValue); - assertThat(opt.readaheadSize()).isEqualTo(longValue); + final int intValue = rand.nextInt(2147483647); + opt.setReadaheadSize(intValue); + assertThat(opt.readaheadSize()).isEqualTo(intValue); } }