mirror of https://github.com/apache/nifi.git
NIFI-9898: Used CloseableHttpClient and replaced deprecated class/method usages in ProxyAwareTransportFactory in GCP module
Also bumped GCP dependencies Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #5950.
This commit is contained in:
parent
c75fa3857e
commit
157a5d342a
|
@ -17,15 +17,15 @@
|
|||
package org.apache.nifi.processors.gcp;
|
||||
|
||||
import com.google.api.client.http.HttpTransport;
|
||||
import com.google.api.client.http.apache.ApacheHttpTransport;
|
||||
import com.google.api.client.http.apache.v2.ApacheHttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.auth.http.HttpTransportFactory;
|
||||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.conn.params.ConnRouteParams;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.nifi.proxy.ProxyConfiguration;
|
||||
import org.apache.nifi.proxy.ProxySpec;
|
||||
|
||||
|
@ -57,20 +57,20 @@ public class ProxyAwareTransportFactory implements HttpTransportFactory {
|
|||
final int port = proxyConfig.getProxyServerPort();
|
||||
final HttpHost proxyHost = new HttpHost(host, port);
|
||||
|
||||
final DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
ConnRouteParams.setDefaultProxy(httpClient.getParams(), proxyHost);
|
||||
final HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()
|
||||
.setProxy(proxyHost);
|
||||
|
||||
if (proxyConfig.hasCredential()) {
|
||||
final AuthScope proxyAuthScope = new AuthScope(host, port);
|
||||
final UsernamePasswordCredentials proxyCredential
|
||||
= new UsernamePasswordCredentials(proxyConfig.getProxyUserName(), proxyConfig.getProxyUserPassword());
|
||||
final UsernamePasswordCredentials proxyCredential = new UsernamePasswordCredentials(proxyConfig.getProxyUserName(), proxyConfig.getProxyUserPassword());
|
||||
final BasicCredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||
credentialsProvider.setCredentials(proxyAuthScope, proxyCredential);
|
||||
httpClient.setCredentialsProvider(credentialsProvider);
|
||||
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
|
||||
}
|
||||
|
||||
return new ApacheHttpTransport(httpClient);
|
||||
final CloseableHttpClient httpClient = httpClientBuilder.build();
|
||||
|
||||
return new ApacheHttpTransport(httpClient);
|
||||
}
|
||||
|
||||
return new NetHttpTransport.Builder().setProxy(proxy).build();
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<google.cloud.sdk.version>0.162.0</google.cloud.sdk.version>
|
||||
<google.cloud.sdk.version>0.172.0</google.cloud.sdk.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
Loading…
Reference in New Issue