Skip to content

fix: correct inverted equality checks in WarUtils.isRelated() - #625

Open
elharo wants to merge 2 commits into
apache:masterfrom
elharo:fix-619-inverted-equality
Open

fix: correct inverted equality checks in WarUtils.isRelated()#625
elharo wants to merge 2 commits into
apache:masterfrom
elharo:fix-619-inverted-equality

Conversation

@elharo

@elharo elharo commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #619

WarUtils.isRelated() returned false when version, type, classifier, or scope were equal between artifact and dependency — the opposite of the intended logic (should return false only when they differ).

Includes TDD: wrote failing tests first (7 test cases covering all isRelated() branches), then applied the fix.

The method returned false when version, type, classifier, or scope
were equal between artifact and dependency — the opposite of the
intended logic. Fixed by negating the equality checks.

Fixes apache#619

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes WarUtils.isRelated() so it returns false only when version, type, classifier, or scope differ between an Artifact and a Dependency (instead of when they’re equal), addressing the inverted-equality bug described in #619.

Changes:

  • Corrected the inverted equality checks in WarUtils.isRelated() for version, type, classifier, and scope.
  • Added a new JUnit test class covering several isRelated() scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/apache/maven/plugins/war/util/WarUtils.java Fixes isRelated() comparison logic so matching artifacts/dependencies are treated as related.
src/test/java/org/apache/maven/plugins/war/util/WarUtilsTest.java Adds unit tests for isRelated() behavior across attribute mismatch cases.

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

Comment thread src/test/java/org/apache/maven/plugins/war/util/WarUtilsTest.java
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@elharo
elharo requested review from khmarbaise and ppkarwasz July 26, 2026 11:40
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.

WarUtils.isRelated() has inverted equality checks for version, type, classifier, scope

2 participants