Browse files

Using Class.forName instead of getClass.getClassLoader.loadClass

  • Loading branch information...
1 parent 4b1174c commit 17562c9a6dc9c1d64181dffe0227317844e1b928 Drew Kutcharian committed Nov 29, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 src/main/scala/com/twitter/libkestrel/Journal.scala
View
13 src/main/scala/com/twitter/libkestrel/Journal.scala
@@ -62,19 +62,22 @@ object Journal {
}
private[libkestrel] val NoCondition = (_: QueueItem) => true
-
+
+ //Dynamically load ConcurrentLinkedDeque so we don't have a hard dependence on Java 7
private[this] val dequeClass: Class[_] = {
//First try to see java.util.concurrent.ConcurrentLinkedDeque exists
try {
- getClass.getClassLoader.loadClass("java.util.concurrent.ConcurrentLinkedDeque")
+ Class.forName("java.util.concurrent.ConcurrentLinkedDeque")
} catch {
//Now try to see if jsr166y is available on the classpath
case e:ClassNotFoundException =>
try {
- getClass.getClassLoader.loadClass("jsr166y.ConcurrentLinkedDeque")
+ Class.forName("jsr166y.ConcurrentLinkedDeque")
} catch {
- case e:ClassNotFoundException => sys.error("Could not find a class for ConcurrentLinkedDeque. You either need to be running Java 7+ or supply js166y jar.")
- }
+ case e:ClassNotFoundException =>
+ throw new ClassNotFoundException("Could not find an appropriate class for ConcurrentLinkedDeque. " +
+ "You either need to be running Java 7+ or supply js166y jar.")
+ }
}
}

0 comments on commit 17562c9

Please sign in to comment.