Reputation: 7084
I'm trying to validate that a string is a UUID
. Apparently I don't understand what a valid UUID is. This is what I thought was an invalid UUID - 55bb6be3-078c-4a49-a4e6-1e05776ed7e81234
But when I pass that to UUID.fromString()
, instead of throwing IllegalArgumentException
, it returns a uuid with the value 55bb6be3-078c-4a49-bee7-776ed7e81234
Upvotes: 1
Views: 4516
Reputation: 3449
To throw an IllegalArgumentException
, there should be less than 4 dashes - or 5 components. Here is the code part that throws the exception:
String[] components = name.split("-");
if (components.length != 5)
throw new IllegalArgumentException("Invalid UUID string: "+name);
Your input is not invalid, it has overflew components, therefore the returning UUID
is different from the input.
Upvotes: 1