Skip to content

Commit 8024ef1

Browse files
committed
Improve Interrupt handling when loading the Native Library
1 parent 10b5f5c commit 8024ef1

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

java/src/main/java/org/rocksdb/RocksDB.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,14 @@ public static void loadLibrary() {
8484
return;
8585
}
8686

87-
while (libraryLoaded.get() == LibraryState.LOADING) {
88-
try {
89-
Thread.sleep(10);
90-
} catch(final InterruptedException e) {
91-
//ignore
87+
try {
88+
while (libraryLoaded.get() == LibraryState.LOADING) {
89+
Thread.sleep(10);
9290
}
91+
} catch (final InterruptedException e) {
92+
// restore interrupted status
93+
Thread.currentThread().interrupt();
94+
throw new RuntimeException("Interrupted whilst trying to load the RocksDB shared library", e);
9395
}
9496
}
9597

@@ -146,12 +148,14 @@ public static void loadLibrary(final List<String> paths) {
146148
return;
147149
}
148150

149-
while (libraryLoaded.get() == LibraryState.LOADING) {
150-
try {
151-
Thread.sleep(10);
152-
} catch(final InterruptedException e) {
153-
//ignore
151+
try {
152+
while (libraryLoaded.get() == LibraryState.LOADING) {
153+
Thread.sleep(10);
154154
}
155+
} catch (final InterruptedException e) {
156+
// restore interrupted status
157+
Thread.currentThread().interrupt();
158+
throw new RuntimeException("Interrupted whilst trying to load the RocksDB shared library", e);
155159
}
156160
}
157161

0 commit comments

Comments
 (0)