Skip to content

Commit

Permalink
reduce usage of Guava
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <[email protected]>
  • Loading branch information
senivam committed Apr 13, 2022
1 parent b0e7b1e commit ea4f4bd
Show file tree
Hide file tree
Showing 28 changed files with 123 additions and 160 deletions.
7 changes: 4 additions & 3 deletions connectors/apache-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -55,11 +55,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<!--<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<version>${guava.version}</version>
</dependency>-->
</dependencies>

<build>
Expand Down
5 changes: 0 additions & 5 deletions connectors/apache5-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
7 changes: 4 additions & 3 deletions connectors/jetty-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2011, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -66,11 +66,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<!--<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<version>${guava.version}</version>
</dependency>-->
</dependencies>

<build>
Expand Down
7 changes: 4 additions & 3 deletions connectors/netty-connector/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -49,11 +49,12 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<!--<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<version>${guava.version}</version>
</dependency>-->
</dependencies>

<build>
Expand Down
10 changes: 8 additions & 2 deletions containers/jdk-http/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2010, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2010, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -33,10 +33,16 @@
<description>JDK Http Container</description>

<dependencies>
<dependency>
<!--<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
<version>${guava.version}</version>
</dependency>-->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons.io.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -30,14 +30,15 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLHandshakeException;

import org.apache.commons.io.IOUtils;
import org.glassfish.jersey.SslConfigurator;
import org.glassfish.jersey.internal.util.JdkVersion;
import org.glassfish.jersey.server.ResourceConfig;

import org.junit.After;
import org.junit.Test;

import com.google.common.io.ByteStreams;
//import com.google.common.io.ByteStreams;

import com.sun.net.httpserver.HttpServer;
import com.sun.net.httpserver.HttpsConfigurator;
Expand Down Expand Up @@ -188,9 +189,9 @@ private SSLContext getClientSslContext() throws IOException {


final SslConfigurator sslConfigClient = SslConfigurator.newInstance()
.trustStoreBytes(ByteStreams.toByteArray(trustStore))
.trustStoreBytes(IOUtils.toByteArray(trustStore))
.trustStorePassword(TRUSTSTORE_CLIENT_PWD)
.keyStoreBytes(ByteStreams.toByteArray(keyStore))
.keyStoreBytes(IOUtils.toByteArray(keyStore))
.keyPassword(KEYSTORE_CLIENT_PWD);

return sslConfigClient.createSSLContext();
Expand All @@ -201,9 +202,9 @@ private SSLContext getServerSslContext() throws IOException {
final InputStream keyStore = JdkHttpsServerTest.class.getResourceAsStream(KEYSTORE_SERVER_FILE);

final SslConfigurator sslConfigServer = SslConfigurator.newInstance()
.keyStoreBytes(ByteStreams.toByteArray(keyStore))
.keyStoreBytes(IOUtils.toByteArray(keyStore))
.keyPassword(KEYSTORE_SERVER_PWD)
.trustStoreBytes(ByteStreams.toByteArray(trustStore))
.trustStoreBytes(IOUtils.toByteArray(trustStore))
.trustStorePassword(TRUSTSTORE_SERVER_PWD);

return sslConfigServer.createSSLContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0, which is available at
Expand All @@ -12,6 +12,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.Executors;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand All @@ -32,7 +33,6 @@
import org.glassfish.jersey.server.Uri;

import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AsyncFunction;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
Expand Down Expand Up @@ -80,7 +80,7 @@ public void onSuccess(final List<AgentResponse> result) {
public void onFailure(final Throwable t) {
async.resume(t);
}
});
}, Executors.newSingleThreadExecutor());
}

private ListenableFuture<AgentResponse> visited(final AgentResponse response) {
Expand All @@ -97,11 +97,11 @@ private ListenableFuture<AgentResponse> visited(final AgentResponse response) {
});

// ... and set them to the final response.
return Futures.transform(visited, (AsyncFunction<List<Destination>, AgentResponse>) destinations -> {
return Futures.transform(visited, destinations -> {
response.setVisited(destinations);

return Futures.immediateFuture(response);
});
return response;
}, Executors.newSingleThreadExecutor());
}

