Skip to content

Update SMIMETest.java - #2386

Closed
cragkhit wants to merge 1 commit into
bcgit:mainfrom
cragkhit:matcha-update-smime-array-comparison-clean
Closed

Update SMIMETest.java#2386
cragkhit wants to merge 1 commit into
bcgit:mainfrom
cragkhit:matcha-update-smime-array-comparison-clean

Conversation

@cragkhit

@cragkhit cragkhit commented Aug 3, 2026

Copy link
Copy Markdown

Hi. We are researchers from Mahidol University, Thailand, and the State University of Ceará, Brazil, working on a research project for improving open-source projects by using the latest accepted answer from Stack Overflow that matched your code snippet. We found this recommendation for improving your code from https://stackoverflow.com/a/40056844.

Note: Our study is approved by the Institutional Review Board of Mahidol University. You can find the participant information sheet explaining this study at https://drive.google.com/file/d/1ml5AqrtWQ9pnifTQyTFTcWQmwp6RuPA7/view?usp=sharing.

Disclosure: This contribution was prepared with assistance from OpenAI Codex. I reviewed and verified the resulting change.

This replaces #2371, whose branch contained unrelated divergent history.

Proposed change

Add identity and null checks before comparing the byte arrays.

Testing

  • ./gradlew :util:compileTestJava passed.
  • ./gradlew :util:test compiled and ran, but 10 unrelated C509CertificateTest cases failed with FileNotFoundException because their resource files were unavailable in the checkout.
  • The repository Gradle configuration does not expose SMIMETest as an individually selectable test.

Add identity and null checks before comparing byte arrays.
@cragkhit cragkhit mentioned this pull request Aug 3, 2026
@dghgit dghgit self-assigned this Aug 4, 2026
@dghgit

dghgit commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Appreciate the effort to improve the library. It's an interesting idea, although in this case it's really the wrong spot - it's a test class and the method should never be called with anything that's null. Perhaps more importantly, the patches "if (a == b)" will return true if both a and b are null, which would be a disaster for the test's effectiveness.

For these reasons, this one I will not merge, however I would be interested to see what else you come up with.

@dghgit dghgit closed this Aug 4, 2026
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.

2 participants