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

fix output window stacktrace parsing when mvnd is used. #5099

Merged
merged 1 commit into from
Dec 21, 2022

Conversation

mbien
Copy link
Member

@mbien mbien commented Dec 12, 2022

mvnd is using WARN instead of WARNING (switched to SLF4J it seems) and prints the output type (stderr|stdout) on exceptions which causes stack traces to be not parsed.

The Level enum is public api so we can't really change that. Instead, WARN is simply mapped to the WARNING enum.

As side effect this also fixes some of the log level parsing which means that some of the maven output is now painted in a yellowish color. This looks good with the dark theme but might need some tweaks for the light theme.

test snippet:

    public static void main(String[] args) {
        List.of(1).clear();
    }

NB 16:
mvnd-stacktrace-before

PR applied:
mvnd-stacktrace-after

@mbien mbien added the Maven [ci] enable "build tools" tests label Dec 12, 2022
@mbien mbien added this to the NB17 milestone Dec 12, 2022
@mbien mbien force-pushed the mvnd-stacktrace-parsing-fix branch 2 times, most recently from 92cabca to 2968ee0 Compare December 14, 2022 23:53
@mbien mbien marked this pull request as ready for review December 15, 2022 01:59
@mbien mbien requested a review from jglick December 15, 2022 02:08
Copy link
Contributor

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Is there no test coverage for these utilities? It is hard for me to follow the impact from code inspection.

@jglick
Copy link
Contributor

jglick commented Dec 15, 2022

BTW a before-and-after screenshot would be really helpful in the PR description as I am not positive I know what sort of output you are referring to here.

@mbien
Copy link
Member Author

mbien commented Dec 15, 2022

BTW a before-and-after screenshot would be really helpful in the PR description as I am not positive I know what sort of output you are referring to here.

of course. Should have done that right away. The description is a bit cryptic I have to admit.

Somewhere between NB 8 and 9 the output window is also posting the ExecutionException. I searched a bit but couldn't figure out where this is coming from. As far as I see its directly from maven and, not added by netbeans. However, when run in CLI with the same flags it does not appear there.

@mbien mbien force-pushed the mvnd-stacktrace-parsing-fix branch 2 times, most recently from 1e03f1b to 7cbfd4c Compare December 15, 2022 21:41
Comment on lines -393 to +425
if (stackTraceElement.matcher(line).find()) {
if (line.endsWith(")") && stackTraceElement.matcher(line).matches()) {
Copy link
Member Author

@mbien mbien Dec 15, 2022

Choose a reason for hiding this comment

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

now I remember why i switched it to find() in the first place: the folding code was already using find() using the same pattern :)

updated the regexp and switched everything to matches() + added a fast path for even less overhead.

Copy link
Contributor

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Looks right. For now this is just tested interactively I guess.

@@ -50,7 +50,9 @@
* @author mkleint
*/
public final class OutputUtils {
public static final Pattern linePattern = Pattern.compile("(?:\\[catch\\])?\\sat (.*)\\((?:Native Method|(.*)\\.java\\:(\\d+))\\)"); //NOI18N

// example: '[WARN] at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)'
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

mvnd is using WARN instead of WARNING and prints the output type
(stderr|stdout) on exceptions.

Improvements to some regex patterns so that the faster match() can
be used instead of find(), which improves parsing speed of long lines.
@mbien mbien force-pushed the mvnd-stacktrace-parsing-fix branch from 7cbfd4c to b2856f4 Compare December 15, 2022 22:07
@mbien mbien merged commit 8678d58 into apache:master Dec 21, 2022
@mbien
Copy link
Member Author

mbien commented Dec 21, 2022

@jglick thank you or your reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maven [ci] enable "build tools" tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants