Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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 @@ -459,6 +459,7 @@ void applyScope(final @NotNull IScope scope, final @NotNull ITransaction transac
}

@VisibleForTesting
@SuppressWarnings("ReferenceEquality")
void clearScope(final @NotNull IScope scope, final @NotNull ITransaction transaction) {
scope.withTransaction(
scopeTransaction -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ private void stop(final boolean restartProfiler) {
}
}

@Override
public void reevaluateSampling() {
shouldSample = true;
}
Expand Down Expand Up @@ -373,6 +374,7 @@ public void close(final boolean isTerminating) {
return ProfileRecordingState.UNKNOWN;
}

@SuppressWarnings("FutureReturnValueIgnored")
private void sendChunks(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
try {
options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public void log(
final @NotNull String message,
final @Nullable Object... args) {
if (args == null || args.length == 0) {
Log.println(toLogcatLevel(level), tag, message);
Log.println(Log.ASSERT, tag, message);
} else {
Log.println(toLogcatLevel(level), tag, String.format(message, args));
Log.println(Log.ASSERT, tag, String.format(message, args));
}
}

Expand Down Expand Up @@ -59,8 +59,4 @@ public void log(
public boolean isEnabled(@Nullable SentryLevel level) {
return true;
}

private int toLogcatLevel(final @NotNull SentryLevel sentryLevel) {
return Log.ASSERT;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void onForeground() {
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void onBackground() {
if (!hasAcceptedItem) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public void onForeground() {
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void onBackground() {
if (!hasAcceptedItem) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ static void installDefaultIntegrations(
options.setReplayController(replay);
}
if (isDistributionAvailable) {
final DistributionIntegration distribution = new DistributionIntegration((context));
final DistributionIntegration distribution = new DistributionIntegration(context);
options.setDistributionController(distribution);
options.addIntegration(distribution);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ public AnrIntegration(final @NotNull Context context) {

private @Nullable SentryOptions options;

protected static final @NotNull AutoClosableReentrantLock watchDogLock =
new AutoClosableReentrantLock();
static final @NotNull AutoClosableReentrantLock watchDogLock = new AutoClosableReentrantLock();

@Override
public final void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
this.options = Objects.requireNonNull(options, "SentryOptions is required");
register(scopes, (SentryAndroidOptions) options);
}

@SuppressWarnings("FutureReturnValueIgnored")
private void register(
final @NotNull IScopes scopes, final @NotNull SentryAndroidOptions options) {
options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
Expand All @@ -64,6 +65,7 @@ public AnrV2Integration(final @NotNull Context context) {

@SuppressLint("NewApi") // we do the check in the AnrIntegrationFactory
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {
this.options =
Objects.requireNonNull(
Expand Down Expand Up @@ -210,7 +212,8 @@ public void markReported(final long timestamp) {
}

try (final BufferedReader reader =
new BufferedReader(new InputStreamReader(new ByteArrayInputStream(dump)))) {
new BufferedReader(
new InputStreamReader(new ByteArrayInputStream(dump), StandardCharsets.UTF_8))) {
final Lines lines = Lines.readLines(reader);

final ThreadDumpParser threadDumpParser = new ThreadDumpParser(options, isBackground);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private void captureConfigurationChangedBreadcrumb(
}
}

@SuppressWarnings("FutureReturnValueIgnored")
private void executeInBackground(final @NotNull Runnable runnable) {
if (options != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ private boolean sampleReplay(
return true;
}

@SuppressWarnings("JavaUtilDate")
private void setReplayId(
final @NotNull SentryEvent event, final @NotNull OptionsSource optionsSource) {
@Nullable String persistedReplayId = readFromDisk(options, REPLAY_FILENAME, String.class);
Expand Down Expand Up @@ -933,6 +934,7 @@ private void setAnrExceptions(
sentryExceptionFactory.getSentryExceptionsFromThread(mainThread, mechanism, anr));
}

@SuppressWarnings("JavaUtilDate")
private void applyAnrProfile(
@NotNull SentryEvent event,
@NotNull Backfillable hint,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ static void setAppPackageInfo(
}
}
} catch (Throwable e) {
// Split APK info is optional, the app context is still complete without it.
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ private CurrentActivityHolder() {}
return null;
}

@SuppressWarnings("ReferenceEquality")
public void setActivity(final @NotNull Activity activity) {
if (currentActivity != null && currentActivity.get() == activity) {
return;
Expand All @@ -38,6 +39,7 @@ public void clearActivity() {
currentActivity = null;
}

@SuppressWarnings("ReferenceEquality")
public void clearActivity(final @NotNull Activity activity) {
if (currentActivity != null && currentActivity.get() != activity) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static final class CachedEnvelopeHint
private final long flushTimeoutMillis;
private final @NotNull ILogger logger;

public CachedEnvelopeHint(final long flushTimeoutMillis, final @NotNull ILogger logger) {
CachedEnvelopeHint(final long flushTimeoutMillis, final @NotNull ILogger logger) {
reset();
this.flushTimeoutMillis = flushTimeoutMillis;
this.logger = Objects.requireNonNull(logger, "ILogger is required.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public abstract class EnvelopeFileObserverIntegration implements Integration, Cl
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public final void register(final @NotNull IScopes scopes, final @NotNull SentryOptions options) {
Objects.requireNonNull(scopes, "Scopes are required");
Objects.requireNonNull(options, "SentryOptions is required");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public synchronized void enableOnShake() {
final @Nullable SentryAndroidOptions options = this.options;
if (enabled || options == null) {
Expand Down Expand Up @@ -154,6 +155,7 @@ void onDialogGone(final @NotNull Dialog dialog) {
}
}

@SuppressWarnings("ReferenceEquality")
private boolean removeDialog(final @NotNull Dialog dialog) {
boolean removed = false;
for (final @NotNull VisibleDialog visibleDialog : visibleDialogs) {
Expand All @@ -169,6 +171,7 @@ private boolean removeDialog(final @NotNull Dialog dialog) {
return removed;
}

@SuppressWarnings("ReferenceEquality")
private boolean hasDialogOn(final @NotNull Activity activity) {
for (final @NotNull VisibleDialog visibleDialog : visibleDialogs) {
if (visibleDialog.dialogRef.get() != null && visibleDialog.activityRef.get() == activity) {
Expand Down Expand Up @@ -226,6 +229,7 @@ public void onActivityResumed(final @NotNull Activity activity) {
}

@Override
@SuppressWarnings("ReferenceEquality")
public void onActivityPaused(final @NotNull Activity activity) {
// Only stop if this is the activity we're tracking. When transitioning between
// activities, B.onResume may fire before A.onPause — stopping unconditionally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ final class Installation {

private static final Charset UTF_8 = Charset.forName("UTF-8");

protected static final @NotNull AutoClosableReentrantLock staticLock =
new AutoClosableReentrantLock();
static final @NotNull AutoClosableReentrantLock staticLock = new AutoClosableReentrantLock();

private Installation() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ private static void addTimeSpanToSerializedSpans(TimeSpan span, List<Map<String,
spans.add(spanMap);
}

@SuppressWarnings("FutureReturnValueIgnored")
private static void deleteCurrentSessionFile(
final @NotNull SentryOptions options, boolean isSync) {
if (!isSync) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private void startSession() {
* <p>TODO [MAJOR]: let a session remember the tick it started on, so this can use a {@link
* Deadline} too. That tick must not be serialized.
*/
@SuppressWarnings("JavaUtilDate")
private boolean isSessionOnScopeStale() {
final long nowMillis = TimeUnit.NANOSECONDS.toMillis(epochClock.now().epochNanos());
// No session, or one that never recorded a start, leaves nothing to resume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ public LoadClass() {
* @param logger an instance of ILogger
* @return a Class<?> if it's available, or null
*/
@Override
public @Nullable Class<?> loadClass(final @NotNull String clazz, final @Nullable ILogger logger) {
return delegate.loadClass(clazz, logger);
}

@Override
public boolean isClassAvailable(final @NotNull String clazz, final @Nullable ILogger logger) {
return delegate.isClassAvailable(clazz, logger);
}

@Override
public boolean isClassAvailable(
final @NotNull String clazz, final @Nullable SentryOptions options) {
return delegate.isClassAvailable(clazz, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public MemoryLimiterIntegration(
}

@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {
androidOptions =
Objects.requireNonNull(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public boolean deleteNativeEventFile(final @NotNull NativeEventData nativeEventD
* the fields we need and exits early once found. Uses a bounded stream to track position within
* the payload and skip any unread bytes on close, avoiding allocation of the full payload.
*/
@SuppressWarnings("JavaUtilDate")
private @Nullable NativeEnvelopeMetadata extractMetadataFromEventPayload(
final @NotNull InputStream stream, final int payloadLength, final @NotNull File file) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public final class NetworkBreadcrumbsIntegration implements Integration, Closeab
private final @NotNull Context context;
private final @NotNull BuildInfoProvider buildInfoProvider;
private final @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock();
private @Nullable SentryOptions options;

@TestOnly @Nullable volatile NetworkBreadcrumbsNetworkCallback networkCallback;

Expand All @@ -53,8 +52,6 @@ public void register(final @NotNull IScopes scopes, final @NotNull SentryOptions
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
"SentryAndroidOptions is required");

this.options = options;

options
.getLogger()
.log(
Expand Down Expand Up @@ -237,7 +234,7 @@ boolean isSimilar(final @NotNull NetworkBreadcrumbConnectionDetail other) {
// This means that if the new connection detail come less than 5 seconds after the previous
// one, we'll report the signal and bandwidth as similar, regardless of their real value.
boolean isTimestampSimilar =
DateUtils.nanosToMillis(Math.abs(timestampNanos - other.timestampNanos)) < 5000;
DateUtils.nanosToMillis((double) Math.abs(timestampNanos - other.timestampNanos)) < 5000;
boolean isSignalSimilar = isTimestampSimilar || signalDiff <= 5;
boolean isDownBandwidthSimilar =
isTimestampSimilar || downBandwidthDiff <= Math.max(1000, Math.abs(downBandwidth) * 0.1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,14 @@ private void onChunkCollected(
}
}

@Override
public void reevaluateSampling() {
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
shouldSample = true;
}
}

@SuppressWarnings("FutureReturnValueIgnored")
private void sendChunk(
final @NotNull ProfileChunk.Builder builder,
final @NotNull IScopes scopes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ boolean start(final @NotNull ChunkRecord chunkRecord, final long durationMs) {
* error) once the OS delivers the result. The listener may be called synchronously if the result
* has already arrived, or asynchronously on an OS-managed thread otherwise.
*/
@SuppressWarnings("FutureReturnValueIgnored")
public void endAndCollect(final @NotNull Consumer<@Nullable File> listener) {
if (!started) {
logger.log(SentryLevel.WARNING, "PerfettoProfiler was never started");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,10 @@ final class PerformanceAndroidEventProcessor implements SentryEventProcessor {
private static final String APP_METRICS_ORIGIN = "auto.ui";

private static final String APP_METRICS_CONTENT_PROVIDER_OP = "contentprovider.load";
private static final String APP_METRICS_ACTIVITIES_OP = "activity.load";
private static final String APP_METRICS_APPLICATION_OP = "application.load";
private static final String APP_METRICS_PROCESS_INIT_OP = "process.load";
private static final long MAX_PROCESS_INIT_APP_START_DIFF_MS = 10000;

private boolean sentStartMeasurement = false;

private final @NotNull SentryAndroidOptions options;
private final @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ public final class SentryAndroid {
private static final String FRAGMENT_CLASS_NAME =
"androidx.fragment.app.FragmentManager$FragmentLifecycleCallbacks";

protected static final @NotNull AutoClosableReentrantLock staticLock =
new AutoClosableReentrantLock();
static final @NotNull AutoClosableReentrantLock staticLock = new AutoClosableReentrantLock();

private SentryAndroid() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -115,7 +116,8 @@ private void launchAppStartProfiler(final @NotNull AppStartMetrics appStartMetri
}

try (final @NotNull Reader reader =
new BufferedReader(new InputStreamReader(new FileInputStream(configFile)))) {
new BufferedReader(
new InputStreamReader(new FileInputStream(configFile), StandardCharsets.UTF_8))) {
final @Nullable SentryAppStartProfilingOptions profilingOptions =
deserializeProfilingConfig(reader);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,20 +179,23 @@ private class ShakeLifecycleCallbacks implements Application.ActivityLifecycleCa
}

@Override
@SuppressWarnings("ReferenceEquality")
public void onActivityResumed(final @NotNull Activity activity) {
if (activity == activityRef.get() && shakeDetector != null) {
shakeDetector.start(activity, shakeListener(activityRef));
}
}

@Override
@SuppressWarnings("ReferenceEquality")
public void onActivityPaused(final @NotNull Activity activity) {
if (activity == activityRef.get() && shakeDetector != null) {
shakeDetector.stop();
}
}

@Override
@SuppressWarnings("ReferenceEquality")
public void onActivityDestroyed(final @NotNull Activity activity) {
if (activity == activityRef.get()) {
stopShakeDetection();
Expand Down
Loading
Loading