do not load snappy implementation if its usage is explicitly disabled via system property

This commit is contained in:
Eugene Zhuravlev
2012-07-13 15:32:45 +02:00
parent 3082f9dd70
commit 3a1451abf3
@@ -31,9 +31,14 @@ public class IOUtils {
private static volatile boolean canUseSnappy;
static {
try {
Field impl = Snappy.class.getDeclaredField("impl");
impl.setAccessible(true);
canUseSnappy = impl.get(null) != null && System.getProperty("idea.no.snappy") == null;
if (System.getProperty("idea.no.snappy") == null) { // if enabled
Field impl = Snappy.class.getDeclaredField("impl");
impl.setAccessible(true);
canUseSnappy = impl.get(null) != null;
}
else {
canUseSnappy = false;
}
}
catch (Throwable e) {}
}