For a bit of background, we have been running into a problem with the LevelDB JNI drivers for AggregationRepositories, which prevents startup when using routes for which we require persistent aggregation. This, however, is not the main topic of this issue.
In the latest version (2.19.2) the following issue has implemented a Java specific leveldb factory:
The relevant part of the Error on startup is as follows:
java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no leveldbjni64-1.8 in java.library.path, no leveldbjni-1.8 in java.library.path, no leveldbjni in java.library.path, C:\Users\atos\AppData\Local\Temp\leveldbjni-64-1-794362262645531032.8: Can't find dependent libraries]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
The way that I understand the code added in issue 11427, is that the LevelDBFile class getFactory() method (line 181) will first try to initiate with the JNI drivers and if that fails, will turn to the pure Java implementation. This is done by catching an Exception which is then ignored incase the JNI driver fails.
However, when we look at the code we see that UnstatisfiedLinkError does not extend Exception, it extends Error.
This Error is therefore not caught by the application and thus the Java implementation for LevelDB is never even attempted to be initialized as the method execution ends exceptionally at that point.
So the main two questions are:
1) Was the code intended to catch this UnsatisfiedLinkageError (I know Errors are often considered a bad thing to catch) as a means to substitute the JNI driver, incase it fails?
2) If it is not supposed to catch this error, how can I use the pure Java implementation in this case? I expect that trying to exclude relevant packages also wont work as it will directly try to initiate the the JNI implementation by its name, which would fail also with an Error.
So, in summary:
Is line 194 in class LevelDBFile in the camel-leveldb component supposed to catch an Error or more generally a Throwable instead of Exception?