dbtsai commented on a change in pull request #2297:
URL: https://github.com/apache/hadoop/pull/2297#discussion_r489921893
##########
File path:
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/snappy/SnappyDecompressor.java
##########
@@ -45,30 +46,19 @@
private int userBufOff = 0, userBufLen = 0;
private boolean finished;
- private static boolean nativeSnappyLoaded = false;
-
- static {
- if (NativeCodeLoader.isNativeCodeLoaded() &&
- NativeCodeLoader.buildSupportsSnappy()) {
- try {
- initIDs();
- nativeSnappyLoaded = true;
- } catch (Throwable t) {
- LOG.error("failed to load SnappyDecompressor", t);
- }
- }
- }
-
- public static boolean isNativeCodeLoaded() {
- return nativeSnappyLoaded;
- }
-
/**
* Creates a new compressor.
*
* @param directBufferSize size of the direct buffer to be used.
*/
public SnappyDecompressor(int directBufferSize) {
+ // `snappy-java` is provided scope. We need to check if its availability.
+ try {
+ SnappyLoader.getVersion();
+ } catch (Throwable t) {
+ LOG.warn("Error loading snappy libraries: " + t);
Review comment:
In the original code, we throw a runtime exception if the native snappy
is not found. Should we follow?
```
throw new RuntimeException("native snappy library not available: " +
"SnappyCompressor has not been loaded.");
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]