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

Don't re-use *Exceptions when stored in static fields if enableSuppre… #958

Merged
merged 6 commits into from
Mar 10, 2020

Conversation

normanmaurer
Copy link
Member

…ssion can not be set to false

Motivation:

Have a static instance of an Exception which does not set enableSuppression to false when constructed is considered to be dangerous as it may escape to the user where an user may add more exceptions to it. The problem with this is that the internal storage will grow and grow over time and never be GC'ed. This can lead to OOME situations.

Modifications:

Create new *Exceptions when needed and remove usage of static stored *Exceptions if needed.

Result:

No more risk of OOME due user calling addSuppressed on exceptions that are propagated through the code

@NiteshKant
Copy link
Collaborator

@normanmaurer Same test:

io.servicetalk.transport.netty.internal.DefaultNettyConnectionTest.testNoErrorEnrichmentWithoutCloseHandlerOnError

failed for both PRBs, looks like something isn't happy 😢

@normanmaurer
Copy link
Member Author

@NiteshKant will check

@normanmaurer normanmaurer force-pushed the no_static_exception branch from 05fce96 to 49ef379 Compare March 6, 2020 08:04
@NiteshKant
Copy link
Collaborator

@normanmaurer JDK 11 build failure is due to a known flaky test:

#758

Can you add this failure details to the issue?

Copy link
Collaborator

@NiteshKant NiteshKant left a comment

Choose a reason for hiding this comment

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

Just doc update suggestions, else LGTM

normanmaurer and others added 6 commits March 9, 2020 12:06
…ssion can not be set to false

Motivation:

Have a static instance of an Exception which does not set enableSuppression to false when constructed is considered to be dangerous as it may escape to the user where an user may add more exceptions to it. The problem with this is that the internal storage will grow and grow over time and never be GC'ed. This can lead to OOME situations.

Modifications:

Create new *Exceptions when needed and remove usage of static stored *Exceptions if needed.

Result:

No more risk of OOME due user calling `addSuppressed` on exceptions that are propagated through the code
…rent/api/RepeatStrategies.java


Update comment

Co-Authored-By: Nitesh Kant <nitesh_kant@apple.com>
@normanmaurer normanmaurer force-pushed the no_static_exception branch from 2e11bb8 to 72191ba Compare March 9, 2020 11:06
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

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

🚀

@normanmaurer normanmaurer merged commit cc466dc into master Mar 10, 2020
@normanmaurer
Copy link
Member Author

Merged... thanks :)

@normanmaurer normanmaurer deleted the no_static_exception branch March 10, 2020 08:31
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