HBASE-30227 Disallow JUnit4 imports in source code#8362
Conversation
liuxiaocs7
commented
Jun 16, 2026
- see: HBASE-30227
There was a problem hiding this comment.
Pull request overview
Updates the parent Maven Enforcer restrictImports rules to prevent using JUnit4 APIs (notably org.junit.*, Assert, and Assume) in favor of JUnit5, aligning with HBASE-30227’s goal to avoid JUnit4 imports in the codebase.
Changes:
- Expand banned imports under the “Use junit5 instead” rule to include JUnit4 packages (
org.junit.*and several subpackages). - Explicitly ban static imports from
org.junit.Assertandorg.junit.Assume.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
wait #8361 in |
|
In HBASE-30200, we have already banned all junit4 dependencies. Since there are still junit4 assert references in hadoop mini cluster code, I introduced dummy Assert class to delegate all calls to junit5 Assertions. And all the method in this class has RestrictedApi annotation to disable usage in HBase code base. I think this is enough? |
Hi, @Apache9, the extra import ban seems still useful as an earlier and clearer guardrail, it fails the build when new JUnit4 imports are added, see #8340 and #8361, WDYT
|
In #8361 , the branch compile is already failing right? You should see an error in pre commit check when adding the calls. But yeah. this does not fail local builds if you do not enable error prone, with this PR in the local build will also fail too. |
|
Failed UTs seems unrelated, let me merge. |
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Peng Lu <lupeng@apache.org>
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org> Signed-off-by: Peng Lu <lupeng@apache.org>

