Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Improvements

- Improve SDK init performance by replacing `java.net.URI` with custom string parsing for DSN ([#5448](https://github.com/getsentry/sentry-java/pull/5448))
- Remove unnecessary boxing to improve performance ([#5520](https://github.com/getsentry/sentry-java/pull/5520))

### Fixes

Expand Down
3 changes: 1 addition & 2 deletions sentry/src/main/java/io/sentry/CircularFifoQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ public boolean add(final @NotNull E element) {
if (index < 0 || index >= sz) {
throw new NoSuchElementException(
String.format(
"The specified index (%1$d) is outside the available range [0, %2$d)",
Integer.valueOf(index), Integer.valueOf(sz)));
"The specified index (%1$d) is outside the available range [0, %2$d)", index, sz));
}

final int idx = (start + index) % maxElements;
Expand Down
4 changes: 2 additions & 2 deletions sentry/src/main/java/io/sentry/DateUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static double nanosToMillis(final double nanos) {
* @return date rounded down to milliseconds
*/
public static Date nanosToDate(final long nanos) {
final Double millis = nanosToMillis(Double.valueOf(nanos));
final Double millis = nanosToMillis((double) nanos);
Comment thread
runningcode marked this conversation as resolved.
return getDateTime(millis.longValue());
}

Expand All @@ -137,7 +137,7 @@ public static Date nanosToDate(final long nanos) {
* @return seconds
*/
public static double nanosToSeconds(final long nanos) {
return Double.valueOf(nanos) / (1000.0 * 1000.0 * 1000.0);
return (double) nanos / (1000.0 * 1000.0 * 1000.0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/ScopesStorageFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class ScopesStorageFactory {
try {
final @Nullable Object otelScopesStorage =
otelScopesStorageClazz.getDeclaredConstructor().newInstance();
if (otelScopesStorage != null && otelScopesStorage instanceof IScopesStorage) {
if (otelScopesStorage instanceof IScopesStorage) {
return (IScopesStorage) otelScopesStorage;
}
} catch (InstantiationException e) {
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/SentryDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public final boolean isAfter(final @NotNull SentryDate otherDate) {

@Override
public int compareTo(@NotNull SentryDate otherDate) {
return Long.valueOf(nanoTimestamp()).compareTo(otherDate.nanoTimestamp());
return Long.compare(nanoTimestamp(), otherDate.nanoTimestamp());
}
}
6 changes: 3 additions & 3 deletions sentry/src/main/java/io/sentry/SentryNanotimeDate.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public long nanoTimestamp() {

@Override
public long laterDateNanosTimestampByDiff(final @Nullable SentryDate otherDate) {
if (otherDate != null && otherDate instanceof SentryNanotimeDate) {
if (otherDate instanceof SentryNanotimeDate) {
final @NotNull SentryNanotimeDate otherNanoDate = (SentryNanotimeDate) otherDate;
if (compareTo(otherDate) < 0) {
return nanotimeDiff(this, otherNanoDate);
Expand All @@ -66,9 +66,9 @@ public int compareTo(@NotNull SentryDate otherDate) {
final long thisDateMillis = date.getTime();
final long otherDateMillis = otherNanoDate.date.getTime();
if (thisDateMillis == otherDateMillis) {
return Long.valueOf(nanos).compareTo(otherNanoDate.nanos);
return Long.compare(nanos, otherNanoDate.nanos);
} else {
return Long.valueOf(thisDateMillis).compareTo(otherDateMillis);
return Long.compare(thisDateMillis, otherDateMillis);
}
} else {
return super.compareTo(otherDate);
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/SpanFactoryFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class SpanFactoryFactory {
try {
final @Nullable Object otelSpanFactory =
otelSpanFactoryClazz.getDeclaredConstructor().newInstance();
if (otelSpanFactory != null && otelSpanFactory instanceof ISpanFactory) {
if (otelSpanFactory instanceof ISpanFactory) {
return (ISpanFactory) otelSpanFactory;
}
} catch (InstantiationException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ public EventProcessorAndOrder(

@Override
public int compareTo(@NotNull EventProcessorAndOrder o) {
return order.compareTo(o.order);
return Long.compare(order, o.order);
}
}
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/protocol/Contexts.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void putAll(final @Nullable Contexts contexts) {

@Override
public boolean equals(final @Nullable Object obj) {
if (obj != null && obj instanceof Contexts) {
if (obj instanceof Contexts) {
final @NotNull Contexts otherContexts = (Contexts) obj;
return internalStorage.equals(otherContexts.internalStorage);
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/util/LifecycleHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public final class LifecycleHelper {

public static void close(final @Nullable Object tokenObject) {
if (tokenObject != null && tokenObject instanceof ISentryLifecycleToken) {
if (tokenObject instanceof ISentryLifecycleToken) {
final @NotNull ISentryLifecycleToken token = (ISentryLifecycleToken) tokenObject;
token.close();
}
Expand Down
2 changes: 1 addition & 1 deletion sentry/src/main/java/io/sentry/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class Platform {
try {
final @Nullable String javaStringVersion = System.getProperty("java.specification.version");
if (javaStringVersion != null) {
final @NotNull double javaVersion = Double.valueOf(javaStringVersion);
final @NotNull double javaVersion = Double.parseDouble(javaStringVersion);
isJavaNinePlus = javaVersion >= 9.0;
} else {
isJavaNinePlus = false;
Expand Down
10 changes: 4 additions & 6 deletions sentry/src/main/java/io/sentry/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.sentry.SentryLevel;
import java.math.BigInteger;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.CharacterIterator;
Expand All @@ -18,7 +19,7 @@
@ApiStatus.Internal
public final class StringUtils {

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

public static final String PROPER_NIL_UUID = "00000000-0000-0000-0000-000000000000";
private static final String CORRUPTED_NIL_UUID = "0000-0000";
Expand Down Expand Up @@ -142,11 +143,8 @@ private StringUtils() {}
// Convert byte array into signum representation
final BigInteger no = new BigInteger(1, messageDigest);

// Convert message digest into hex value
final StringBuilder stringBuilder = new StringBuilder(no.toString(16));

// return the HashText
return stringBuilder.toString();
// Convert message digest into hex value and return the HashText
return no.toString(16);
}

// For specifying wrong message digest algorithms
Expand Down
Loading