Skip to content

Commit

Permalink
Merge branch 'main' into feat/apollo-v3
Browse files Browse the repository at this point in the history
  • Loading branch information
adinauer committed Jul 19, 2022
2 parents 7d95756 + 504fce8 commit 65fdef8
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 184 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Unreleased

### Features

- Switch upstream dependencies to `compileOnly` in integrations ([#2175](https://github.com/getsentry/sentry-java/pull/2175))

### Fixes

- Lazily retrieve HostnameCache in MainEventProcessor ([#2170](https://github.com/getsentry/sentry-java/pull/2170))

## 6.2.1

### Fixes
Expand Down Expand Up @@ -50,6 +60,7 @@
### Fixes

- Fix proguard rules to work R8 [issue](https://issuetracker.google.com/issues/235733922) around on AGP 7.3.0-betaX and 7.4.0-alphaX ([#2094](https://github.com/getsentry/sentry-java/pull/2094))
- Fix GraalVM Native Image compatibility ([#2172](https://github.com/getsentry/sentry-java/pull/2172))

## 6.0.0

Expand Down
3 changes: 2 additions & 1 deletion sentry-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ android {

// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks.
checkReleaseBuilds = false
disable += "LogNotTimber"
}

// needed because of Kotlin 1.4.x
Expand Down Expand Up @@ -107,4 +106,6 @@ dependencies {
testImplementation(projects.sentryTestSupport)
testImplementation(projects.sentryAndroidFragment)
testImplementation(projects.sentryAndroidTimber)
testRuntimeOnly(Config.Libs.timber)
testRuntimeOnly(Config.Libs.fragment)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public final class SentryAndroid {
static final String SENTRY_TIMBER_INTEGRATION_CLASS_NAME =
"io.sentry.android.timber.SentryTimberIntegration";

private static final String TIMBER_CLASS_NAME = "timber.log.Timber";
private static final String FRAGMENT_CLASS_NAME =
"androidx.fragment.app.FragmentManager$FragmentLifecycleCallbacks";

private SentryAndroid() {}

/**
Expand Down Expand Up @@ -84,10 +88,17 @@ public static synchronized void init(
OptionsContainer.create(SentryAndroidOptions.class),
options -> {
final LoadClass classLoader = new LoadClass();
final boolean isTimberUpstreamAvailable =
classLoader.isClassAvailable(TIMBER_CLASS_NAME, options);
final boolean isFragmentUpstreamAvailable =
classLoader.isClassAvailable(FRAGMENT_CLASS_NAME, options);
final boolean isFragmentAvailable =
classLoader.isClassAvailable(SENTRY_FRAGMENT_INTEGRATION_CLASS_NAME, options);
(isFragmentUpstreamAvailable
&& classLoader.isClassAvailable(
SENTRY_FRAGMENT_INTEGRATION_CLASS_NAME, options));
final boolean isTimberAvailable =
classLoader.isClassAvailable(SENTRY_TIMBER_INTEGRATION_CLASS_NAME, options);
(isTimberUpstreamAvailable
&& classLoader.isClassAvailable(SENTRY_TIMBER_INTEGRATION_CLASS_NAME, options));

AndroidOptionsInitializer.init(
options, context, logger, isFragmentAvailable, isTimberAvailable);
Expand Down
3 changes: 2 additions & 1 deletion sentry-android-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ kotlin {
dependencies {
api(projects.sentry)

implementation(Config.Libs.fragment)
compileOnly(Config.Libs.fragment)

// tests
testImplementation(Config.Libs.fragment)
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
testImplementation(Config.TestLibs.mockitoInline)
Expand Down
6 changes: 4 additions & 2 deletions sentry-android-okhttp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ kotlin {
dependencies {
api(projects.sentry)

implementation(Config.Libs.okhttpBom)
implementation(Config.Libs.okhttp)
compileOnly(Config.Libs.okhttpBom)
compileOnly(Config.Libs.okhttp)

implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))

// tests
testImplementation(Config.Libs.okhttpBom)
testImplementation(Config.Libs.okhttp)
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.androidxJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
Expand Down
3 changes: 2 additions & 1 deletion sentry-android-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,12 @@ kotlin {
dependencies {
api(projects.sentry)

api(Config.Libs.timber)
compileOnly(Config.Libs.timber)

implementation(kotlin(Config.kotlinStdLib, KotlinCompilerVersion.VERSION))

// tests
testImplementation(Config.Libs.timber)
testImplementation(Config.TestLibs.kotlinTestJunit)
testImplementation(Config.TestLibs.androidxJunit)
testImplementation(Config.TestLibs.mockitoKotlin)
Expand Down
1 change: 1 addition & 0 deletions sentry-samples/sentry-samples-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ dependencies {
implementation(projects.sentryAndroidTimber)
implementation(projects.sentryCompose)
implementation(Config.Libs.fragment)
implementation(Config.Libs.timber)

// how to exclude androidx if release health feature is disabled
// implementation(projects.sentryAndroid) {
Expand Down
29 changes: 17 additions & 12 deletions sentry/src/main/java/io/sentry/MainEventProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ public final class MainEventProcessor implements EventProcessor, Closeable {
private final @NotNull SentryOptions options;
private final @NotNull SentryThreadFactory sentryThreadFactory;
private final @NotNull SentryExceptionFactory sentryExceptionFactory;
private final @Nullable HostnameCache hostnameCache;
private volatile @Nullable HostnameCache hostnameCache = null;

public MainEventProcessor(final @NotNull SentryOptions options) {
this(options, options.isAttachServerName() ? HostnameCache.getInstance() : null);
}

MainEventProcessor(
final @NotNull SentryOptions options, final @Nullable HostnameCache hostnameCache) {
this.options = Objects.requireNonNull(options, "The SentryOptions is required.");
this.hostnameCache = hostnameCache;

final SentryStackTraceFactory sentryStackTraceFactory =
new SentryStackTraceFactory(
Expand All @@ -53,14 +47,12 @@ public MainEventProcessor(final @NotNull SentryOptions options) {
MainEventProcessor(
final @NotNull SentryOptions options,
final @NotNull SentryThreadFactory sentryThreadFactory,
final @NotNull SentryExceptionFactory sentryExceptionFactory,
final @NotNull HostnameCache hostnameCache) {
final @NotNull SentryExceptionFactory sentryExceptionFactory) {
this.options = Objects.requireNonNull(options, "The SentryOptions is required.");
this.sentryThreadFactory =
Objects.requireNonNull(sentryThreadFactory, "The SentryThreadFactory is required.");
this.sentryExceptionFactory =
Objects.requireNonNull(sentryExceptionFactory, "The SentryExceptionFactory is required.");
this.hostnameCache = Objects.requireNonNull(hostnameCache, "The HostnameCache is required");
}

@Override
Expand Down Expand Up @@ -164,8 +156,21 @@ private void setServerName(final @NotNull SentryBaseEvent event) {
event.setServerName(options.getServerName());
}

if (options.isAttachServerName() && hostnameCache != null && event.getServerName() == null) {
event.setServerName(hostnameCache.getHostname());
if (options.isAttachServerName() && event.getServerName() == null) {
ensureHostnameCache();
if (hostnameCache != null) {
event.setServerName(hostnameCache.getHostname());
}
}
}

private void ensureHostnameCache() {
if (hostnameCache == null) {
synchronized (this) {
if (hostnameCache == null) {
hostnameCache = HostnameCache.getInstance();
}
}
}
}

Expand Down

This file was deleted.

0 comments on commit 65fdef8

Please sign in to comment.