Skip to content

HBASE-30227 Disallow JUnit4 imports in source code#8362

Merged
liuxiaocs7 merged 2 commits into
apache:masterfrom
liuxiaocs7:HBASE-30227
Jun 17, 2026
Merged

HBASE-30227 Disallow JUnit4 imports in source code#8362
liuxiaocs7 merged 2 commits into
apache:masterfrom
liuxiaocs7:HBASE-30227

Conversation

@liuxiaocs7

Copy link
Copy Markdown
Member

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Assert and org.junit.Assume.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pom.xml Outdated
@liuxiaocs7 liuxiaocs7 changed the title HBASE-30227 Disallow JUnit4 Assert/Assume imports in source code HBASE-30227 Disallow JUnit4 imports in source code Jun 16, 2026
@liuxiaocs7

Copy link
Copy Markdown
Member Author

wait #8361 in

@Apache9

Apache9 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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?

@liuxiaocs7

liuxiaocs7 commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

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

image

@Apache9

Apache9 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

image

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.

@guluo2016 guluo2016 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@liuxiaocs7

Copy link
Copy Markdown
Member Author

Failed UTs seems unrelated, let me merge.

@liuxiaocs7 liuxiaocs7 merged commit f1023e6 into apache:master Jun 17, 2026
18 of 24 checks passed
liuxiaocs7 added a commit that referenced this pull request Jun 17, 2026
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Peng Lu <lupeng@apache.org>
liuxiaocs7 added a commit to liuxiaocs7/hbase that referenced this pull request Jun 17, 2026
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Peng Lu <lupeng@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants