Skip to content

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

Merged
merged 3 commits into from
Jun 10, 2025

Conversation

shubhluck
Copy link
Contributor

…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

Copy link
Member

@deniskuzZ deniskuzZ left a 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?

@shubhluck
Copy link
Contributor Author

@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(
Copy link
Member

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}",
Copy link
Member

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}]

@shubhluck
Copy link
Contributor Author

@deniskuzZ thank you again for reviewing the PR, updated with suggested changes

Copy link
Member

@deniskuzZ deniskuzZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, pending tests

Copy link

sonarqubecloud bot commented Jun 9, 2025

@deniskuzZ deniskuzZ merged commit d458193 into apache:master Jun 10, 2025
4 checks passed
@shubhluck shubhluck deleted the HIVE-28996 branch June 11, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants