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

Handle invalid hex representations of GUIDs #4174

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Jun 23, 2023

Identify the Bug or Feature request

Fixes a bug introduced in PR #4127, for issue #3852

Description of the Change

The GUID(String) constructor is documented to throw an InvalidGUIDException when the parameter is not a valid representation of a GUID. However that was not being done when the string is not even a valid hex string. Instead, the NumberFormatException thrown by HexFormat.parseHex() was allowed to propagate, which was not being handled by the new map ID support.

This PR changes that constructor to obey its contract. The NumberFormatException (any Exception really) thrown by HexFormat.parseHes() is now caught and an InvalidGUIDException is thrown in its place.

Also some cleanup: the byte[] constructor for GUID was unused, so it has been removed.

Possible Drawbacks

Should be none, unless I overlooked a caller that handles the NumberFormatException / IllegalArgumentException.

Documentation Notes

N/A

Release Notes

N/A


This change is Reviewable

The `NumberFormatException` thrown by `HexFormat.parseHex()` is now handled in the `GUID(String)` constructor, and
rethrown as a `InvalidGUIDException` instead.
The `GUID(byte[])` and corresponding `GUID.valueOf(byte[])` were not used, so they have been removed.
@cwisniew cwisniew added this pull request to the merge queue Jun 24, 2023
Merged via the queue into RPTools:develop with commit b73929a Jun 24, 2023
@kwvanderlinde kwvanderlinde deleted the feature/3852-fix-fallback-exception branch August 31, 2023 02:44
@cwisniew cwisniew added the bug label Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

2 participants