Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a list of exceptions encountered during verification #113

Open
johnscancella opened this issue Feb 28, 2018 · 0 comments
Open

Return a list of exceptions encountered during verification #113

johnscancella opened this issue Feb 28, 2018 · 0 comments

Comments

@johnscancella
Copy link
Contributor

Currently we throw an exception at the first problem we discover when verifying a bag:

@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
void checkHashes(final Manifest manifest) throws CorruptChecksumException, InterruptedException, VerificationException{
final CountDownLatch latch = new CountDownLatch( manifest.getFileToChecksumMap().size());
//TODO maybe return all of these at some point...
final Collection<Exception> exceptions = Collections.synchronizedCollection(new ArrayList<>());
for(final Entry<Path, String> entry : manifest.getFileToChecksumMap().entrySet()){
executor.execute(new CheckManifestHashesTask(entry, manifest.getAlgorithm().getMessageDigestName(), latch, exceptions));
}
latch.await();
if(!exceptions.isEmpty()){
final Exception e = exceptions.iterator().next();
if(e instanceof CorruptChecksumException){
logger.debug(messages.getString("checksums_not_matching_error"), exceptions.size());
throw (CorruptChecksumException)e;
}
throw new VerificationException(e);
}
}

Instead we should return a list of errors in the case that there is more than one problem with a bag and let the user of this library decide how to deal with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant