public static UUID getOrCreateUserToken ( ) { UUID userToken ; if ( Request . getPerThreadRequestData ( ) . getRequestId ( ) != null ) { try { userToken = UUID . fromString ( Request . getPerThreadRequestData ( ) . getRequestId ( ) ) ; } catch ( final IllegalArgumentException ignored ) { userToken = UUIDs . randomUUID ( ) ; } } else { userToken = UUIDs . randomUUID ( ) ; } return userToken ; }
Use REQUEST_ID_HEADER if this is provided and looks like a UUID if not allocate a random one .