diff --git a/src/main/java/com/github/junrar/extract/ExtractArchive.java b/src/main/java/com/github/junrar/extract/ExtractArchive.java index bb83d8ed3..4cf88ea7b 100644 --- a/src/main/java/com/github/junrar/extract/ExtractArchive.java +++ b/src/main/java/com/github/junrar/extract/ExtractArchive.java @@ -4,6 +4,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.util.Collections; +import java.util.List; import org.apache.commons.logging.Log; @@ -25,14 +27,16 @@ public void setLogger(Log logger) { this.logger = logger; } - public void extractArchive(File archive, File destination) { + public void extractArchive(File archive, File destination) throws RarException, IOException { Archive arch = null; try { arch = new Archive(archive); } catch (RarException e) { logError(e); + throw e; } catch (IOException e1) { logError(e1); + throw e1; } if (arch != null) { if (arch.isEncrypted()) { @@ -63,8 +67,10 @@ public void extractArchive(File archive, File destination) { } } catch (IOException e) { logError(e, "error extracting the file"); + throw e; } catch (RarException e) { logError(e,"error extraction the file"); + throw e; } } }finally { diff --git a/src/main/java/com/github/junrar/testutil/ExtractArchive.java b/src/main/java/com/github/junrar/testutil/ExtractArchive.java index 61f5ff5ca..fa7c91cb5 100644 --- a/src/main/java/com/github/junrar/testutil/ExtractArchive.java +++ b/src/main/java/com/github/junrar/testutil/ExtractArchive.java @@ -1,7 +1,9 @@ package com.github.junrar.testutil; import java.io.File; +import java.io.IOException; +import com.github.junrar.exception.RarException; import org.apache.commons.logging.LogFactory; /** @@ -12,7 +14,7 @@ */ public class ExtractArchive { - public static void main(String[] args) { + public static void main(String[] args) throws IOException, RarException { if (args.length == 2) { extractArchive(args[0], args[1]); } else { @@ -20,7 +22,7 @@ public static void main(String[] args) { } } - public static void extractArchive(String archive, String destination) { + public static void extractArchive(String archive, String destination) throws IOException, RarException { if (archive == null || destination == null) { throw new RuntimeException("archive and destination must me set"); } @@ -35,7 +37,7 @@ public static void extractArchive(String archive, String destination) { ExtractArchive.extractArchive(arch, dest); } - public static void extractArchive(File archive, File destination){ + public static void extractArchive(File archive, File destination) throws IOException, RarException { com.github.junrar.extract.ExtractArchive extractArchive = new com.github.junrar.extract.ExtractArchive(); extractArchive.setLogger(LogFactory.getLog(ExtractArchive.class.getName())); extractArchive.extractArchive(archive, destination); diff --git a/src/test/java/com/github/junrar/testUtil/JUnRarTestUtil.java b/src/test/java/com/github/junrar/testUtil/JUnRarTestUtil.java index e914fe345..6a2b6cf91 100644 --- a/src/test/java/com/github/junrar/testUtil/JUnRarTestUtil.java +++ b/src/test/java/com/github/junrar/testUtil/JUnRarTestUtil.java @@ -93,7 +93,7 @@ public static void setupFunctionalTests() throws IOException{ } @Test - public void unrarFile_FileContentsShouldMatchExpected() throws IOException{ + public void unrarFile_FileContentsShouldMatchExpected() throws IOException, RarException { InputStream resourceAsStream = JUnRarTestUtil.class.getResourceAsStream("test.rar"); File testRar = new File(tempFolder,"test.rar"); FileUtils.writeByteArrayToFile(testRar, IOUtils.toByteArray(resourceAsStream));