RFR: 8216407: java.util.UUID.fromString accepts input that does not match expected format

Peter Levart peter.levart at gmail.com
Sun Mar 8 08:28:26 UTC 2020



On 3/8/20 8:45 AM, Peter Levart wrote:
> Hi Roger,
>
> What about deprecating this method (not for removal at this time) and 
> creating new method UUID.valueOf(String) or similar that would be more 
> strict?

... since Andriy Plokhotnyuk and Claes Redestad have already done all 
the coding (nice work!) while optimizing the UUID.fromString method in 
[1], it is just a matter of wiring up the code to new public method like 
in [2] for example. The question is only whether this is a desirable 
addition. I think it is. I can imagine bugs are a possible outcome when 
a programmer doesn't realize that different String values can 
successfully map to a single UUID value.

Regards, Peter


[1] https://bugs.openjdk.java.net/browse/JDK-8196334
[2] 
http://cr.openjdk.java.net/~plevart/jdk-dev/8216407_UUID.valueOf/webrev.01/

>
> Peter
>
> On 3/6/20 7:15 PM, Roger Riggs wrote:
>> Hi Chihiro, et.al.,
>>
>> Thanks for taking a look at this issue,  however...
>>
>> There has been a long history of concerns[1] about breaking existing 
>> applications
>> that depend on the loose parsing of UUIDs.  Throwing an exception 
>> where it did not
>> previously is an incompatible change.
>>
>> The crucial concern about performance parsing conforming strings has 
>> been addressed by:
>>
>> 8196334 Optimize UUID#fromString 
>> <https://bugs.openjdk.java.net/browse/JDK-8196334>
>>
>> I propose to close these as WILL-NOT-FIX: and hope that the next 
>> several times it gets reported
>> they will be closed as duplicates.
>>
>> 8216407 <https://bugs.openjdk.java.net/browse/JDK-8216407> 
>> java.util.UUID.fromString accepts input that does not match expected 
>> format
>>
>> 8165199 
>> <https://bugs.openjdk.java.net/browse/JDK-8165199>UUID.fromString 
>> accepts wrong placements of the dashes
>>
>> Any other suggestions welcome.
>>
>> Thanks, Roger
>>
>> [1] 
>> http://mail.openjdk.java.net/pipermail/core-libs-dev/2018-December/057470.html
>>
>>
>> On 3/2/20 10:39 AM, Chihiro Ito wrote:
>>> Hi,
>>>
>>> I tried to correct this problem.
>>>
>>> Could you review this fix, please?
>>>
>>> According to the RFC 4122, UUID has a fixed format. I tried to raise an
>>> exception if a string was specified that is not suitable for this
>>> format. Also, is there anything else I should be aware of with this 
>>> bug?
>>>
>>> Webrev : http://cr.openjdk.java.net/~cito/JDK-8216407/webrev.00/
>>> JBS : https://bugs.openjdk.java.net/browse/JDK-8216407
>>>
>>> Regards,
>>> Chihiro
>>
>



More information about the core-libs-dev mailing list