Skip to content

Instantly share code, notes, and snippets.

@skonto
Created November 30, 2017 00:05
Show Gist options
  • Save skonto/727a60e43308e81e92b6095fe5986f48 to your computer and use it in GitHub Desktop.
Save skonto/727a60e43308e81e92b6095fe5986f48 to your computer and use it in GitHub Desktop.
debug class
import org.apache.hadoop.fs.FileSystem
import org.apache.hadoop.fs.Path
import org.apache.hadoop.mapred.JobConf
import java.util.ServiceLoader
val path = new Path(readURL)
val c= new JobConf()
val sl = ServiceLoader.load(classOf[FileSystem])
import scala.collection.JavaConversions._
sl.iterator.toList.foreach { fs =>
println(s"${fs.getScheme()} - ${fs.getClass()}")
}
println(s"${c.getClass("fs.s3n.impl", null)}")
import java.lang.reflect._
val field = classOf[FileSystem].getDeclaredField("SERVICE_FILE_SYSTEMS")
val modifiersField = classOf[Field].getDeclaredField("modifiers");
modifiersField.setAccessible(true)
modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.setAccessible(true)
field.get(null).asInstanceOf[Map[String, Class[FileSystem]]].foreach(println)
try {
path.getFileSystem(c)
} catch {
case e:Exception =>
println(e)
field.get(null).asInstanceOf[Map[String, Class[FileSystem]]].foreach(println)
println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH")
System.exit(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment