diff --git a/src/main/java/org/jboss/netty/util/internal/QueueFactory.java b/src/main/java/org/jboss/netty/util/internal/QueueFactory.java index f08b42f442..6dfe83a39e 100644 --- a/src/main/java/org/jboss/netty/util/internal/QueueFactory.java +++ b/src/main/java/org/jboss/netty/util/internal/QueueFactory.java @@ -41,16 +41,14 @@ public final class QueueFactory { * @param itemClass the {@link Class} type which will be used as {@link BlockingQueue} items * @return queue the {@link BlockingQueue} implementation */ - @SuppressWarnings("unchecked") public static BlockingQueue createQueue(Class itemClass) { + // if we run in java >=7 its the best to just use the LinkedTransferQueue which + // comes with java bundled. See #273 + if (DetectionUtil.javaVersion() >= 7) { + return new java.util.concurrent.LinkedTransferQueue(); + } + try { - // if we run in java >=7 its the best to just use the LinkedTransferQueue which - // comes with java bundled. See #273 - if (DetectionUtil.javaVersion() >= 7) { - // Use reflect as android otherwise will panic out. See #458 - return (BlockingQueue) QueueFactory.class.getClassLoader() - .loadClass("java.util.concurrent.LinkedTransferQueue").newInstance(); - } if (useUnsafe) { return new LinkedTransferQueue(); } @@ -77,16 +75,13 @@ public final class QueueFactory { * @return queue the {@link BlockingQueue} implementation */ public static BlockingQueue createQueue(Collection collection, Class itemClass) { + // if we run in java >=7 its the best to just use the LinkedTransferQueue which + // comes with java bundled. See #273 + if (DetectionUtil.javaVersion() >= 7) { + return new java.util.concurrent.LinkedTransferQueue(); + } + try { - // if we run in java >=7 its the best to just use the LinkedTransferQueue which - // comes with java bundled. See #273 - if (DetectionUtil.javaVersion() >= 7) { - // Use reflect as android otherwise will panic out. See #458 - @SuppressWarnings("unchecked") - Class> clazz = (Class>) QueueFactory.class.getClassLoader() - .loadClass("java.util.concurrent.LinkedTransferQueue"); - return clazz.getConstructor(Collection.class).newInstance(collection); - } if (useUnsafe) { return new LinkedTransferQueue(collection); } @@ -104,5 +99,4 @@ public final class QueueFactory { return new LegacyLinkedTransferQueue(collection); } - }