LibraryOfCongress / bagit-java

Java library to support the BagIt specification.
Other
73 stars 49 forks source link

Verifying a bag throws an exception: Unable to create new native threads #121

Open chinuhub opened 6 years ago

chinuhub commented 6 years ago

When submitting an issue please include:

Please format it in the given when then style

For example (from link above):

Given

When

Then

The exception is thrown in method "checkAllFilesListedInManifestExist(Set files)" in file PayloadVerifier.java in line this.executor.execute(new CheckIfFileExistsTask(file, missingFiles, latch)); when a new task isto be executed on executor.

When checking the thread creation limit on mac It was 709.

chinuhub commented 6 years ago

When instantiating BagVerifier I am now using Executors.newSingleThreadExecutor(). It fixed the issue.

jscancella commented 6 years ago

For a large bag you may want to use Executors.newFixedThreadPool() and specify how many threads you want to use instead of just using a single thread as multi-threading it will be much faster(as long as you aren't hitting IO problems).

@acdha does Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()) seem reasonable for being the default instead of Executors.newCachedThreadPool()?

acdha commented 6 years ago

That's exactly what I was wondering — as long as someone can override it for unusual cases, the CPU count seems like a reasonable default.

jscancella commented 6 years ago

Yup, they are able to because a different user asked to be able to finely tune that threadpool. That's why there are 4 different constructors on that class, to be able to override various parts of it or keep the defaults.

acdha commented 6 years ago

Yeah, I figure there are a few cases where someone would need to change that value but it really does seem like most of them would be edge cases.