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

Single.repeat: use TerminateRepeatException as a terminal marker #3045

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

idelpivnitskiy
Copy link
Member

Motivation:

Currently, RepeatWhenSingle uses its own static END_REPEAT_EXCEPTION object as an end marker. That static exception does not discard suppressed exceptions. If under any circumcises it unintentionally leaks, it may cause a memory leak if some path adds suppressed exceptions to it. Also, it's inconsistent with RepeatStrategies.

Modifications:

  • Use RepeatStrategies.TerminateRepeatException instead that discards suppressed exceptions and doesn't write stacktrace.
  • Cache failed Completable with TerminateRepeatException instance instead of allocating a new one on every repeat check.

Result:

  1. Avoids static exception instance that may attach suppressed exceptions.
  2. Consistency between all repeat operators and strategies.

Motivation:

Currently, `RepeatWhenSingle` uses its own static `END_REPEAT_EXCEPTION`
object as an end marker. That static exception does not discard
suppressed exceptions. If under any circumcises it unintentionally
leaks, it may cause a memory leak if some path adds suppressed
exceptions to it. Also, it's inconsistent with `RepeatStrategies`.

Modifications:

- Use `RepeatStrategies.TerminateRepeatException` instead that discards
suppressed exceptions and doesn't write stacktrace.
- Cache failed `Completable` with `TerminateRepeatException` instance
instead of allocating a new one on every repeat check.

Result:

1. Avoids static exception instance that may attach suppressed
exceptions.
2. Consistency between all repeat operators and strategies.
@idelpivnitskiy idelpivnitskiy self-assigned this Aug 20, 2024
@idelpivnitskiy idelpivnitskiy merged commit edb05b5 into apple:main Aug 21, 2024
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the repeat branch August 21, 2024 15:49
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.

2 participants