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

fix: calculate/add MD5 hash for multiple object delete. #581

Merged
merged 1 commit into from
Jun 2, 2017

Conversation

balamurugana
Copy link
Member

Fixes #579

@balamurugana
Copy link
Member Author

All functional tests pass with Amazon AWS S3

} else if (data instanceof byte[]) {
sha256Digest.update((byte[]) data, 0, len);
} else {
throw new InternalException("unknown data to calculate SHA256 hash. This should not happend. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown data source to calculate sha256 hash. This should not happen, please report this issue at https://github.com/minio/minio-java/issues - is better i think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

md5Digest.update((byte[]) data, 0, len);
} else {
throw new InternalException("unknown data to calculate SHA256 hash. This should not happend. "
+ "Please report this issue at https://github.com/minio/minio-java/issues");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above..

} else if (data instanceof byte[]) {
md5Digest.update((byte[]) data, 0, len);
} else {
throw new InternalException("unknown data to calculate SHA256 hash. This should not happend. "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above..

return BaseEncoding.base64().encode(md5Digest.digest());
}


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no. you can see double newlines between methods

Copy link
Contributor

@poornas poornas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a code review, have not tested yet.

sha256Hash = Digest.sha256Hash((RandomAccessFile) body, length);
} else if (body instanceof byte[]) {
sha256Hash = Digest.sha256Hash((byte[]) body, length);
Object data = body;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to consider ternary operator for conciseness
Object data = (body == null) ? new byte[0] : body;
int len = (body == null) ? 0 : length;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this case, data and len are reset when data == null in one if seems better to me for readability sake.

There is a chance of misread two (body == null) statements.

Copy link
Contributor

@poornas poornas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harshavardhana harshavardhana merged commit 8e21950 into minio:master Jun 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants