imbajin commented on code in PR #2911: URL: https://github.com/apache/incubator-hugegraph/pull/2911#discussion_r2531930624
########## hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/HbaseUnitTest.java: ########## @@ -0,0 +1,58 @@ +/* + * + * * 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.hugegraph.unit.hbase; + +import org.apache.hugegraph.testutil.Assert; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class HbaseUnitTest extends BaseHbaseUnitTest { + + private static final String GRAPH_NAME = "test_graph"; + + @Before Review Comment: ⚠️ **Test setup/teardown issue** Both `BaseHbaseUnitTest` and `HbaseUnitTest` have setup/teardown methods that may cause issues: 1. **Duplicate cleanup**: `@After` in both base and child class will close store/provider twice 2. **Setup order**: Child's `@Before` runs after parent's, but calls `provider.open()` which may conflict **Suggestion**: ```suggestion @Before public void setUp(){ super.setup(); // Call parent setup first this.provider.open(GRAPH_NAME); this.provider.init(); } @After public void teardown(){ // Remove duplicate cleanup - handled by parent // Only add child-specific cleanup here if needed } ``` ########## hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/unit/hbase/BaseHbaseUnitTest.java: ########## @@ -0,0 +1,63 @@ +/* + * + * * 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.hugegraph.unit.hbase; + +import org.apache.hugegraph.backend.store.BackendStore; +import org.apache.hugegraph.backend.store.hbase.HbaseStoreProvider; +import org.apache.hugegraph.config.HugeConfig; +import org.apache.hugegraph.unit.BaseUnitTest; +import org.apache.hugegraph.unit.FakeObjects; +import org.junit.After; +import org.junit.Before; + +public class BaseHbaseUnitTest extends BaseUnitTest{ + + protected BackendStore store; + + protected HugeConfig config; + protected HbaseStoreProvider provider; + + @Before + public void setup() { + this.config = FakeObjects.newConfig(); + + this.provider = new HbaseStoreProvider(); + + this.store = this.provider.loadSystemStore(config); + } + + @After + public void down(){ Review Comment: 🧹 **Code quality: Silent exception swallowing** Using empty catch blocks makes debugging difficult. Consider: ```suggestion @After public void down(){ if (this.store != null) { try { this.store.close(); } catch (Exception e) { LOG.warn("Failed to close store", e); } } if (this.provider != null) { try { this.provider.close(); } catch (Exception e) { LOG.warn("Failed to close provider", e); } } } ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
