xerial / snappy-java

Snappy compressor/decompressor for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option to disable fallback to PureJavaSnappy

lehnerj opened this issue · comments

snappy-java has two implementations of Snappy, one native implementation written in C/C++ and one written in Java called PureJavaSnappy.
At the moment the consumers of snappy-java cannot force to use the native implementation as snappy-java always falls back to PureJavaSnappy in case of any errors during loading of the native library. This is unfortunate not only because it limits the choices of the consumer but also because different people have reported issues with PureJavaSnappy, most notably #295.

The fallback to PureJavaSnappy was implemented with #244

static synchronized SnappyApi loadSnappyApi() {
...
        try {
            if(Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_PUREJAVA, "false"))) {
                // Use pure-java Snappy implementation
                setSnappyApi(new PureJavaSnappy());
            }
            else {
                loadNativeLibrary();
                setSnappyApi(new SnappyNative());
            }
        }
        catch(Throwable e) {
            // Fall-back to pure-java Snappy implementation
            setSnappyApi(new PureJavaSnappy());
        }
...

Pure-java mode is removed since snappy 1.1.9.0