Skip to content

Avoid throwing in ForcedSender.sendBlocking #4293

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 2 commits into from
Nov 15, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.google.android.datatransport.runtime;

import android.annotation.SuppressLint;
import androidx.annotation.Discouraged;
import androidx.annotation.WorkerThread;
import com.google.android.datatransport.Priority;
Expand All @@ -26,16 +25,11 @@
public final class ForcedSender {
@WorkerThread
public static void sendBlocking(Transport<?> transport, Priority priority) {
@SuppressLint("DiscouragedApi")
TransportContext context = getTransportContextOrThrow(transport).withPriority(priority);
TransportRuntime.getInstance().getUploader().logAndUpdateState(context, 1);
}

private static TransportContext getTransportContextOrThrow(Transport<?> transport) {
if (transport instanceof TransportImpl) {
return ((TransportImpl<?>) transport).getTransportContext();
TransportContext context =
((TransportImpl<?>) transport).getTransportContext().withPriority(priority);
TransportRuntime.getInstance().getUploader().logAndUpdateState(context, 1);
}
throw new IllegalArgumentException("Expected instance of TransportImpl.");
Copy link
Member

Choose a reason for hiding this comment

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

Let's add a warning log statement here, there's logging util available in this sdk under
com.google.android.datatransport.runtime.logging.Logging

}

private ForcedSender() {}
Expand Down