-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-28996 Fix invalid string formatting to prevent NumberFormatExcep… #5849
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change looks good.
@shubhluck, would you mind adding a unit test for this?
@deniskuzZ Thanks for the review! I’ve added the requested unit test. Could you also add me to the committer list when convenient? |
long maxWriteIdOnFilesystem = 2L; // From source table insertions (2 operations) | ||
long maxAllocatedWriteId = 1L; // From target table insertion (1 operation) | ||
|
||
String expectedMessage = MessageFormat.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use the MessageFormat
in the expectation, just hardcode and update the text
String expectedMessage = "The highest writeId [2] in the table 'acidtblpartmsck' is greater than the maximum writeId allocated in the metastore [1]"
Assert.assertTrue(e.getCause() instanceof MetaException);
Assert.assertEquals(expectedMessage, e.getCause().getMessage());
@@ -399,7 +399,7 @@ private void validateAndAddMaxTxnIdAndWriteId(long maxWriteIdOnFilesystem, long | |||
long maxAllocatedWriteId = getMsc().getMaxAllocatedWriteId(dbName, tableName); | |||
if (maxAllocatedWriteId > 0 && maxWriteIdOnFilesystem > maxAllocatedWriteId) { | |||
throw new MetaException(MessageFormat | |||
.format("The maximum writeId {} in table {} is greater than the maximum allocated in the metastore {}", | |||
.format("The maximum writeId {0} in table {1} is greater than the maximum allocated in the metastore {2}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The highest writeId [{0}] in the table '{1}' is greater than the maximum writeId allocated in the metastore [{2}]
@deniskuzZ thank you again for reviewing the PR, updated with suggested changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, pending tests
|
…tion
What changes were proposed in this pull request?
Fix invalid string formatting to prevent NumberFormatException
https://issues.apache.org/jira/browse/HIVE-28996
Why are the changes needed?
Fix invalid string formatting for MessageFormat class
Does this PR introduce any user-facing change?
No
Is the change a dependency upgrade?
No
How was this patch tested?
NA