diff --git a/core/src/main/java/com/turn/ttorrent/common/ByteBufferPool.java b/core/src/main/java/com/turn/ttorrent/common/ByteBufferPool.java index 6e2a75b1a..7796a1565 100644 --- a/core/src/main/java/com/turn/ttorrent/common/ByteBufferPool.java +++ b/core/src/main/java/com/turn/ttorrent/common/ByteBufferPool.java @@ -36,8 +36,12 @@ public ByteBufferPool(int amount, int length) { pool = new GenericObjectPool(new ByteBufferFactory(length), gopc); } - public ByteBuffer borrowObject() throws Exception { - return pool.borrowObject(); + public ByteBuffer borrowObject() { + try { + return pool.borrowObject(); + } catch (Exception e) { + throw new RuntimeException(e); + } } public void returnObject(ByteBuffer buffer) { diff --git a/core/src/main/java/com/turn/ttorrent/common/Torrent.java b/core/src/main/java/com/turn/ttorrent/common/Torrent.java index 77c42f390..3de1d3af4 100644 --- a/core/src/main/java/com/turn/ttorrent/common/Torrent.java +++ b/core/src/main/java/com/turn/ttorrent/common/Torrent.java @@ -505,7 +505,7 @@ public static Torrent load(File torrent, boolean seeder) * torrent's creator. */ public static Torrent create(File source, URI announce, String createdBy) - throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + throws InterruptedException, IOException, NoSuchAlgorithmException { return Torrent.create(source, null, DEFAULT_PIECE_LENGTH, announce, null, createdBy); } @@ -528,7 +528,7 @@ public static Torrent create(File source, URI announce, String createdBy) * torrent's creator. */ public static Torrent create(File parent, List files, URI announce, - String createdBy) throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + String createdBy) throws InterruptedException, IOException, NoSuchAlgorithmException { return Torrent.create(parent, files, DEFAULT_PIECE_LENGTH, announce, null, createdBy); } @@ -549,7 +549,7 @@ public static Torrent create(File parent, List files, URI announce, * torrent's creator. */ public static Torrent create(File source, int pieceLength, List> announceList, - String createdBy) throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + String createdBy) throws InterruptedException, IOException, NoSuchAlgorithmException { return Torrent.create(source, null, pieceLength, null, announceList, createdBy); } @@ -574,7 +574,7 @@ public static Torrent create(File source, int pieceLength, List> annou */ public static Torrent create(File source, List files, int pieceLength, List> announceList, String createdBy) - throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + throws InterruptedException, IOException, NoSuchAlgorithmException { return Torrent.create(source, files, pieceLength, null, announceList, createdBy); } @@ -600,7 +600,7 @@ public static Torrent create(File source, List files, int pieceLength, */ private static Torrent create(File parent, List files, int pieceLength, URI announce, List> announceList, String createdBy) - throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + throws InterruptedException, IOException, NoSuchAlgorithmException { if (files == null || files.isEmpty()) { logger.info("Creating single-file torrent for {}...", parent.getName()); @@ -715,12 +715,12 @@ public String call() throws UnsupportedEncodingException, InterruptedException { * @param file The file to hash. */ private static String hashFile(File file, int pieceLength) - throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + throws InterruptedException, IOException, NoSuchAlgorithmException { return Torrent.hashFiles(Arrays.asList(new File[] { file }), pieceLength); } private static String hashFiles(List files, int pieceLength) - throws InterruptedException, IOException, NoSuchAlgorithmException, Exception { + throws InterruptedException, IOException, NoSuchAlgorithmException { int threads = getHashingThreadsCount(); ExecutorService executor = Executors.newFixedThreadPool(threads); final ByteBufferPool bbp = new ByteBufferPool(threads + 1, pieceLength);