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

Reduce pretty formatter output flushes for DataTables (#2536) #2537

Closed
wants to merge 2 commits into from

Conversation

scottadav
Copy link
Contributor

🤔 What's changed?

See details in #2536 and #2481

⚡️ What's your motivation?

DataTables were formatted incorrectly by the Pretty formatter when using Gradle.

🏷️ What kind of change is this?

The problem stemmed from the fact that Gradle adds a newline with every flush of the output stream, and cucumber-jvm was flushing the output stream very frequently. For DataTables, it was flushing with every cell, padding, and delimiter. This caused an unreadable output. It also reduces I/O performance by flushing excessively.

  • 🐛 Bug fix (non-breaking change which fixes a defect)

♻️ Anything particular you want feedback on?

Make sure it follows project standards.

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

This text was originally generated from a template, then edited by hand. You can modify the template here.

Copy link
Contributor

@mpkorstanje mpkorstanje left a comment

Choose a reason for hiding this comment

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

While this solution reduces the number of flushes, it tries to solve a problem that happens several abstractions down. As a result the problem is not solved fundamentally and will re-occur whenever a flush does not coincide with a newline.

Please consider all my comments from #2481 to develop your solution.

// Gradle adds a newline for every call to flush() unless the most
// recent character written was already a newline. That leads
// to some VERY difficult to read tables on the console.
StringBuilder buffer = new StringBuilder();
Copy link
Contributor

Choose a reason for hiding this comment

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

Normally it could be assumed that the Appendable is well behaved. However for the formatter we know that lines may interleave with other output as it writes to System.out. Consider pushing this buffer up to the pretty formatter instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed the buffer up to the pretty formatter by commit f4a2d42 . Only caveat - I can't decide how to test that particular change or whether a unit test is warranted.

@scottadav
Copy link
Contributor Author

mpkorstanje, I created a separate pull request #2541, which might be more acceptable as a general-purpose solution. Could you take a look at that one? If you prefer the other solution, feel free to close this one. Either of them solves my display problem.

@mpkorstanje
Copy link
Contributor

Superseded by #2481

@mpkorstanje mpkorstanje closed this May 2, 2022
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.

2 participants