GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [Backport] Evaluate profile activation conditions lazily by gnodet · Pull Request #13144 · apache/maven

Conversation

@gnodet

@gnodet gnodet commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Backport of #13139 to the maven-4.0.x branch.

Cherry-pick of 2a555d0, applied cleanly with no conflicts.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Dev-next-gen @gnodet
Evaluate profile activation conditions lazily
88360a8
* Evaluate profile activation conditions lazily

The condition parser evaluated every operand as it parsed it, so both
branches of if(..) and the right-hand side of && and || were always
computed. A branch that is not valid for the current input then fails
the whole condition. The if(..) example from the condition
documentation, substring(${java.version}, 0, indexOf(${java.version},
'-')), throws StringIndexOutOfBoundsException on any java.version
without a '-', and a guard such as length(x) >= 3 cannot protect a
substring(x, 0, 3) that follows it with &&.

Skip the unselected if(..) branch and the right operand of && / || when
the left one already decides the result. Skipped operands are still
checked for balanced parentheses, so malformed expressions keep failing.

* Name the if function checked by the condition parser

Replace the "if" literal in parseArgumentList with a named constant, so
the one place where the parser depends on a function name is visible,
and cover the two-argument if(false, 'a') call next to if(true, 'a').
@gnodet gnodet added the bug Something isn't working label Sep 15, 2026
@gnodet gnodet added this to the 4.0.0-rc-7 milestone Sep 15, 2026
gnodet-bot
gnodet-bot reviewed Sep 15, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Clean backport of #13139 — cherry-pick applies without conflicts. Short-circuit logic and skipOperand depth tracking are correct. One nit on readability of the lazy-arg condition.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/ConditionParser.java Outdated
Comment on lines +439 to +441
if (IF_FUNCTION.equals(functionName)
&& (index == 1 || index == 2)
&& toBoolean(args.get(0)) != (index == 1)) {

@gnodet-bot gnodet-bot Sep 15, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

💡 Readability nit: toBoolean(args.get(0)) != (index == 1) is correct but takes a moment to decode. The intent is: skip the branch that was not selected by the condition. An explicit form makes the invariant obvious:

Suggested change
if (IF_FUNCTION.equals(functionName)
&& (index == 1 || index == 2)
&& toBoolean(args.get(0)) != (index == 1)) {
if (IF_FUNCTION.equals(functionName)
&& (index == 1 || index == 2)
&& toBoolean(args.get(0)) == (index == 2)) {

Or equivalently:

boolean condition = toBoolean(args.get(0));
if (IF_FUNCTION.equals(functionName) && (index == 1 || index == 2)
        && ((index == 1) ? !condition : condition)) {

Either form makes the if/else branch symmetry immediate to the reader. The suggestion above (== (index == 2)) reads as: "skip this argument when it's the branch the condition did not select."

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gnodet gnodet Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed in 06c24ba.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@gnodet gnodet Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fixed in 06c24ba.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet gnodet added the backport label Sep 15, 2026
@gnodet
Improve readability of if-function skip condition
06c24ba
gnodet-bot
gnodet-bot approved these changes Sep 15, 2026
View reviewed changes

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Re-review after 06c24ba: the readability nit from the previous review is addressed.

The new form toBoolean(args.get(0)) == (index == 2) reads left-to-right as "skip this branch when the condition's truth value matches the branch index" — clear and unambiguous. No new issues introduced.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@gnodet
gnodet merged commit 20317c7 into apache:maven-4.0.x Sep 15, 2026
22 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@gnodet
gnodet deleted the backport/13139-to-4.0.x branch September 15, 2026 18:11
@github-actions github-actions Bot assigned gnodet Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer
@gnodet-bot gnodet-bot gnodet-bot approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@gnodet gnodet

Labels

backport bug Something isn't working

Projects

None yet

Milestone

4.0.0-rc-7

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@gnodet @gnodet-bot @Dev-next-gen
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.