Skip to content

[CQ] stop storing property service instance #8118

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

Merged
merged 1 commit into from
Apr 24, 2025

Conversation

pq
Copy link
Contributor

@pq pq commented Apr 24, 2025

A bit pedantic but generally good practice and easy to fix. (There's also no real reason to store the instance.)

image

Inspection motivation:

Such services' assignments contribute to global state and make it impossible to tear down an application and set up another one in tests, therefore, repeated tests in the same process may fail. The only exception is an explicit constructor call to store dummy/default instances.
The recommended way to avoid storing services is to retrieve a service locally. Alternatively, one can wrap it in java.util.function.Supplier (Java, Kotlin) or convert the property to a function (Kotlin).


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

@pq pq requested a review from jwren April 24, 2025 23:31
@jwren jwren added this to the M85.3 milestone Apr 24, 2025
@pq pq merged commit b3a9274 into flutter:master Apr 24, 2025
7 checks passed
@pq pq deleted the cq_FlutterSurveyService_serviceAssignment branch April 24, 2025 23:56
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