Skip to content

Commit 9933e47

Browse files
committed
redo a seemingly missed spotlessApply
1 parent ba0c7db commit 9933e47

File tree

5 files changed

+111
-118
lines changed

5 files changed

+111
-118
lines changed

sentry-android-core/build.gradle.kts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,8 @@ dependencies {
113113
}
114114

115115
protobuf {
116-
protoc {
117-
artifact = libs.protoc.get().toString()
118-
}
116+
protoc { artifact = libs.protoc.get().toString() }
119117
generateProtoTasks {
120-
all().forEach { task ->
121-
task.builtins {
122-
create("java") {
123-
option("lite")
124-
}
125-
}
126-
}
118+
all().forEach { task -> task.builtins { create("java") { option("lite") } } }
127119
}
128120
}

sentry-android-core/src/main/java/io/sentry/android/core/SentryAndroidOptions.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public final class SentryAndroidOptions extends SentryOptions {
8282
* <li>The transaction status will be {@link SpanStatus#OK} if none is set.
8383
* </ul>
8484
*
85-
* The transaction is automatically bound to the {@link IScope}, but only if there's no
85+
* <p>The transaction is automatically bound to the {@link IScope}, but only if there's no
8686
* transaction already bound to the Scope.
8787
*/
8888
private boolean enableAutoActivityLifecycleTracing = true;
@@ -313,7 +313,8 @@ public void setTombstonesEnabled(boolean tombstonesEnabled) {
313313
}
314314

315315
/**
316-
* Checks if Tombstone reporting (ApplicationExitInfo.REASON_CRASH_NATIVE) is enabled or disabled Default is disabled
316+
* Checks if Tombstone reporting (ApplicationExitInfo.REASON_CRASH_NATIVE) is enabled or disabled
317+
* Default is disabled
317318
*
318319
* @return true if enabled or false otherwise
319320
*/

sentry-android-core/src/main/java/io/sentry/android/core/TombstoneIntegration.java

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
import android.app.ApplicationExitInfo;
77
import android.content.Context;
88
import android.os.Build;
9-
109
import androidx.annotation.RequiresApi;
11-
1210
import io.sentry.DateUtils;
1311
import io.sentry.IScopes;
1412
import io.sentry.Integration;
@@ -21,13 +19,11 @@
2119
import io.sentry.transport.CurrentDateProvider;
2220
import io.sentry.transport.ICurrentDateProvider;
2321
import io.sentry.util.Objects;
24-
2522
import java.io.Closeable;
2623
import java.io.IOException;
2724
import java.util.ArrayList;
2825
import java.util.List;
2926
import java.util.concurrent.TimeUnit;
30-
3127
import org.jetbrains.annotations.NotNull;
3228
import org.jetbrains.annotations.Nullable;
3329

@@ -45,36 +41,37 @@ public TombstoneIntegration(final @NotNull Context context) {
4541
}
4642

4743
TombstoneIntegration(
48-
final @NotNull Context context, final @NotNull ICurrentDateProvider dateProvider) {
44+
final @NotNull Context context, final @NotNull ICurrentDateProvider dateProvider) {
4945
this.context = ContextUtils.getApplicationContext(context);
5046
this.dateProvider = dateProvider;
5147
}
5248

5349
@Override
5450
public void register(@NotNull IScopes scopes, @NotNull SentryOptions options) {
5551
this.options =
56-
Objects.requireNonNull(
57-
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
58-
"SentryAndroidOptions is required");
52+
Objects.requireNonNull(
53+
(options instanceof SentryAndroidOptions) ? (SentryAndroidOptions) options : null,
54+
"SentryAndroidOptions is required");
5955

6056
this.options
61-
.getLogger()
62-
.log(SentryLevel.DEBUG, "TombstoneIntegration enabled: %s", this.options.isTombstonesEnabled());
57+
.getLogger()
58+
.log(
59+
SentryLevel.DEBUG,
60+
"TombstoneIntegration enabled: %s",
61+
this.options.isTombstonesEnabled());
6362

6463
if (this.options.isTombstonesEnabled()) {
6564
if (this.options.getCacheDirPath() == null) {
6665
this.options
67-
.getLogger()
68-
.log(SentryLevel.INFO, "Cache dir is not set, unable to process Tombstones");
66+
.getLogger()
67+
.log(SentryLevel.INFO, "Cache dir is not set, unable to process Tombstones");
6968
return;
7069
}
7170

7271
try {
7372
options
74-
.getExecutorService()
75-
.submit(
76-
new TombstoneProcessor(
77-
context, scopes, this.options, dateProvider));
73+
.getExecutorService()
74+
.submit(new TombstoneProcessor(context, scopes, this.options, dateProvider));
7875
} catch (Throwable e) {
7976
options.getLogger().log(SentryLevel.DEBUG, "Failed to start TombstoneProcessor.", e);
8077
}
@@ -92,19 +89,16 @@ public void close() throws IOException {
9289

9390
public static class TombstoneProcessor implements Runnable {
9491

95-
@NotNull
96-
private final Context context;
97-
@NotNull
98-
private final IScopes scopes;
99-
@NotNull
100-
private final SentryAndroidOptions options;
92+
@NotNull private final Context context;
93+
@NotNull private final IScopes scopes;
94+
@NotNull private final SentryAndroidOptions options;
10195
private final long threshold;
10296

10397
public TombstoneProcessor(
104-
@NotNull Context context,
105-
@NotNull IScopes scopes,
106-
@NotNull SentryAndroidOptions options,
107-
@NotNull ICurrentDateProvider dateProvider) {
98+
@NotNull Context context,
99+
@NotNull IScopes scopes,
100+
@NotNull SentryAndroidOptions options,
101+
@NotNull ICurrentDateProvider dateProvider) {
108102
this.context = context;
109103
this.scopes = scopes;
110104
this.options = options;
@@ -116,7 +110,7 @@ public TombstoneProcessor(
116110
@RequiresApi(api = Build.VERSION_CODES.R)
117111
public void run() {
118112
final ActivityManager activityManager =
119-
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
113+
(ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
120114

121115
final List<ApplicationExitInfo> applicationExitInfoList;
122116
applicationExitInfoList = activityManager.getHistoricalProcessExitReasons(null, 0, 0);
@@ -129,12 +123,12 @@ public void run() {
129123
final IEnvelopeCache cache = options.getEnvelopeDiskCache();
130124
if (cache instanceof EnvelopeCache) {
131125
if (options.isEnableAutoSessionTracking()
132-
&& !((EnvelopeCache) cache).waitPreviousSessionFlush()) {
126+
&& !((EnvelopeCache) cache).waitPreviousSessionFlush()) {
133127
options
134-
.getLogger()
135-
.log(
136-
SentryLevel.WARNING,
137-
"Timed out waiting to flush previous session to its own file.");
128+
.getLogger()
129+
.log(
130+
SentryLevel.WARNING,
131+
"Timed out waiting to flush previous session to its own file.");
138132

139133
// if we timed out waiting here, we can already flush the latch, because the timeout is
140134
// big
@@ -155,25 +149,26 @@ public void run() {
155149
if (applicationExitInfo.getReason() == ApplicationExitInfo.REASON_CRASH_NATIVE) {
156150
latestTombstone = applicationExitInfo;
157151
// remove it, so it's not reported twice
158-
// TODO: if we fail after this, we effectively lost the ApplicationExitInfo (maybe only remove after we reported it)
152+
// TODO: if we fail after this, we effectively lost the ApplicationExitInfo (maybe only
153+
// remove after we reported it)
159154
exitInfos.remove(applicationExitInfo);
160155
break;
161156
}
162157
}
163158

164159
if (latestTombstone == null) {
165160
options
166-
.getLogger()
167-
.log(
168-
SentryLevel.DEBUG,
169-
"No Tombstones have been found in the historical exit reasons list.");
161+
.getLogger()
162+
.log(
163+
SentryLevel.DEBUG,
164+
"No Tombstones have been found in the historical exit reasons list.");
170165
return;
171166
}
172167

173168
if (latestTombstone.getTimestamp() < threshold) {
174169
options
175-
.getLogger()
176-
.log(SentryLevel.DEBUG, "Latest Tombstones happened too long ago, returning early.");
170+
.getLogger()
171+
.log(SentryLevel.DEBUG, "Latest Tombstones happened too long ago, returning early.");
177172
return;
178173
}
179174

sentry-android-core/src/main/java/io/sentry/android/core/internal/tombstone/TombstoneParser.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
package io.sentry.android.core.internal.tombstone;
22

33
import androidx.annotation.NonNull;
4-
5-
import java.io.IOException;
6-
import java.io.InputStream;
7-
import java.util.ArrayList;
8-
import java.util.HashMap;
9-
import java.util.List;
10-
import java.util.Locale;
11-
import java.util.Map;
12-
134
import io.sentry.SentryEvent;
145
import io.sentry.SentryLevel;
156
import io.sentry.protocol.DebugImage;
@@ -20,6 +11,13 @@
2011
import io.sentry.protocol.SentryStackFrame;
2112
import io.sentry.protocol.SentryStackTrace;
2213
import io.sentry.protocol.SentryThread;
14+
import java.io.IOException;
15+
import java.io.InputStream;
16+
import java.util.ArrayList;
17+
import java.util.HashMap;
18+
import java.util.List;
19+
import java.util.Locale;
20+
import java.util.Map;
2321

2422
public class TombstoneParser {
2523

@@ -44,7 +42,7 @@ public SentryEvent parse() throws IOException {
4442
SentryEvent event = new SentryEvent();
4543
event.setLevel(SentryLevel.FATAL);
4644

47-
// we must use the "native" platform because otherwise the stack-trace would not be correctly parsed
45+
// must use the "native" platform because otherwise the stack-trace wouldn't be correctly parsed
4846
event.setPlatform("native");
4947

5048
event.setMessage(constructMessage(tombstone));
@@ -57,10 +55,11 @@ public SentryEvent parse() throws IOException {
5755
}
5856

5957
@NonNull
60-
private List<SentryThread> createThreads(TombstoneProtos.Tombstone tombstone, SentryException exc) {
58+
private List<SentryThread> createThreads(
59+
TombstoneProtos.Tombstone tombstone, SentryException exc) {
6160
List<SentryThread> threads = new ArrayList<>();
6261
for (Map.Entry<Integer, TombstoneProtos.Thread> threadEntry :
63-
tombstone.getThreadsMap().entrySet()) {
62+
tombstone.getThreadsMap().entrySet()) {
6463

6564
SentryThread thread = new SentryThread();
6665
thread.setId(Long.valueOf(threadEntry.getKey()));
@@ -70,7 +69,8 @@ private List<SentryThread> createThreads(TombstoneProtos.Tombstone tombstone, Se
7069
thread.setStacktrace(stacktrace);
7170
if (tombstone.getTid() == threadEntry.getValue().getId()) {
7271
thread.setCrashed(true);
73-
// even though we refer to the thread_id from the exception, the backend currently requires a stack-trace in exception
72+
// even though we refer to the thread_id from the exception,
73+
// the backend currently requires a stack-trace in exception
7474
exc.setStacktrace(stacktrace);
7575
}
7676
threads.add(thread);
@@ -80,11 +80,11 @@ private List<SentryThread> createThreads(TombstoneProtos.Tombstone tombstone, Se
8080
}
8181

8282
@NonNull
83-
private static SentryStackTrace createStackTrace(Map.Entry<Integer, TombstoneProtos.Thread> threadEntry) {
83+
private static SentryStackTrace createStackTrace(
84+
Map.Entry<Integer, TombstoneProtos.Thread> threadEntry) {
8485
List<SentryStackFrame> frames = new ArrayList<>();
8586

86-
for (TombstoneProtos.BacktraceFrame frame :
87-
threadEntry.getValue().getCurrentBacktraceList()) {
87+
for (TombstoneProtos.BacktraceFrame frame : threadEntry.getValue().getCurrentBacktraceList()) {
8888
SentryStackFrame stackFrame = new SentryStackFrame();
8989
stackFrame.setPackage(frame.getFileName());
9090
stackFrame.setFunction(frame.getFunctionName());
@@ -96,7 +96,7 @@ private static SentryStackTrace createStackTrace(Map.Entry<Integer, TombstonePro
9696
stacktrace.setFrames(frames);
9797

9898
Map<String, Object> unknown = new HashMap<>();
99-
// `libunwindstack` used for tombstone generation already applies instruction address adjustment:
99+
// `libunwindstack` used for tombstones already applies instruction address adjustment:
100100
// https://android.googlesource.com/platform/system/unwinding/+/refs/heads/main/libunwindstack/Regs.cpp#175
101101
// prevent "processing" from doing it again.
102102
unknown.put("instruction_addr_adjustment", "none");
@@ -136,8 +136,8 @@ private static Mechanism createMechanismFromSignalInfo(TombstoneProtos.Signal si
136136
meta.put("code_name", signalInfo.getCodeName());
137137

138138
Mechanism mechanism = new Mechanism();
139-
// this follows the current processing triggers strictly, changing any of these alters grouping and name (long-term we might want to
140-
// have a tombstone mechanism)
139+
// this follows the current processing triggers strictly, changing any of these
140+
// alters grouping and name (long-term we might want to have a tombstone mechanism)
141141
mechanism.setType("signalhandler");
142142
mechanism.setHandled(false);
143143
mechanism.setSynthetic(true);
@@ -153,14 +153,15 @@ private Message constructMessage(TombstoneProtos.Tombstone tombstone) {
153153

154154
// reproduce the message `debuggerd` would use to dump the stack trace in logcat
155155
message.setFormatted(
156-
String.format(Locale.getDefault(),
157-
"Fatal signal %s (%d), %s (%d), pid = %d (%s)",
158-
signalInfo.getName(),
159-
signalInfo.getNumber(),
160-
signalInfo.getCodeName(),
161-
signalInfo.getCode(),
162-
tombstone.getPid(),
163-
String.join(" ", tombstone.getCommandLineList())));
156+
String.format(
157+
Locale.getDefault(),
158+
"Fatal signal %s (%d), %s (%d), pid = %d (%s)",
159+
signalInfo.getName(),
160+
signalInfo.getNumber(),
161+
signalInfo.getCodeName(),
162+
signalInfo.getCode(),
163+
tombstone.getPid(),
164+
String.join(" ", tombstone.getCommandLineList())));
164165

165166
return message;
166167
}
@@ -171,8 +172,8 @@ private DebugMeta createDebugMeta(TombstoneProtos.Tombstone tombstone) {
171172
for (TombstoneProtos.MemoryMapping module : tombstone.getMemoryMappingsList()) {
172173
// exclude anonymous and non-executable maps
173174
if (module.getBuildId().isEmpty()
174-
|| module.getMappingName().isEmpty()
175-
|| !module.getExecute()) {
175+
|| module.getMappingName().isEmpty()
176+
|| !module.getExecute()) {
176177
continue;
177178
}
178179
DebugImage image = new DebugImage();

0 commit comments

Comments
 (0)