private ListenableFuture<AgentResponse> recommended(final AgentResponse response) {
Expand All @@ -120,15 +120,14 @@ private ListenableFuture<AgentResponse> recommended(final AgentResponse response

// ... transform them to Recommendation instances ...
final ListenableFuture<List<Recommendation>> recommendations = Futures.transform(
destinations,
(AsyncFunction<List<Destination>, List<Recommendation>>) destinationList -> {
destinations, destinationList -> {
// Create new array list to avoid multiple remote calls.
final List<Recommendation> recommendationList = Lists.newArrayList(Lists.transform(
destinationList,
destination -> new Recommendation(destination.getDestination(), null, 0)));

return Futures.immediateFuture(recommendationList);
});
return recommendationList;
}, Executors.newSingleThreadExecutor());

// ... add forecasts and calculations ...
final ListenableFuture<List<List<Recommendation>>> filledRecommendations = Futures
Expand All @@ -140,47 +139,47 @@ private ListenableFuture<AgentResponse> recommended(final AgentResponse response

// ... and transform the list into agent response with filled recommendations.
return Futures
.transform(filledRecommendations, (AsyncFunction<List<List<Recommendation>>, AgentResponse>) input -> {
.transform(filledRecommendations, input -> {
response.setRecommended(input.get(0));

return Futures.immediateFuture(response);
});
return response;
}, Executors.newSingleThreadExecutor());
}

private ListenableFuture<List<Recommendation>> forecasts(final ListenableFuture<List<Recommendation>> recommendations) {
forecast.register(RxListenableFutureInvokerProvider.class);

// Fill the list with weather forecast.
return Futures.transform(recommendations, (AsyncFunction<List<Recommendation>, List<Recommendation>>) list ->
return Futures.transform(recommendations, list ->
// For each recommendation ...
Futures.successfulAsList(Lists.transform(list, recommendation -> Futures.transform(
(List<Recommendation>) Futures.successfulAsList(Lists.transform(list, recommendation -> Futures.transform(
// ... get the weather forecast ...
forecast.resolveTemplate("destination", recommendation.getDestination()).request()
.rx(RxListenableFutureInvoker.class)
.get(Forecast.class),
// ... and set it to the recommendation.
(AsyncFunction<Forecast, Recommendation>) forecast -> {
forecast -> {
recommendation.setForecast(forecast.getForecast());
return Futures.immediateFuture(recommendation);
}))));
return recommendation;
}, Executors.newSingleThreadExecutor()))), Executors.newSingleThreadExecutor());
}

private ListenableFuture<List<Recommendation>> calculations(final ListenableFuture<List<Recommendation>> recommendations) {
calculation.register(RxListenableFutureInvokerProvider.class);

// Fill the list with price calculations.
return Futures.transform(recommendations, (AsyncFunction<List<Recommendation>, List<Recommendation>>) list ->
return Futures.transform(recommendations, list ->
// For each recommendation ...
Futures.successfulAsList(Lists.transform(list, recommendation -> Futures.transform(
(List<Recommendation>) Futures.successfulAsList(Lists.transform(list, recommendation -> Futures.transform(
// ... get the price calculation ...
calculation.resolveTemplate("from", "Moon")
.resolveTemplate("to", recommendation.getDestination())
.request().rx(RxListenableFutureInvoker.class).get(Calculation.class),
// ... and set it to the recommendation.
(AsyncFunction<Calculation, Recommendation>) calculation -> {
calculation -> {
recommendation.setPrice(calculation.getPrice());
return Futures.immediateFuture(recommendation);
})))
return recommendation;
}, Executors.newSingleThreadExecutor()))), Executors.newSingleThreadExecutor()
);
}
}
3 changes: 2 additions & 1 deletion ext/rx/rx-client-guava/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!--
Copyright (c) 2014, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2014, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -41,6 +41,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>
</dependencies>
</project>
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1528,12 +1528,6 @@
<version>${jta.api.version}</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>

<dependency>
<groupId>org.glassfish.hk2</groupId>
<artifactId>hk2-locator</artifactId>
Expand Down Expand Up @@ -2108,6 +2102,7 @@
<bnd.plugin.version>2.3.6</bnd.plugin.version>
<cdi.api.version>1.1</cdi.api.version>
<cdi2.api.version>2.0.2</cdi2.api.version>
<commons.io.version>2.11.0</commons.io.version>
<commons-lang3.version>3.3.2</commons-lang3.version>
<microprofile.config.version>2.0</microprofile.config.version>
<checkstyle.mvn.plugin.version>3.1.0</checkstyle.mvn.plugin.version>
Expand All @@ -2121,7 +2116,7 @@
<gae.version>1.9.59</gae.version>
<grizzly.client.version>1.16</grizzly.client.version>
<grizzly2.version>2.4.4</grizzly2.version>
<guava.version>18.0</guava.version>
<guava.version>31.1-jre</guava.version>
<hamcrest.version>1.3</hamcrest.version>
<helidon.version>1.0.3</helidon.version>
<xmlunit.version>1.6</xmlunit.version>
Expand Down
8 changes: 4 additions & 4 deletions test-framework/maven/container-runner-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -119,11 +119,11 @@
<version>${project.version}</version>
</dependency>

<dependency>
<!--<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.0.1-jre</version>
</dependency>
<version>${guava.version}</version>
</dependency>-->

</dependencies>

Expand Down
9 changes: 5 additions & 4 deletions test-framework/maven/custom-enforcer-rules/pom.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2015, 2022 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -46,13 +46,14 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>${commons.io.version}</version>
</dependency>

<dependency>
<!--<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<version>${guava.version}</version>
</dependency>-->

<dependency>
<groupId>junit</groupId>
Expand Down
Loading

0 comments on commit ea4f4bd

Please sign in to comment.