From c9539ede76e030076eca6d7f91b38a7fce90d85e Mon Sep 17 00:00:00 2001 From: Davide Angelocola Date: Wed, 17 Nov 2021 08:40:38 -0800 Subject: [PATCH] Fix integer overflow in TraceOptions (#9157) Summary: Hello from a happy user of rocksdb java :-) Default constructor of TraceOptions is supposed to initialize size to 64GB but the expression contains an integer overflow. Simple test case with JShell: ``` jshell> 64 * 1024 * 1024 * 1024 $1 ==> 0 jshell> 64L * 1024 * 1024 * 1024 $2 ==> 68719476736 ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/9157 Reviewed By: pdillinger, zhichao-cao Differential Revision: D32369273 Pulled By: mrambacher fbshipit-source-id: 6a0c95fff7a91f27ff15d65b662c6b101756b450 --- java/src/main/java/org/rocksdb/TraceOptions.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/java/src/main/java/org/rocksdb/TraceOptions.java b/java/src/main/java/org/rocksdb/TraceOptions.java index 657b263c6..0b8353745 100644 --- a/java/src/main/java/org/rocksdb/TraceOptions.java +++ b/java/src/main/java/org/rocksdb/TraceOptions.java @@ -13,7 +13,7 @@ public class TraceOptions { private final long maxTraceFileSize; public TraceOptions() { - this.maxTraceFileSize = 64 * 1024 * 1024 * 1024; // 64 GB + this.maxTraceFileSize = 64L * 1024 * 1024 * 1024; // 64 GB } public TraceOptions(final long maxTraceFileSize) { @@ -21,8 +21,8 @@ public class TraceOptions { } /** - * To avoid the trace file size grows large than the storage space, - * user can set the max trace file size in Bytes. Default is 64GB + * To avoid the trace file size grows larger than the storage space, + * user can set the max trace file size in Bytes. Default is 64 GB. * * @return the max trace size */