Copilot commented on code in PR #8271:
URL: https://github.com/apache/hbase/pull/8271#discussion_r3304930493
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionTracing.java:
##########
@@ -73,41 +64,34 @@ public class TestHRegionTracing {
private static byte[] VALUE = Bytes.toBytes("value");
- @Rule
- public final OpenTelemetryRule traceRule = OpenTelemetryRule.create();
-
- @Rule
- public final TableNameTestRule tableNameRule = new TableNameTestRule();
+ @RegisterExtension
+ public static final OpenTelemetryExtension traceRule =
OpenTelemetryExtension.create();
- private WAL wal;
+ @RegisterExtension
+ public final TableNameTestExtension tableNameRule = new
TableNameTestExtension();
private HRegion region;
- @AfterClass
+ @AfterAll
public static void tearDownAfterClass() throws IOException {
UTIL.cleanupTestDir();
}
- @Before
- public void setUp() throws IOException {
+ @BeforeEach
+ public void setUp() throws Throwable {
+ traceRule.clearSpans();
TableName tableName = tableNameRule.getTableName();
TableDescriptor desc = TableDescriptorBuilder.newBuilder(tableName)
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY)).build();
RegionInfo info = RegionInfoBuilder.newBuilder(tableName).build();
ChunkCreator.initialize(MemStoreLAB.CHUNK_SIZE_DEFAULT, false, 0, 0, 0,
null,
MemStoreLAB.INDEX_CHUNK_SIZE_PERCENTAGE_DEFAULT);
- wal = HBaseTestingUtil.createWal(UTIL.getConfiguration(),
- new Path(UTIL.getDataTestDir(), tableName.getNameAsString()), null);
- region = HRegion.createHRegion(info, UTIL.getDataTestDir(),
UTIL.getConfiguration(), desc, wal);
region = UTIL.createLocalHRegion(info, desc);
}
- @After
+ @AfterEach
public void tearDown() throws IOException {
- if (region != null) {
- region.close();
- }
- Closeables.close(wal, true);
+ HBaseTestingUtil.closeRegionAndWAL(region);
}
Review Comment:
`@AfterEach` unconditionally closes `region`. If `setUp` fails before
`region` is assigned, this can throw a NullPointerException during cleanup and
obscure the real failure. Guard the close call with a null check (and
optionally set `region = null` after closing).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]