Skip to content

Commit

Permalink
PARQUET-1802: Use job ClassLoader to load CompressionCodec class
Browse files Browse the repository at this point in the history
The MR job might be having a different ClassLoader then
the defining ClassLoader of the CodecFactory class.
A CompressionCodec class that is not loadable via the
CodecFactory ClassLoader might be loadable through the
job ClassLoader.
  • Loading branch information
chtyim committed Feb 19, 2020
1 parent 1eaf16d commit cddcea2
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -227,7 +227,13 @@ protected CompressionCodec getCodec(CompressionCodecName codecName) {
}

try {
Class<?> codecClass = Class.forName(codecClassName);
Class<?> codecClass;
try {
codecClass = Class.forName(codecClassName);
} catch (ClassNotFoundException e) {
// Try to load the class using the job classloader
codecClass = configuration.getClassLoader().loadClass(codecClassName);
}
codec = (CompressionCodec) ReflectionUtils.newInstance(codecClass, configuration);
CODEC_BY_NAME.put(codecClassName, codec);
return codec;
Expand Down

0 comments on commit cddcea2

Please sign in to comment.