Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/3119#discussion_r20331903
--- Diff: core/src/main/scala/org/apache/spark/io/CompressionCodec.scala ---
@@ -58,9 +60,15 @@ private[spark] object CompressionCodec {
def createCodec(conf: SparkConf, codecName: String): CompressionCodec = {
val codecClass =
shortCompressionCodecNames.getOrElse(codecName.toLowerCase, codecName)
- val ctor = Class.forName(codecClass, true,
Utils.getContextOrSparkClassLoader)
- .getConstructor(classOf[SparkConf])
- ctor.newInstance(conf).asInstanceOf[CompressionCodec]
+ val codec = try {
+ val ctor = Class.forName(codecClass, true,
Utils.getContextOrSparkClassLoader)
+ .getConstructor(classOf[SparkConf])
+ Some(ctor.newInstance(conf).asInstanceOf[CompressionCodec])
+ } catch {
+ case e: ClassNotFoundException => None
+ }
+ codec.filter(_.isAvailable())
+ .getOrElse(throw new IllegalArgumentException(s"Codec [$codecName]
is not available."))
--- End diff --
Hmm. This is fine, but one suggestion in the bug was to have extra wording
for the case where the default codec is not available, suggesting to the user
to change the configuration to set the codec to LZF instead. I think that would
be a nice thing to have, since that's probably the most common case of this
exception happening.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]