Skip to content

Conversation

@gnodet
Copy link
Contributor

@gnodet gnodet commented May 19, 2021

…ensible limits.

Slightly modified version of #472 / e47d647

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] - Fixes bug in ApproximateQuantiles,
    where you replace MNG-XXX 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.

@gnodet gnodet marked this pull request as draft May 19, 2021 15:37
@gnodet gnodet marked this pull request as ready for review May 19, 2021 15:37
@MartinKanters
Copy link
Contributor

Looks good to me!

Didn't think of this last time, but I'm wondering, when Jansi cannot determine the width, whether we should fallback the width of the terminal equal to the 'old' terminal width of 80 (I believe?). Then we are backwards-compatible for non-jansi terminals and probably would not have to change any ITs and unit tests. What do you think? And @mthmulders?

@gnodet
Copy link
Contributor Author

gnodet commented May 20, 2021

@MartinKanters it seems to work. I've forced pushed the change.

Fwiw, there is a minor problem with the terminal width which can be improved later: ideally, we'd make the difference between the System.out and System.err streams. Currently, MessageUtils.getTerminalWidth() relies on AnsiConsole.getTerminalWidth() which first tries the get the width of the terminal using System.out and then try with System.err. The downside is that if the output is redirected using mvn > out.txt or even simply mvn -l out.txt, then the computed terminal width is not relevant. It's no big deal though. This also makes we wonder if the MavenCli should use System.err to print non standard output (i.e. version, help, etc...) instead of System.out...

@MartinKanters
Copy link
Contributor

@MartinKanters it seems to work. I've forced pushed the change.

Nice, I definitely prefer defaulting to the old width. I see that you are not targeting any customized ITs and removed the changes in the unit tests. To me that proves that it's backwards compatible for non-ansi terminals.
And now that we have a constructor where we can put in the values, we can create some unit tests which verify that the terminal width is set correctly in all scenarios. I'm sorry that I'm asking for more changes on a PR that @mthmulders and I initially delivered... :)

Fwiw, there is a minor problem with the terminal width which can be improved later: ideally, we'd make the difference between the System.out and System.err streams. Currently, MessageUtils.getTerminalWidth() relies on AnsiConsole.getTerminalWidth() which first tries the get the width of the terminal using System.out and then try with System.err. The downside is that if the output is redirected using mvn > out.txt or even simply mvn -l out.txt, then the computed terminal width is not relevant. It's no big deal though. This also makes we wonder if the MavenCli should use System.err to print non standard output (i.e. version, help, etc...) instead of System.out...

Right, that indeed sounds like something that can be dealt with later. About the last point we can also create a thread on the dev mailing list.

@gnodet
Copy link
Contributor Author

gnodet commented May 20, 2021

@MartinKanters it seems to work. I've forced pushed the change.

Nice, I definitely prefer defaulting to the old width. I see that you are not targeting any customized ITs and removed the changes in the unit tests. To me that proves that it's backwards compatible for non-ansi terminals.
And now that we have a constructor where we can put in the values, we can create some unit tests which verify that the terminal width is set correctly in all scenarios. I'm sorry that I'm asking for more changes on a PR that @mthmulders and I initially delivered... :)

I've added a test to check various terminal widths.

Copy link
Contributor

@MartinKanters MartinKanters left a comment

Choose a reason for hiding this comment

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

LGTM! Let's keep it open for a bit to see if @mthmulders agrees.
I can merge it afterwards.

Copy link
Contributor

@mthmulders mthmulders left a comment

Choose a reason for hiding this comment

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

Thanks @gnodet!

@MartinKanters
Copy link
Contributor

Running the build on Jenkins. First try failed because of an infra issue, I think.

@MartinKanters MartinKanters merged commit a202308 into apache:master May 22, 2021
@gnodet gnodet deleted the MNG-6915 branch June 2, 2021 06:23
@jira-importer
Copy link

Resolve #8616

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.

4 participants