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

[SUREFIRE-1992] Do not output class name on error/failure for certain exceptions #457

Closed
wants to merge 1 commit into from
Closed

[SUREFIRE-1992] Do not output class name on error/failure for certain exceptions #457

wants to merge 1 commit into from

Conversation

spannm
Copy link
Contributor

@spannm spannm commented Feb 4, 2022

Pull request 3/3 for this ticket. Please merge in order.

result.append( target.getClass().getSimpleName() );
result.append( getTruncatedMessage( throwable.getMessage(), MAX_LINE_LENGTH - result.length() ) );
result.append( ' ' )
.append( msg.split( "\r?\n" )[0] );
Copy link
Contributor

@Tibor17 Tibor17 Feb 4, 2022

Choose a reason for hiding this comment

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

I know that the .split( "\r?\n" )[0] was my request but this part of code will break the nackwards compatibility. Pls use only .append( msg );, thx
And I have an additional question. Is the code between the lines 90 and 103 the same in the class SmartStackTraceParser - see the lines 133 - 146? Is it possible to share this code between classes?
Has the method toMinimalThrowableMiniMessage() the same code in both classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @Tibor17

I know that the .split( "\r?\n" )[0] was my request but this part of code will break the nackwards compatibility.

In what way would this break backward compatibility?

Surefire has always kept each failure on one line on the output. This behaviour is still true.

If your concern is that important info is contained on lines 2..n of the error/failure message, we could replace line separators by space and keep the complete message.

Suggested change
.append( msg.split( "\r?\n" )[0] );
.append( msg.replaceAll( "\r?\n", " " ) );

Copy link
Contributor

Choose a reason for hiding this comment

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

The mesage was always printed completely.
If you compare witht he old code, you will see only msg.
The point of the issue is to remove the function which takes first 77 chars, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The point of the issue is to remove the function which takes first 77 chars, right?

Correct.
Or to put in more general terms: output enough of the error message that it is always clear and eases troubleshooting.
Your suggestion to print only the first line is a good compromise I think.
To have multi-line messages in exception is unusual (if not an anti-pattern). I cannot think of many examples other than jdbc drivers maybe that tend to be quite verbose in the exception message.

Copy link
Contributor

Choose a reason for hiding this comment

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

The Spark/Groovy is having such assertion statements which have excellent benefit with multiline message for user.
I would not like to break the users since they rely on complete message.
Thx for your work and all your efforts!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fine with me. I'll close this pull request then?

if ( isNotEmpty( msg ) )
{
result.append( ' ' )
.append( msg.split( "\r?\n" )[0] );
Copy link
Contributor

Choose a reason for hiding this comment

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

The same here.

@spannm spannm closed this Jul 9, 2022
@spannm spannm deleted the sman-81-SUREFIRE-1992-3 branch July 9, 2022 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants