JDK-8219815 : UUID.fromString() is too lax
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 11.0.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-02-26
  • Updated: 2019-02-27
  • Resolved: 2019-02-27
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
64-bit Windows 10. Java runtime: Azul Zulu; Zulu 11.29+3 686fa9062e1b ; corresponding to JRE 11.0.2

A DESCRIPTION OF THE PROBLEM :
An invalid (too short) UUID string is parsed successfully, i.e., without exception.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Call UUID.fromString on a too short string, for example UUID.fromString("fecf3e99-0422-4936-9b9e-348a7e1fa5");

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Throws exception.
ACTUAL -
fromString("fecf3e99-0422-4936-9b9e-348a7e1fa5") succeeds and constructs an UUID object with the value fecf3e99-0422-4936-9b9e-00348a7e1fa5 (note the leading 00 in the last group).

CUSTOMER SUBMITTED WORKAROUND :
Manual check that the lengt of input string equals to 36 before calling UUID.fromString().

FREQUENCY : always



Comments
Closing as duplicate of JDK-8216407.
27-02-2019