Skip to content

Commit 8135c95

Browse files
authored
Merge branch 'main' into fix/anr-tombstone-main-thread-detection
2 parents 6d1e647 + 65f7853 commit 8135c95

6 files changed

Lines changed: 138 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Fix main thread identification for tombstone (native crash) events ([#5742](https://github.com/getsentry/sentry-java/pull/5742))
8+
9+
## 8.48.0
10+
511
### Features
612

713
- Add `Sentry.extendAppStart()`, `Sentry.finishExtendedAppStart()`, and `Sentry.getExtendedAppStartSpan()` to extend the app start measurement past the first frame for extra launch-time work on Android ([#5604](https://github.com/getsentry/sentry-java/pull/5604))
@@ -22,7 +28,7 @@
2228

2329
### Fixes
2430

25-
- Fix main thread identification for tombstone (native crash) events ([#5742](https://github.com/getsentry/sentry-java/pull/5742))
31+
- Fix `NoSuchMethodError` when using `Math.floorDiv`/`Math.floorMod` on Android < 24 ([#5743](https://github.com/getsentry/sentry-java/pull/5743))
2632
- Fix main thread identification parsing for ApplicationExitInfo ANRs ([#5733](https://github.com/getsentry/sentry-java/pull/5733))
2733
- Do not send threads without stacktraces for ApplicationExitInfo ANRs ([#5733](https://github.com/getsentry/sentry-java/pull/5733))
2834
- Record byte-level client reports when event processors discard logs or trace metrics ([#5718](https://github.com/getsentry/sentry-java/pull/5718))

THIRD_PARTY_NOTICES.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,34 @@ limitations under the License.
3434

3535
---
3636

37+
## Google Guava — LongMath (Apache 2.0)
38+
39+
**Source:** https://github.com/google/guava/blob/v33.0.0/guava/src/com/google/common/math/LongMath.java<br>
40+
**License:** Apache License 2.0<br>
41+
**Copyright:** Copyright (C) 2011 The Guava Authors
42+
43+
### Scope
44+
45+
The Sentry Java SDK includes adapted floor division logic from Guava's `LongMath` class to support older Android API levels. The code resides in `io.sentry.vendor.SentryMath`.
46+
47+
```
48+
Copyright (C) 2011 The Guava Authors
49+
50+
Licensed under the Apache License, Version 2.0 (the "License");
51+
you may not use this file except in compliance with the License.
52+
You may obtain a copy of the License at
53+
54+
http://www.apache.org/licenses/LICENSE-2.0
55+
56+
Unless required by applicable law or agreed to in writing, software
57+
distributed under the License is distributed on an "AS IS" BASIS,
58+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59+
See the License for the specific language governing permissions and
60+
limitations under the License.
61+
```
62+
63+
---
64+
3765
## FasterXML Jackson — ISO8601Utils (Apache 2.0)
3866

3967
**Source:** https://github.com/FasterXML/jackson-databind<br>

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ android.useAndroidX=true
1313
android.experimental.lint.version=8.13.1
1414

1515
# Release information
16-
versionName=8.47.0
16+
versionName=8.48.0
1717

1818
# Override the SDK name on native crashes on Android
1919
sentryAndroidSdkName=sentry.native.android

sentry/src/main/java/io/sentry/vendor/SentryIso8601Utils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ public static long parseTimestamp(final @NotNull String timestamp) {
142142
return formatTimestampWithCalendar(millis);
143143
}
144144

145-
final long epochDay = Math.floorDiv(millis, MILLIS_PER_DAY);
146-
int millisOfDay = (int) Math.floorMod(millis, MILLIS_PER_DAY);
145+
final long epochDay = SentryMath.floorDiv(millis, MILLIS_PER_DAY);
146+
int millisOfDay = (int) SentryMath.floorMod(millis, MILLIS_PER_DAY);
147147

148148
final int[] yearMonthDay = epochDayToYearMonthDay(epochDay);
149149
final int hour = millisOfDay / (int) MILLIS_PER_HOUR;
@@ -281,7 +281,7 @@ private static long epochMillis(
281281

282282
private static long daysFromYearMonthDay(int year, final int month, final int day) {
283283
year -= month <= 2 ? 1 : 0;
284-
final long era = Math.floorDiv(year, 400);
284+
final long era = SentryMath.floorDiv(year, 400L);
285285
final int yearOfEra = (int) (year - era * 400);
286286
final int dayOfYear = (153 * (month + (month > 2 ? -3 : 9)) + 2) / 5 + day - 1;
287287
final int dayOfEra = yearOfEra * 365 + yearOfEra / 4 - yearOfEra / 100 + dayOfYear;
@@ -290,7 +290,7 @@ private static long daysFromYearMonthDay(int year, final int month, final int da
290290

291291
private static int[] epochDayToYearMonthDay(long epochDay) {
292292
epochDay += DAYS_0000_TO_1970;
293-
final long era = Math.floorDiv(epochDay, 146097);
293+
final long era = SentryMath.floorDiv(epochDay, 146097L);
294294
final int dayOfEra = (int) (epochDay - era * 146097);
295295
final int yearOfEra = (dayOfEra - dayOfEra / 1460 + dayOfEra / 36524 - dayOfEra / 146096) / 365;
296296
final int year = (int) (yearOfEra + era * 400);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Adapted from https://github.com/google/guava/blob/v33.0.0/guava/src/com/google/common/math/LongMath.java
3+
*
4+
* Copyright (C) 2011 The Guava Authors
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package io.sentry.vendor;
20+
21+
final class SentryMath {
22+
23+
private SentryMath() {}
24+
25+
static long floorDiv(final long x, final long y) {
26+
final long quotient = x / y;
27+
final long remainder = x - y * quotient;
28+
29+
if (remainder == 0) {
30+
return quotient;
31+
}
32+
33+
final int signum = 1 | (int) ((x ^ y) >> (Long.SIZE - 1));
34+
return signum < 0 ? quotient + signum : quotient;
35+
}
36+
37+
static long floorMod(final long x, final long y) {
38+
return x - floorDiv(x, y) * y;
39+
}
40+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package io.sentry.vendor
2+
3+
import com.google.common.truth.Truth.assertThat
4+
import kotlin.test.Test
5+
import kotlin.test.assertFailsWith
6+
7+
class SentryMathTest {
8+
@Test
9+
fun `floorDiv matches Java Math floorDiv`() {
10+
values.forEach { x ->
11+
divisors.forEach { y -> assertThat(SentryMath.floorDiv(x, y)).isEqualTo(Math.floorDiv(x, y)) }
12+
}
13+
}
14+
15+
@Test
16+
fun `floorMod matches Java Math floorMod`() {
17+
values.forEach { x ->
18+
divisors.forEach { y -> assertThat(SentryMath.floorMod(x, y)).isEqualTo(Math.floorMod(x, y)) }
19+
}
20+
}
21+
22+
@Test
23+
fun `floorDiv throws when dividing by zero`() {
24+
assertFailsWith<ArithmeticException> { SentryMath.floorDiv(1L, 0L) }
25+
}
26+
27+
@Test
28+
fun `floorMod throws when dividing by zero`() {
29+
assertFailsWith<ArithmeticException> { SentryMath.floorMod(1L, 0L) }
30+
}
31+
32+
private companion object {
33+
val values =
34+
listOf(
35+
Long.MIN_VALUE,
36+
-86_400_001L,
37+
-86_400_000L,
38+
-86_399_999L,
39+
-401L,
40+
-400L,
41+
-399L,
42+
-2L,
43+
-1L,
44+
0L,
45+
1L,
46+
2L,
47+
399L,
48+
400L,
49+
401L,
50+
86_399_999L,
51+
86_400_000L,
52+
86_400_001L,
53+
Long.MAX_VALUE,
54+
)
55+
56+
val divisors = listOf(Long.MIN_VALUE, -146_097L, -400L, -1L, 1L, 400L, 146_097L, Long.MAX_VALUE)
57+
}
58+
}

0 commit comments

Comments
 (0)