Open suztomo opened 3 years ago
Note that the "-android" flavor is currently compatible with Java 7, but is intended to remain compatible with (some version of) Android SDK. The version of Android SDK that it's compatible with does not include many Java 8 APIs, such as java.time
.
I imagine that there are probably few remaining Java 7 users of GCP. What about Android clients, though?
What about Android clients, though?
I don't have the number. Let me search for it a bit.
@kileys We're going to keep the libraries BOM's Guava as it is until we stop supporting Java 7. When Beam publishes its Beam GCP BOM for Beam users early next year, add the override to choose Beam's Guava flavor.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version> <!-- "-jre" for Java 8 or higher -->
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>16.2.0</version> <!-- the version the Beam release was built with -->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
This enables Beam users to select appropriate Guava version (rather than them relying on the Libraries BOM).
Beam vendors Guava. So why is this an issue at all?
org.apache.beam.sdk.io.gcp.healthcare.HL7v2IOTest > test_HL7v2IO_failedReads FAILED
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.util.concurrent.UncheckedExecutionException at LocalCache.java:2050
Caused by: org.apache.beam.sdk.util.UserCodeException at UserCodeException.java:39
Caused by: java.io.IOException at DefaultCredentialsProvider.java:134
We need to double check our assumptions and make sure we understand what the problem really is, as well as the root causes.
Yes, Beam vendors Guava. This error below
java.lang.NoSuchMethodError: com.google.common.cache.CacheBuilder.expireAfterWrite(Ljava/time/Duration;)Lcom/google/common/cache/CacheBuilder;
at com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.<init>(GoogleCloudStorageImpl.java:149)
comes from com.google.cloud.bigdataoss:gcsio
, one of the Beam dependencies (gcsio is outside the libraries BOM).
This is the issue I asked for gcsio to use Guava's -android flavor. https://github.com/GoogleCloudDataproc/hadoop-connectors/issues/307
Will LTS work moot this?
Shall we create the Libraries BOM with Guava's -jre flavor?
As of now, the Libraries BOM uses Guava's -android flavor. This flavor of Guava does not have methods for Java 8+, such as
CacheBuilder.expireAfterWrite(java.time.Duration)
. (Duration class was introduced in Java 8.) If a project uses the Libraries BOM and depends on a library that touches the Java 8+ methods (for examplecom.google.cloud.bigdataoss:gcsio
), the JVM throwsNoSuchMethodError
:Therefore, Java 8 users in such situations need to override the version of Guava. The step is documented in https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM#guava-versions--jre-or--android . As noted there we cannot override Gradle's
enforcedPlatform
keyword, which controls transitive dependency versions. (platform
works but this does not control transitive dependencies) Maven users can override transitive dependencies by adding guava entry in thedependencyManagement
section.Given that Java 8 users are majority right now (Java 7 users are few percent in GCP), shall we target for Java 8 users as the main audience?
This request is from @kileys (Dataflow team). The options listed below are prepared by suztomo.
Option 1: change main target audience to Java 8 users
Option 2: two flavors of the Libraries BOM