diff --git a/src/main/java/gov/loc/repository/bagit/verify/BagVerifier.java b/src/main/java/gov/loc/repository/bagit/verify/BagVerifier.java index 95fd7a127..663cd8b8f 100644 --- a/src/main/java/gov/loc/repository/bagit/verify/BagVerifier.java +++ b/src/main/java/gov/loc/repository/bagit/verify/BagVerifier.java @@ -45,7 +45,7 @@ public final class BagVerifier implements AutoCloseable{ * {@link StandardBagitAlgorithmNameToSupportedAlgorithmMapping} */ public BagVerifier(){ - this(Executors.newCachedThreadPool(), new StandardBagitAlgorithmNameToSupportedAlgorithmMapping()); + this(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), new StandardBagitAlgorithmNameToSupportedAlgorithmMapping()); } /** @@ -54,7 +54,7 @@ public BagVerifier(){ * @param nameMapping the mapping between BagIt algorithm name and the java supported algorithm */ public BagVerifier(final BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping){ - this(Executors.newCachedThreadPool(), nameMapping); + this(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()), nameMapping); } /** diff --git a/src/main/java/gov/loc/repository/bagit/verify/ManifestVerifier.java b/src/main/java/gov/loc/repository/bagit/verify/ManifestVerifier.java index 8d073b1d3..645953f15 100644 --- a/src/main/java/gov/loc/repository/bagit/verify/ManifestVerifier.java +++ b/src/main/java/gov/loc/repository/bagit/verify/ManifestVerifier.java @@ -43,7 +43,7 @@ public class ManifestVerifier implements AutoCloseable{ * {@link StandardBagitAlgorithmNameToSupportedAlgorithmMapping} mapping */ public ManifestVerifier(){ - this(new StandardBagitAlgorithmNameToSupportedAlgorithmMapping(), Executors.newCachedThreadPool()); + this(new StandardBagitAlgorithmNameToSupportedAlgorithmMapping(), Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())); } /** @@ -52,7 +52,7 @@ public ManifestVerifier(){ * @param nameMapping the mapping between BagIt algorithm name and the java supported algorithm */ public ManifestVerifier(final BagitAlgorithmNameToSupportedAlgorithmMapping nameMapping) { - this(nameMapping, Executors.newCachedThreadPool()); + this(nameMapping, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())); } /** diff --git a/src/test/java/gov/loc/repository/bagit/verify/CheckIfFileExistsTaskTest.java b/src/test/java/gov/loc/repository/bagit/verify/CheckIfFileExistsTaskTest.java index eb0f1b7fb..6ea65d417 100644 --- a/src/test/java/gov/loc/repository/bagit/verify/CheckIfFileExistsTaskTest.java +++ b/src/test/java/gov/loc/repository/bagit/verify/CheckIfFileExistsTaskTest.java @@ -17,7 +17,7 @@ public class CheckIfFileExistsTaskTest extends TempFolderTest { @Test public void testNormalizedFileExists() throws Exception{ - ExecutorService executor = Executors.newCachedThreadPool(); + ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); CountDownLatch latch = new CountDownLatch(1); Set missingFiles = new ConcurrentSkipListSet<>(); String filename = "Núñez.txt";