Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.19.2
-
None
-
Unknown
Description
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:
https://issues.apache.org/jira/browse/CAMEL-11427
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 org.fusesource.hawtjni.runtime.Library.doLoad(Library.java:182)
at org.fusesource.hawtjni.runtime.Library.load(Library.java:140)
at org.fusesource.leveldbjni.JniDBFactory.(JniDBFactory.java:48)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.apache.camel.component.leveldb.LevelDBFile.getFactory(LevelDBFile.java:189)
at org.apache.camel.component.leveldb.LevelDBFile.start(LevelDBFile.java:174)
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?
Attachments
Attachments
Issue Links
- breaks
-
CAMEL-11427 camel-leveldb does not work on Solaris -- no native code library and no Java fallback
- Resolved
- links to