Skip to content

Commit 0bff5c1

Browse files
authored
Ensure no Java 8 method reference sugar is used for Android (#2857)
1 parent f60279b commit 0bff5c1

File tree

6 files changed

+25
-8
lines changed

6 files changed

+25
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Deduplicate events happening in multiple threads simultaneously (e.g. `OutOfMemoryError`) ([#2845](https://github.com/getsentry/sentry-java/pull/2845))
88
- This will improve Crash-Free Session Rate as we no longer will send multiple Session updates with `Crashed` status, but only the one that is relevant
9+
- Ensure no Java 8 method reference sugar is used for Android ([#2857](https://github.com/getsentry/sentry-java/pull/2857))
910

1011
## 6.26.0
1112

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ final class ANRWatchDog extends Thread {
4444
@NotNull ANRListener listener,
4545
@NotNull ILogger logger,
4646
final @NotNull Context context) {
47+
// avoid method refs on Android due to some issues with older AGP setups
48+
// noinspection Convert2MethodRef
4749
this(
4850
() -> SystemClock.uptimeMillis(),
4951
timeoutIntervalMillis,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ public void close() throws IOException {
130130
} else {
131131
// some versions of the androidx lifecycle-process require this to be executed on the main
132132
// thread.
133+
// avoid method refs on Android due to some issues with older AGP setups
134+
// noinspection Convert2MethodRef
133135
handler.post(() -> removeObserver());
134136
}
135137
}

sentry/src/main/java/io/sentry/HostnameCache.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ private HostnameCache() {
5959
}
6060

6161
HostnameCache(long cacheDuration) {
62+
// avoid method refs on Android due to some issues with older AGP setups
63+
// noinspection Convert2MethodRef
6264
this(cacheDuration, () -> InetAddress.getLocalHost());
6365
}
6466

sentry/src/main/java/io/sentry/JsonObjectDeserializer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,17 @@ private void parse(@NotNull JsonObjectReader reader) throws IOException {
103103
pushCurrentToken(new TokenName(reader.nextName()));
104104
break;
105105
case STRING:
106-
done = handlePrimitive(reader::nextString);
106+
// avoid method refs on Android due to some issues with older AGP setups
107+
// noinspection Convert2MethodRef
108+
done = handlePrimitive(() -> reader.nextString());
107109
break;
108110
case NUMBER:
109111
done = handlePrimitive(() -> nextNumber(reader));
110112
break;
111113
case BOOLEAN:
112-
done = handlePrimitive(reader::nextBoolean);
114+
// avoid method refs on Android due to some issues with older AGP setups
115+
// noinspection Convert2MethodRef
116+
done = handlePrimitive(() -> reader.nextBoolean());
113117
break;
114118
case NULL:
115119
reader.nextNull();

sentry/src/main/java/io/sentry/SentryEnvelopeItem.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ public final class SentryEnvelopeItem {
8787
new SentryEnvelopeItemHeader(
8888
SentryItemType.Session, () -> cachedItem.getBytes().length, "application/json", null);
8989

90-
// Don't use method reference. This can cause issues on Android
90+
// avoid method refs on Android due to some issues with older AGP setups
91+
// noinspection Convert2MethodRef
9192
return new SentryEnvelopeItem(itemHeader, () -> cachedItem.getBytes());
9293
}
9394

@@ -124,7 +125,8 @@ public final class SentryEnvelopeItem {
124125
"application/json",
125126
null);
126127

127-
// Don't use method reference. This can cause issues on Android
128+
// avoid method refs on Android due to some issues with older AGP setups
129+
// noinspection Convert2MethodRef
128130
return new SentryEnvelopeItem(itemHeader, () -> cachedItem.getBytes());
129131
}
130132

@@ -161,7 +163,8 @@ public static SentryEnvelopeItem fromUserFeedback(
161163
"application/json",
162164
null);
163165

164-
// Don't use method reference. This can cause issues on Android
166+
// avoid method refs on Android due to some issues with older AGP setups
167+
// noinspection Convert2MethodRef
165168
return new SentryEnvelopeItem(itemHeader, () -> cachedItem.getBytes());
166169
}
167170

@@ -206,7 +209,8 @@ public static SentryEnvelopeItem fromAttachment(
206209
attachment.getFilename(),
207210
attachment.getAttachmentType());
208211

209-
// Don't use method reference. This can cause issues on Android
212+
// avoid method refs on Android due to some issues with older AGP setups
213+
// noinspection Convert2MethodRef
210214
return new SentryEnvelopeItem(itemHeader, () -> cachedItem.getBytes());
211215
}
212216

@@ -271,7 +275,8 @@ private static void ensureAttachmentSizeLimit(
271275
"application-json",
272276
traceFile.getName());
273277

274-
// Don't use method reference. This can cause issues on Android
278+
// avoid method refs on Android due to some issues with older AGP setups
279+
// noinspection Convert2MethodRef
275280
return new SentryEnvelopeItem(itemHeader, () -> cachedItem.getBytes());
276281
}
277282

@@ -340,7 +345,8 @@ private static byte[] readBytesFromFile(String pathname, long maxFileLength)
340345
"application/json",
341346
null);
342347

343-
// Don't use method reference. This can cause issues on Android
348+
// avoid method refs on Android due to some issues with older AGP setups
349+
// noinspection Convert2MethodRef
344350
return new SentryEnvelopeItem(itemHeader, () -> cachedItem.getBytes());
345351
}
346352

0 commit comments

Comments
 (0)