Junegunn Choi created HBASE-30358:
-------------------------------------

             Summary: TestMetaTableForReplica fails on Java 21 rewriting a 
static final field
                 Key: HBASE-30358
                 URL: https://issues.apache.org/jira/browse/HBASE-30358
             Project: HBase
          Issue Type: Bug
            Reporter: Junegunn Choi
            Assignee: Junegunn Choi


h2. Problem

{{TestMetaTableForReplica.testMetaTableNameForReplicaWithSuffix}} fails on Java 
21:
{noformat}
java.lang.UnsupportedOperationException: set
  at 
org.apache.hadoop.hbase.TestMetaTableForReplica.setStaticFinalField(TestMetaTableForReplica.java:164)
{noformat}
The test rewrites the static final {{TableName.META_TABLE_NAME}} by clearing 
its {{FINAL}} bit through a VarHandle on the private {{{}Field.modifiers{}}}. 
On Java 21 that VarHandle is read-only, so the write throws before 
{{Field.set}} is reached.

Same family as HBASE-29547 and HBASE-29605, both closed as duplicates of 
HBASE-29614. Found by the JDK 21 nightly axis added in HBASE-30354.
h2. No need for the reflection
{code:java}
TableName expected = TableName.initializeHbaseMetaTableName(conf);   // compute
setStaticFinalField(metaTableName, expected);                        // write 
the static
TableName current = TableName.META_TABLE_NAME;                       // read it 
back
assertNotEquals(TableName.getDefaultNameOfMetaForReplica(), current);
assertEquals(expected, current);
{code}
{{current}} holds the value the line above just wrote, so 
{{assertEquals(expected, current)}} can only fail if reflection itself is 
broken.
h2. Fix

Assert on the return value directly and delete the reflection:



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to