Incorrect data from ZipWorkflowOperationHandler if setting checksom of the attachment fails

Steps to reproduce

Here is the source code of the offending function:

InputStream in = null;
URI uri = null;
try {
in = new FileInputStream(zip);
uri = workspace.putInCollection(collectionId, mediaPackage.getIdentifier().compact() + ".zip", in);
} catch (FileNotFoundException e) {
throw new WorkflowOperationException("zip file " + zip + " not found", e);
} catch (IOException e) {
throw new WorkflowOperationException(e);
} finally {
IOUtils.closeQuietly(in);
}
logger.info("Zipped mediapackage {} moved to the {} archive", mediaPackage, collectionId);

Attachment attachment = (Attachment) MediaPackageElementBuilderFactory.newInstance().newElementBuilder()
.elementFromURI(uri, Type.Attachment, ARCHIVE_FLAVOR);
try {
attachment.setChecksum(Checksum.create(ChecksumType.DEFAULT_TYPE, zip));
} catch (IOException e) {
throw new WorkflowOperationException(e);
}
attachment.setMimeType(MimeTypes.ZIP);

Where attachment.setChecksum is called, an exception can be thrown. This is caught, but rethrown to the caller immediately. At this time, the mediapackage has already been added to the workspace collect, but is incomplete. Further, the caller may retry to add this package as the exception suggests that the call failed.

There is no test for this case yet.

Status

Assignee

Unassigned

Reporter

Christopher Brooks

Severity

Incorrectly Functioning With Workaround

Tags (folksonomy)

Components

Affects versions

Priority

Major
Configure