Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/org/xerial/snappy/SnappyLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public class SnappyLoader
public static final String KEY_SNAPPY_LIB_PATH = "org.xerial.snappy.lib.path";
public static final String KEY_SNAPPY_LIB_NAME = "org.xerial.snappy.lib.name";
public static final String KEY_SNAPPY_PUREJAVA = "org.xerial.snappy.purejava";
public static final String KEY_SNAPPY_ALLOW_PUREJAVA = "org.xerial.snappy.allow.purejava";
public static final String KEY_SNAPPY_TEMPDIR = "org.xerial.snappy.tempdir";
public static final String KEY_SNAPPY_USE_SYSTEMLIB = "org.xerial.snappy.use.systemlib";
public static final String KEY_SNAPPY_DISABLE_BUNDLED_LIBS = "org.xerial.snappy.disable.bundled.libs"; // Depreciated, but preserved for backward compatibility
Expand Down Expand Up @@ -158,8 +159,9 @@ static synchronized SnappyApi loadSnappyApi()
if (snappyApi != null) {
return snappyApi;
}
boolean allowPureJava = Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_ALLOW_PUREJAVA, "true"));
try {
if(Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_PUREJAVA, "false"))) {
if(allowPureJava && Boolean.parseBoolean(System.getProperty(KEY_SNAPPY_PUREJAVA, "false"))) {
// Use pure-java Snappy implementation
setSnappyApi(new PureJavaSnappy());
}
Expand All @@ -170,6 +172,9 @@ static synchronized SnappyApi loadSnappyApi()
}
catch(Throwable e) {
// Fall-back to pure-java Snappy implementation
if (!allowPureJava) {
throw new RuntimeException("Native Snappy could not be loaded and Java Snappy not allowed.", e);
}
setSnappyApi(new PureJavaSnappy());
}
return snappyApi;
Expand Down