xerial / snappy-java

Snappy compressor/decompressor for Java
Apache License 2.0
1.04k stars 232 forks source link

Add option to disable fallback to PureJavaSnappy #326

Closed lehnerj closed 1 year ago

lehnerj commented 2 years ago

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());
        }
...
xerial commented 1 year ago

Pure-java mode is removed since snappy 1.1.9.0