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:
Peter Turcsanyi 2022-04-08 23:40:20 +02:00 committed by Pierre Villard
parent c75fa3857e
commit 157a5d342a
No known key found for this signature in database
GPG Key ID: F92A93B30C07C6D5
2 changed files with 10 additions and 10 deletions

View File

@ -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();

View File

@ -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>