Skip to content

Create native proxy object to check provider on each call and mediate… #2532

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 13 commits into from
Apr 19, 2021

Conversation

davidmotson
Copy link
Collaborator

… between desired return value and default behavior)

… between desired return value and default behavior)
@google-cla google-cla bot added the cla: yes Override cla label Mar 22, 2021
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 22, 2021

Coverage Report

Affected SDKs

  • firebase-crashlytics

    SDK overall coverage did not change between base commit (2cc1cc4) and head commit (461cf834). However there are changes in individual files.

    Filename Base (2cc1cc4) Head (461cf834) Diff
    ProviderProxyNativeComponent.java ? 0.00% ?

Test Logs

Notes

HTML coverage reports can be produced locally with ./gradlew <product>:checkCoverage.
Report files are located at <product-build-dir>/reports/jacoco/.

Head commit (461cf834) is created by Prow via merging commits: 2cc1cc4 6aabb02.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Mar 22, 2021

Binary Size Report

Affected SDKs

  • firebase-crashlytics

    Type Base (2cc1cc4) Head (461cf834) Diff
    aar 317 kB 318 kB +599 B (+0.2%)
    apk (aggressive) 193 kB 193 kB +140 B (+0.1%)
    apk (release) 820 kB 821 kB +252 B (+0.0%)

Test Logs

Notes

Head commit (461cf834) is created by Prow via merging commits: 2cc1cc4 6aabb02.

Copy link
Member

@vkryachko vkryachko left a comment

Choose a reason for hiding this comment

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

Could we add a test for the proxy where when the provider is filled with a value we would see the expected call into the native component?

Comment on lines 34 to 36
if (provider.get() != null) {
return provider.get().hasCrashDataForSession(sessionId);
}
Copy link
Member

Choose a reason for hiding this comment

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

I recommend caching the result of get() instead of calling into it twice. This will make code more readable and more conventional as per Injecting Providers where in more traditional DI setups each call to get() could return a newly created instance if the component is not a singleton.

While all Firebase components are singletons, it could be beneficial to be consistent with common conventions for future readers of this code(including ourselves).

Suggested change
if (provider.get() != null) {
return provider.get().hasCrashDataForSession(sessionId);
}
Foo native = provider.get();
if (native != null) {
return native.hasCrashDataForSession(sessionId);
}

Here and throughout

@rlazo rlazo self-requested a review March 31, 2021 17:34
@davidmotson davidmotson requested a review from mrober March 31, 2021 18:39
Comment on lines +31 to +36
@Mock private CrashlyticsNativeComponent component;

@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: for this simple case you can just use the more concise:

Suggested change
@Mock private CrashlyticsNativeComponent component;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
private final CrashlyticsNativeComponent component = mock(CrashlyticsNativeComponent.class);

import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

public class ProviderProxyNative {
Copy link
Member

Choose a reason for hiding this comment

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

Please add a @RunWith(AndroidJUnit4.class)

@google-oss-bot
Copy link
Contributor

@davidmotson: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
device-check-changed 6aabb02 link /test device-check-changed

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@davidmotson davidmotson merged commit 593da89 into master Apr 19, 2021
@davidmotson davidmotson deleted the davidmotson.crashlytics_dynamic_module branch April 19, 2021 20:05
@firebase firebase locked and limited conversation to collaborators May 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Override cla size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants