Skip to content

HBASE-30358 Fix TestMetaTableForReplica on Java 21 - #8621

Open
junegunn wants to merge 1 commit into
apache:masterfrom
junegunn:HBASE-30358
Open

HBASE-30358 Fix TestMetaTableForReplica on Java 21#8621
junegunn wants to merge 1 commit into
apache:masterfrom
junegunn:HBASE-30358

Conversation

@junegunn

@junegunn junegunn commented Sep 4, 2026

Copy link
Copy Markdown
Member

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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_NAME that is fragile under Java 21 module/access rules.
  • Updated testMetaTableNameForReplicaWithSuffix to assert the suffix logic by calling the same initializer method used by TableName’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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants