Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7511] Ensure the degreeOfConcurrency is a positive number in MavenExecutionRequest #767

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

kwart
Copy link
Contributor

@kwart kwart commented Jul 12, 2022

JIRA: https://issues.apache.org/jira/browse/MNG-7511

This PR ensures the degreeOfConcurrency is always a positive number (defaulting to 1). It resolves issues when the computed value is < 1.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MNG-XXX] SUMMARY, where you replace MNG-XXX
    and SUMMARY with the appropriate JIRA issue. Best practice is to use the JIRA issue
    title in the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

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

I am not convinced by this. It should throw an IAE here. I would expect to fix the source.

@kwart
Copy link
Contributor Author

kwart commented Jul 12, 2022

I am not convinced by this. It should throw an IAE here. I would expect to fix the source.

To me, it seems like the safest approach.

Another place to put the fix would be the MavenCli.calculateDegreeOfConcurrencyWithCoreMultiplier(...) method, but I like the protection in the config object more as it handles more cases without doing harm.

Still, if you request the change, I can move the fix to the calculateDegreeOfConcurrencyWithCoreMultiplier(...) method.

@michael-o
Copy link
Member

I think I have a better idea for this. First of all the arg need to checked whether it is a really an int or float. The C must be at the end. It must be larger than 0. The IAE still stands. When doing with float we could either use ceiling or floor. And then here set to one when smaller than 1.

@kwart
Copy link
Contributor Author

kwart commented Jul 13, 2022

The C allowed only at the end would break the backward compatibility, see the MavenCliTest.

So I've added a new commit with additional checks in the MavenCli.calculateDegreeOfConcurrencyWithCoreMultiplier(String) method.

To be honest, the change from the NumberFormatException to IllegalArgumentException is also not backward compatible, but it's not a change on the sunshine call path.

@kwart kwart force-pushed the MNG-7511-degreeOfConcurrency-positive branch from a9592da to a2ed3bd Compare July 13, 2022 20:13
@michael-o
Copy link
Member

Picking this up...A breaking change in Maven 4 is fully acceptable.

@michael-o
Copy link
Member

michael-o commented Jul 17, 2022

@kwart Added a commit on top:

  • Using C not at the end was never documented, so it is undefined behavior. Thus, don't rely on
  • Change of exception: Well, it is CLI, not for embedding into an IDE or so. For the user on the CLI it does not matter.

I am not 100% happy because there are no methods to verify a true mathematical integer (whole number) and a real (fraction number). But is is likely good enough for now.

WDYT?

@kwart
Copy link
Contributor Author

kwart commented Jul 18, 2022

👍 LGTM
Thanks for jumping on it.

@michael-o michael-o force-pushed the MNG-7511-degreeOfConcurrency-positive branch from 1929eb9 to 03b1faf Compare July 18, 2022 11:36
@asfgit asfgit closed this in 03b1faf Jul 18, 2022
@asfgit asfgit merged commit 03b1faf into apache:master Jul 18, 2022
@michael-o
Copy link
Member

@kwart If you want this in Maven 3.9 please provide a followup PR.

@kwart
Copy link
Contributor Author

kwart commented Jul 18, 2022

@michael-o Thanks for merging.

WRT 3.9 backport: Should I care about the exception type and the -TC<float> format, or should it be rather the 1:1 backport?

@kwart kwart deleted the MNG-7511-degreeOfConcurrency-positive branch July 18, 2022 12:06
@michael-o
Copy link
Member

@michael-o Thanks for merging.

WRT 3.9 backport: Should I care about the exception type and the -TC<float> format, or should it be rather the 1:1 backport?

Back port 1:1 because:

  • -TC<float> was never documented
  • This is a class with a main() not really intended for code use, but both exceptions are still IAE.

kwart added a commit to kwart/maven that referenced this pull request Jul 18, 2022
kwart added a commit to kwart/maven that referenced this pull request Jul 18, 2022
asfgit pushed a commit that referenced this pull request Feb 17, 2023
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