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

DigestBuilder should raise an exception when provided with invalid data #3

Open
trixpan opened this issue Apr 25, 2017 · 1 comment
Assignees

Comments

@trixpan
Copy link

trixpan commented Apr 25, 2017

as it currently is, DigestBuilder can be fed with bogus data, but depending on what gets fed it will raise all sort of Exceptions, requiring the consumer of the API to capture all sort of exceptions.

Examples:

feeding it with a empty strings results in ArrayIndexOutOfBoundsException

while feeding with an short hash string results in StringIndexOutOfBoundsException

It would be great if a particular exception was raised.

@jdvr
Copy link

jdvr commented Jul 24, 2017

I have verified that wrong inputs produce different java general exception.

I am going add an input check on builder method that produces an IllegalArgumentException when the hash is invalid.

What do you think @trixpan ?

new DigestBuilder().withHash("F42089EA34272885F0FB2D34E6911444C").build() 

java.lang.StringIndexOutOfBoundsException: String index out of range: 40
new DigestBuilder().withHash("").build() 
java.lang.ArrayIndexOutOfBoundsException: 0

@jdvr jdvr added the bug label Jul 25, 2017
@jdvr jdvr self-assigned this Jul 25, 2017
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

3 participants