Skip to content

Instantly share code, notes, and snippets.

@berngp
Created April 8, 2014 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berngp/10075583 to your computer and use it in GitHub Desktop.
Save berngp/10075583 to your computer and use it in GitHub Desktop.
Bad Things On Code.
// somewhere inside some cool framework
val classpathEntries = Option(conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH)).
getOrElse(getDefaultYarnApplicationClasspath())
// where
def getDefaultYarnApplicationClasspath(): Array[String] = {
try {
val field = classOf[MRJobConfig].getField("DEFAULT_YARN_APPLICATION_CLASSPATH")
field.get(null).asInstanceOf[Array[String]]
} catch {
case err: NoSuchFieldError => null
case err: NoSuchFieldException => null
}
}
// O.o ... why? oh why? Just return Empty!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment