Skip to content
This repository was archived by the owner on Aug 30, 2023. It is now read-only.

Commit 9723c50

Browse files
bruno-garciamarandaneto
authored andcommitted
feat: Take proxy in SentryOptions (#65)
1 parent 86057d8 commit 9723c50

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

sentry-core/src/main/java/io/sentry/core/AsyncConnectionFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public static AsyncConnection create(SentryOptions options) {
1414

1515
// TODO: Take configuration values from SentryOptions
1616
HttpTransport transport =
17-
new HttpTransport(options, null, setCredentials, 5000, 5000, false, sentryUrl);
17+
new HttpTransport(options, setCredentials, 5000, 5000, false, sentryUrl);
1818

1919
// TODO this should be made configurable at least for the Android case where we can
2020
// just not attempt to send if the device is offline.

sentry-core/src/main/java/io/sentry/core/SentryOptions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.sentry.core;
22

33
import io.sentry.core.util.NonNull;
4+
import java.net.Proxy;
45
import java.util.ArrayList;
56
import java.util.List;
67

@@ -21,6 +22,7 @@ public class SentryOptions {
2122
private BeforeSendCallback beforeSend;
2223
private BeforeBreadcrumbCallback beforeBreadcrumb;
2324
private String cacheDirPath;
25+
private Proxy proxy;
2426

2527
public void addEventProcessor(EventProcessor eventProcessor) {
2628
eventProcessors.add(eventProcessor);
@@ -129,6 +131,14 @@ public void setCacheDirPath(String cacheDirPath) {
129131
this.cacheDirPath = cacheDirPath;
130132
}
131133

134+
public Proxy getProxy() {
135+
return proxy;
136+
}
137+
138+
public void setProxy(Proxy proxy) {
139+
this.proxy = proxy;
140+
}
141+
132142
public interface BeforeSendCallback {
133143
SentryEvent execute(SentryEvent event);
134144
}

sentry-core/src/main/java/io/sentry/core/transport/HttpTransport.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class HttpTransport implements ITransport {
3737
* obtained from the options.
3838
*
3939
* @param options sentry options to read the config from
40-
* @param proxy the proxy to use, if any
4140
* @param connectionConfigurator this consumer is given a chance to set up the request before it
4241
* is sent
4342
* @param connectionTimeoutMills connection timeout in milliseconds
@@ -46,13 +45,12 @@ public class HttpTransport implements ITransport {
4645
*/
4746
public HttpTransport(
4847
SentryOptions options,
49-
@Nullable Proxy proxy,
5048
IConnectionConfigurator connectionConfigurator,
5149
int connectionTimeoutMills,
5250
int readTimeoutMills,
5351
boolean bypassSecurity,
5452
URL sentryUrl) {
55-
this.proxy = proxy;
53+
this.proxy = options.getProxy();
5654
this.connectionConfigurator = connectionConfigurator;
5755
this.serializer = options.getSerializer();
5856
this.connectionTimeout = connectionTimeoutMills;

sentry-core/src/test/java/io/sentry/core/transport/HttpTransportTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ class HttpTransportTest {
3838
fun getSUT(): HttpTransport {
3939
val options = SentryOptions()
4040
options.serializer = serializer
41+
options.proxy = proxy
4142

42-
return object : HttpTransport(options, proxy, requestUpdater, connectionTimeout, readTimeout, bypassSecurity, dsn) {
43+
return object : HttpTransport(options, requestUpdater, connectionTimeout, readTimeout, bypassSecurity, dsn) {
4344
override fun open(url: URL?, proxy: Proxy?): HttpURLConnection {
4445
return connection
4546
}

0 commit comments

Comments
 (0)