HBASE-30358 Fix TestMetaTableForReplica on Java 21 - #8621
Open
junegunn wants to merge 1 commit into
Open
Conversation
testMetaTableNameForReplicaWithSuffix cleared the FINAL bit on TableName.META_TABLE_NAME through a VarHandle on the private Field.modifiers so it could rewrite the static. On Java 21 that VarHandle is read-only and the write throws UnsupportedOperationException before Field.set is reached. --add-opens does not help: with the flag passed, the VarHandle reports SET as supported on 17 and unsupported on 21. The reflection was not needed. The test computed the expected name with TableName.initializeHbaseMetaTableName(conf), wrote it into the static, read it back and asserted equality, so that assertion could only fail if reflection itself broke. Assert on the return value instead, which is the method the class initializer itself calls. Drop the helper, the captured original value and the restore step with it. The restore was the last statement rather than a finally, so any earlier failure left META_TABLE_NAME overwritten for later tests in the same fork. Same family as HBASE-29614, which removed this pattern from TestBytes, TestByteBufferUtils and TestFromClientSide3WoUnsafe.
There was a problem hiding this comment.
🟢 Approval recommended
The changes remove Java 21-incompatible reflective access while preserving the core assertion of meta table suffix naming via the canonical initializer method.
Pull request overview
This PR updates an HBase server-side test to be compatible with Java 21 by removing reflective mutation of TableName.META_TABLE_NAME and asserting the intended meta table naming behavior via TableName.initializeHbaseMetaTableName(Configuration) instead.
Changes:
- Removed reflection-based modification/restoration of
TableName.META_TABLE_NAMEthat is fragile under Java 21 module/access rules. - Updated
testMetaTableNameForReplicaWithSuffixto assert the suffix logic by calling the same initializer method used byTableName’s class initialization.
File summaries
| File | Description |
|---|---|
| hbase-server/src/test/java/org/apache/hadoop/hbase/TestMetaTableForReplica.java | Reworks the “meta table name with suffix” test to avoid reflective static-final mutation and directly validate the initializer logic used by TableName. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/HBASE-30358
Remove unnecessary reflection that causes the test to fail on Java 21 without adding anything to the assertion.
Fixes: https://ci-hbase.apache.org/job/HBase%20Nightly%20JDK21%20test/job/HBASE-30354/2/testReport/junit/org.apache.hadoop.hbase/TestMetaTableForReplica/health_checks___yetus_jdk21_hadoop3_checks___testMetaTableNameForReplicaWithSuffix/