Copilot commented on code in PR #8136:
URL: https://github.com/apache/hbase/pull/8136#discussion_r3139277855


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestRpcServer.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.ipc;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.hadoop.hbase.HBaseTestingUtility;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.client.Get;
+import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.client.Result;
+import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.TableDescriptor;
+import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
+import org.apache.hadoop.hbase.regionserver.DisabledRegionSplitPolicy;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.LoadTestKVGenerator;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestInfo;
+
+public abstract class AbstractTestRpcServer {
+
+  private static final byte[] FAMILY = Bytes.toBytes("f");
+  private static final byte[] QUALIFIER = Bytes.toBytes("q");
+  private static final int NUM_ROWS = 100;
+  private static final int MIN_LEN = 1000;
+  private static final int MAX_LEN = 1000000;
+  protected static final LoadTestKVGenerator GENERATOR = new 
LoadTestKVGenerator(MIN_LEN, MAX_LEN);
+  protected static HBaseTestingUtility TEST_UTIL;
+  protected TableName tableName;
+
+  @BeforeEach
+  public void setUpTest(TestInfo testInfo) {
+    tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());

Review Comment:
   Calling `testInfo.getTestMethod().get()` can throw a 
`NoSuchElementException` with a poor failure message if the method is absent 
(e.g., certain template/dynamic scenarios). Prefer `orElseThrow(...)` 
(optionally with a descriptive message) or derive a stable name from 
`testInfo.getDisplayName()` when `getTestMethod()` is empty.
   ```suggestion
       tableName = TableName.valueOf(testInfo.getTestMethod()
         .map(java.lang.reflect.Method::getName)
         .orElseThrow(() -> new IllegalStateException(
           "Test method is not available for test: " + 
testInfo.getDisplayName())));
   ```



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

Reply via email to