Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1042432: Remove dependency on com.amazonaws.Protocol from HttpClientSettingsKey #1627

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7ca3a88
remove dependency on com.amazonaws.Protocol from HttpClientSettingsKey
jtjeferreira Feb 5, 2024
a6c26ce
keep backwards compatibility
jtjeferreira Feb 6, 2024
4db26fc
copyright header
jtjeferreira Feb 6, 2024
7cfb93b
fix copyright header
jtjeferreira Feb 8, 2024
f1b57bc
do not use getProxyHttpProtocol().toString(), use key.getProxyHttpPro…
jtjeferreira Feb 8, 2024
6cd37d8
move setProxyForS3 to S3HttpUtil
jtjeferreira Feb 8, 2024
28ea19e
deprecate SnowflakeMutableProxyRoutePlanner constructor
jtjeferreira Feb 8, 2024
7dca1fc
remove last usage of deprecated getProxyProtocol
jtjeferreira Feb 8, 2024
aaa5ca3
make a copy of com.amazonaws.http.apache.SdkProxyRoutePlanner but doe…
jtjeferreira Feb 8, 2024
6e10f57
Revert "make a copy of com.amazonaws.http.apache.SdkProxyRoutePlanner…
jtjeferreira Feb 9, 2024
4c735cc
fix HttpProtocol constructor argument
jtjeferreira Feb 9, 2024
fce6bc5
add Deprecated annotations
jtjeferreira Feb 9, 2024
92a67d6
remove duplicate code by calling the other constructor
jtjeferreira Feb 9, 2024
7e7efab
add copyright header
jtjeferreira Feb 9, 2024
1399811
Merge remote-tracking branch 'upstream/master' into remove_dependecy_…
jtjeferreira Feb 9, 2024
12a8f92
fmt
jtjeferreira Feb 9, 2024
c4e2225
change SnowflakeMutableProxyRoutePlanner constructor
jtjeferreira Feb 14, 2024
d326351
reformat
jtjeferreira Feb 14, 2024
f780f6d
Merge remote-tracking branch 'upstream/master' into remove_dependecy_…
jtjeferreira Feb 14, 2024
ad9f4c1
mark HttpClientSettingsKey.getProxyPassword as internal
jtjeferreira Feb 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package net.snowflake.client.core;

import com.amazonaws.Protocol;
import com.google.common.base.Strings;
import java.io.Serializable;

Expand Down Expand Up @@ -132,8 +131,16 @@ public String getNonProxyHosts() {
return this.nonProxyHosts;
}

public Protocol getProxyProtocol() {
return this.proxyProtocol.equalsIgnoreCase("https") ? Protocol.HTTPS : Protocol.HTTP;
/**
* @deprecated Use {@link #getProxyHttpProtocol()}
* @return ProxyProtocol
*/
@Deprecated
public com.amazonaws.Protocol getProxyProtocol() {
return this.proxyProtocol.equalsIgnoreCase("https") ? com.amazonaws.Protocol.HTTPS : com.amazonaws.Protocol.HTTP;
}
public HttpProtocol getProxyHttpProtocol() {
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved
return this.proxyProtocol.equalsIgnoreCase("https") ? HttpProtocol.HTTPS : HttpProtocol.HTTP;
}

public Boolean getGzipDisabled() {
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/net/snowflake/client/core/HttpProtocol.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved
*/

package net.snowflake.client.core;
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved

public enum HttpProtocol {

HTTP("http"),

HTTPS("https");

private final String protocol;
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved

HttpProtocol(String protocol) {
sfc-gh-dprzybysz marked this conversation as resolved.
Show resolved Hide resolved
this.protocol = protocol;
}

@Override
public String toString() {
return protocol;
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/snowflake/client/core/HttpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ public static CloseableHttpClient buildHttpClient(
HttpHost proxy =
(key != null && key.usesProxy())
? new HttpHost(
key.getProxyHost(), key.getProxyPort(), key.getProxyProtocol().toString())
key.getProxyHost(), key.getProxyPort(), key.getProxyHttpProtocol().toString())
: null;
// If defaultrequestconfig is not initialized or its proxy settings do not match current proxy
// settings, re-build it (current or old proxy settings could be null, so null check is
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/snowflake/client/core/SFSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public synchronized void open() throws SFException, SnowflakeSQLException {
httpClientSettingsKey.getProxyUser(),
!Strings.isNullOrEmpty(httpClientSettingsKey.getProxyPassword()) ? "***" : "(empty)",
httpClientSettingsKey.getNonProxyHosts(),
httpClientSettingsKey.getProxyProtocol());
httpClientSettingsKey.getProxyHttpProtocol());

// TODO: temporarily hardcode sessionParameter debug info. will be changed in the future
SFLoginInput loginInput = new SFLoginInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertTrue;

import com.amazonaws.Protocol;
import java.io.File;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.sql.*;
import java.util.Properties;
import net.snowflake.client.category.TestCategoryOthers;
import net.snowflake.client.core.HttpClientSettingsKey;
import net.snowflake.client.core.HttpProtocol;
import net.snowflake.client.core.HttpUtil;
import net.snowflake.client.core.SFSession;
import net.snowflake.common.core.SqlState;
Expand Down Expand Up @@ -596,7 +596,7 @@ public void testSetJVMProxyHttp() throws SQLException {
"jdbc:snowflake://s3testaccount.us-east-1.snowflakecomputing.com", props);
SFSession sfSession = con.unwrap(SnowflakeConnectionV1.class).getSfSession();
HttpClientSettingsKey clientSettingsKey = sfSession.getHttpClientKey();
assertEquals(Protocol.HTTP, clientSettingsKey.getProxyProtocol());
assertEquals(HttpProtocol.HTTP, clientSettingsKey.getProxyHttpProtocol());
con.close();
}

Expand All @@ -622,7 +622,7 @@ public void testSetJVMProxyHttps() throws SQLException {
"jdbc:snowflake://s3testaccount.us-east-1.snowflakecomputing.com", props);
SFSession sfSession = con.unwrap(SnowflakeConnectionV1.class).getSfSession();
HttpClientSettingsKey clientSettingsKey = sfSession.getHttpClientKey();
assertEquals(Protocol.HTTPS, clientSettingsKey.getProxyProtocol());
assertEquals(HttpProtocol.HTTPS, clientSettingsKey.getProxyHttpProtocol());
con.close();
}

Expand All @@ -647,7 +647,7 @@ public void testSetJVMProxyDefaultHttps() throws SQLException {
"jdbc:snowflake://s3testaccount.us-east-1.snowflakecomputing.com", props);
SFSession sfSession = con.unwrap(SnowflakeConnectionV1.class).getSfSession();
HttpClientSettingsKey clientSettingsKey = sfSession.getHttpClientKey();
assertEquals(Protocol.HTTPS, clientSettingsKey.getProxyProtocol());
assertEquals(HttpProtocol.HTTPS, clientSettingsKey.getProxyHttpProtocol());
con.close();
}

Expand Down
Loading