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

Rework static exceptions in ContentProducer #8135

Closed

Conversation

lorban
Copy link
Contributor

@lorban lorban commented Jun 7, 2022

As this is a potential memory leak if Throwable.addSuppressed() is ever called on the static exception, or on the exception contained in the static ErrorContent.

sbordet
sbordet previously approved these changes Jun 7, 2022
@lorban lorban force-pushed the jetty-10.0.x-ContentProducer-static-exception branch 2 times, most recently from 6baf0c1 to 5edfef1 Compare June 7, 2022 16:04
gregw
gregw previously approved these changes Jun 7, 2022
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

I'm trying hard to think of why this is going to bite us.... but this all looks very straight forward and how it probably should have been done in the first place.

Jetty 10.0.10/11.0.10 - 🧊 FROZEN 🥶 automation moved this from In progress to Review in progress Jun 8, 2022
@joakime joakime requested a review from sbordet June 8, 2022 21:50
@lorban lorban added Bug For general bugs on Jetty side Sponsored This issue affects a user with a commercial support agreement labels Jun 8, 2022
@lorban lorban self-assigned this Jun 8, 2022
sbordet
sbordet previously approved these changes Jun 8, 2022
Jetty 10.0.10/11.0.10 - 🧊 FROZEN 🥶 automation moved this from Review in progress to Reviewer approved Jun 8, 2022
Jetty 10.0.10/11.0.10 - 🧊 FROZEN 🥶 automation moved this from Reviewer approved to Review in progress Jun 9, 2022
@lorban lorban requested a review from sbordet June 9, 2022 10:34
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

Do we need to make so many changes now that you've discovered the constructor that allows us to avoid suppressed exceptions for static sentinel Throwables.

Perhaps it is better for use to create a utility StaticThrowable class that has no stack trace and doesn't keep suppressed exceptions. We can then use that as the base for our existing static exceptions rather than replacing them.


public UnconsumedContentException()
{
super("Unconsumed content", null, false, LOG.isDebugEnabled());
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this constructor is key!
Seeing that this constructor allows us to disable suppressed exceptions, there is no real reason for us to avoid static Throwables used as sentinels.

I'm not keen on using the LOG to hide stack traces. I think if it is worth creating an exception of the fly, it is worth generating a stack trace. I think we should avoid stack traces only for static sentinel Throwables.

@lachlan-roberts can you review your recent change in light of this constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. While this code might be worth some refactorings, that's clearly outside the scope of the original issue which is just to avoid leaking stack traces in static exceptions.

I'm going to revert all these changes, introduce a new StaticException and keep the changes to a minimum.

…les.

Signed-off-by: Ludovic Orban <lorban@bitronix.be>
@lorban lorban force-pushed the jetty-10.0.x-ContentProducer-static-exception branch from ac2c862 to e175625 Compare June 10, 2022 07:54
Jetty 10.0.10/11.0.10 - 🧊 FROZEN 🥶 automation moved this from Review in progress to Reviewer approved Jun 10, 2022
@lorban lorban changed the title Remove static exception in ContentProducer Rework static exceptions in ContentProducer Jun 10, 2022
@lorban
Copy link
Contributor Author

lorban commented Jun 10, 2022

Changes combined with #8155

@lorban lorban closed this Jun 10, 2022
Jetty 10.0.10/11.0.10 - 🧊 FROZEN 🥶 automation moved this from Reviewer approved to Done Jun 10, 2022
@lorban lorban deleted the jetty-10.0.x-ContentProducer-static-exception branch June 10, 2022 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side Sponsored This issue affects a user with a commercial support agreement
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants