yuck!, hack around snappy printing to System.err the failure to load its library if its not found

This commit is contained in:
Shay Banon 2012-07-09 20:14:03 +02:00
parent 1a085d9bfa
commit 0bb7496dfe
1 changed files with 8 additions and 0 deletions

View File

@ -21,6 +21,8 @@ package org.elasticsearch.common.compress.snappy.xerial;
import org.xerial.snappy.Snappy;
import java.io.PrintStream;
/**
*/
public class XerialSnappy {
@ -31,13 +33,19 @@ public class XerialSnappy {
static {
Throwable failureX = null;
boolean availableX;
// Yuck!, we need to do this since snappy 1.0.4.1 does e.printStackTrace
// when failing to load the snappy library, and we don't want it displayed...
PrintStream err = System.err;
try {
System.setErr(null);
byte[] tests = Snappy.compress("test");
Snappy.uncompressString(tests);
availableX = true;
} catch (Throwable e) {
availableX = false;
failureX = e;
} finally {
System.setErr(err);
}
available = availableX;
failure = failureX;