Skip to content

Return a list of exceptions encountered during verification #113

Description

@johnscancella

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions