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

Prevent Test From Hanging With AnimatedLabel Thread #597

Conversation

Kapral67
Copy link

The fix for #595 as proposed by #596 looks good to me.

The test proposed in #596 would hang with the AnimatedLabel Thread.

This PR proposes a modification so that now matter if Issue595 test fails or succeeds:

  • it never hangs

  • indicates test failure via:

    • output to stderr

    • returned exit code

}
++exit_code;
final StringWriter stringWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stringWriter));
Copy link
Author

Choose a reason for hiding this comment

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

redundant, can just call e.printStackTrace()

Copy link
Contributor

Choose a reason for hiding this comment

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

Things like e.printStackTrace() are often barfed at by code quality tools, like e.g. SonarQube.
The preferred way would be resorting to some logging-framework, so that it can be disabled
for production use - and not dump an exception-stackdump into user's face.

I'm aware that using a logging framework is not a simple decision, but the original code is already closer to a real solution than "simplifying" it back to e.printStackTrace().

My opinion: just leave that bit as it is. Simplifying it as suggested would be a step in the wrong direction.

Copy link
Author

@Kapral67 Kapral67 Feb 29, 2024

Choose a reason for hiding this comment

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

Unless we resort to a logging framework

StringWriter s = new StringWriter();
e.printStackTrace(new PrintWriter(s));
System.err.print(s);

Is equivalent to e.printStackTrace() (at least in vanilla JDK implementations)

This code is also part of the test suite, so users will not see the trace produced by potential exceptions here

Copy link
Owner

Choose a reason for hiding this comment

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

This was copy+pasted from the bug report, I think :)

Copy link
Owner

Choose a reason for hiding this comment

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

Nevermind, wrong PR

@avl42
Copy link
Contributor

avl42 commented Feb 29, 2024 via email

@Kapral67 Kapral67 force-pushed the bugfix/Issue595-avoid-weakref branch from 63cb030 to b10e866 Compare February 29, 2024 21:29
@mabe02
Copy link
Owner

mabe02 commented Mar 2, 2024

Given that this is a test for reproducing a reported bug, I don't really mind that the code style and some constructs are misaligned with the rest of the library. The code won't be included in the library anyway. I've intentionally avoided introducing or using any logging framework in the library itself since there never really was any strong need for logging anywhere. Rather, errors are thrown out and users should catch exceptions and log them as per their application.

@mabe02 mabe02 merged commit 155c2ec into mabe02:bugfix/Issue595-avoid-weakref Mar 2, 2024
@Kapral67 Kapral67 deleted the bugfix/Issue595-avoid-weakref branch March 2, 2024 02:51
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.

3 participants