Skip to content

Commit

Permalink
Require JDK 21 to run Trino
Browse files Browse the repository at this point in the history
  • Loading branch information
wendigo committed Jan 8, 2024
1 parent 5c2b059 commit 09ef5b5
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 66 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
fail-fast: false
matrix:
java-version:
- 17 # Keep testing on JDK 17 to ensure basic backward compatibility
- 21
timeout-minutes: 45
steps:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ information about reporting vulnerabilities.
## Build requirements

* Mac OS X or Linux
* Java 17.0.8+, 64-bit
* Java 21.0.1+, 64-bit
* Docker
* Turn SELinux or other systems disabling write access to the local checkout
off, to allow containers to mount parts of the Trino source tree
Expand Down Expand Up @@ -70,8 +70,8 @@ After opening the project in IntelliJ, double check that the Java SDK is
properly configured for the project:

* Open the File menu and select Project Structure
* In the SDKs section, ensure that JDK 17 is selected (create one if none exist)
* In the Project section, ensure the Project language level is set to 17
* In the SDKs section, ensure that JDK 21 is selected (create one if none exist)
* In the Project section, ensure the Project language level is set to 21

### Running a testing server

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,23 @@
import com.google.common.util.concurrent.ForwardingListeningExecutorService;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import jakarta.annotation.Nullable;

import java.lang.invoke.MethodHandle;
import java.lang.reflect.Method;
import java.time.Duration;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.trino.util.Reflection.methodHandle;
import static java.util.Objects.requireNonNull;

public class DecoratingListeningExecutorService
extends ForwardingListeningExecutorService
implements ListeningExecutorService
{
// TODO remove after requiring Java 19+ for runtime.
private static final @Nullable MethodHandle CLOSE_METHOD;

static {
Method closeMethod;
try {
closeMethod = ExecutorService.class.getMethod("close");
}
catch (NoSuchMethodException e) {
closeMethod = null;
}
CLOSE_METHOD = closeMethod != null
? methodHandle(closeMethod)
: null;
}

private final ListeningExecutorService delegate;
private final TaskDecorator decorator;

Expand Down Expand Up @@ -194,21 +172,10 @@ public boolean awaitTermination(Duration duration)
return super.awaitTermination(duration);
}

// TODO This is temporary, until Guava's ForwardingExecutorService has the method in their interface. See https://github.com/google/guava/issues/6296
//@Override
@Override
public void close()
{
if (CLOSE_METHOD == null) {
throw new UnsupportedOperationException("ExecutorService.close has close() method since Java 19. " +
"The DecoratingListeningExecutorService supports the method only when run with Java 19 runtime.");
}
try {
CLOSE_METHOD.invoke(delegate());
}
catch (Throwable e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
delegate.close();
}

public interface TaskDecorator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ else if ("Mac OS X".equals(osName)) {

private static void verifyJavaVersion()
{
Version required = Version.parse("17.0.8");
Version required = Version.parse("21.0.1");

if (Runtime.version().compareTo(required) < 0) {
failRequirement("Trino requires Java %s at minimum (found %s)", required, Runtime.version());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public static void main(String[] args)
String javaVersion = nullToEmpty(StandardSystemProperty.JAVA_VERSION.value());
String majorVersion = javaVersion.split("\\D", 2)[0];
Integer major = Ints.tryParse(majorVersion);
if (major == null || major < 17) {
System.err.println(format("ERROR: Trino requires Java 17+ (found %s)", javaVersion));
if (major == null || major < 21) {
System.err.println(format("ERROR: Trino requires Java 21+ (found %s)", javaVersion));
System.exit(100);
}

Expand Down
8 changes: 2 additions & 6 deletions core/trino-server-rpm/src/main/rpm/preinstall
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ check_if_correct_java_version() {
# candidate for JAVA_HOME).
JAVA_VERSION=$(java_version "$1")
JAVA_MAJOR=$(echo "$JAVA_VERSION" | cut -d'.' -f1)
if [ "$JAVA_MAJOR" -ge "17" ]; then
if [ "$JAVA_MAJOR" -ge "21" ]; then
echo "$1" >/tmp/trino-rpm-install-java-home
return 0
else
Expand All @@ -34,10 +34,6 @@ check_if_correct_java_version() {
if ! check_if_correct_java_version "$JAVA_HOME"; then
java_found=false
for candidate in \
/usr/lib/jvm/java-17-* \
/usr/lib/jvm/zulu-17 \
/usr/lib/jvm/temurin-17 \
/usr/lib/jvm/temurin-17-* \
/usr/lib/jvm/java-21-* \
/usr/lib/jvm/zulu-21 \
/usr/lib/jvm/temurin-21 \
Expand All @@ -61,7 +57,7 @@ if [ "$java_found" = false ]; then
+======================================================================+
| Error: Required Java version could not be found |
+----------------------------------------------------------------------+
| JDK 17 was not detected. |
| JDK 21 was not detected. |
| Recommended JDK distribution is Eclipse Temurin. |
| Installation guide: https://adoptium.net/installation/linux/ |
| |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public ServerIT()
@Test
public void testInstall()
{
testInstall("17");
testInstall("21");
}

Expand Down Expand Up @@ -107,7 +106,6 @@ private void testInstall(String javaVersion)
public void testUninstall()
throws Exception
{
testUninstall("17");
testUninstall("21");
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/sphinx/functions/conversion.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Like {func}`cast`, but returns null if the cast fails.
## Formatting

:::{function} format(format, args...) -> varchar
Returns a formatted string using the specified [format string](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Formatter.html#syntax)
Returns a formatted string using the specified [format string](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Formatter.html#syntax)
and arguments:

```
Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/sphinx/functions/regexp.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,6 @@ SELECT regexp_split('1a 2b 14m', '\s*[a-z]+\s*'); -- [1, 2, 14, ]
```
:::

[capturing group number]: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#gnumber
[capturing groups]: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html#cg
[java pattern]: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/regex/Pattern.html
[capturing group number]: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/regex/Pattern.html#gnumber
[capturing groups]: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/regex/Pattern.html#cg
[java pattern]: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/regex/Pattern.html
10 changes: 3 additions & 7 deletions docs/src/main/sphinx/installation/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,15 @@

### Java runtime environment

Trino requires a 64-bit version of Java 17, with a minimum required version of 17.0.8.
Earlier major versions such as Java 8 or Java 11 do not work.
Newer major versions such as Java 18 or 19, are not supported -- they may work, but are not tested.
Trino requires a 64-bit version of Java 21, with a minimum required version of 21.0.1.
Earlier major versions such as Java 8, Java 11 or Java 17 do not work.
Newer major versions such as Java 22 are not supported -- they may work, but are not tested.

We recommend using the Eclipse Temurin OpenJDK distribution from
[Adoptium](https://adoptium.net/) as the JDK for Trino, as Trino is tested
against that distribution. Eclipse Temurin is also the JDK used by the [Trino
Docker image](https://hub.docker.com/r/trinodb/trino).

If you are using Java 17 or 18, the JVM must be configured to use UTF-8 as the default charset by
adding `-Dfile.encoding=UTF-8` to `etc/jvm.config`. Starting with Java 19, the Java default
charset is UTF-8, so this configuration is not needed.

(requirements-python)=

### Python
Expand Down
6 changes: 3 additions & 3 deletions docs/src/main/sphinx/security/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ using TLS 1.2 and TLS 1.3 certificates. The server rejects TLS 1.1, TLS 1.0, and
all SSL format certificates.

The Trino server does not specify a set of supported ciphers, instead deferring
to the defaults set by the JVM version in use. The documentation for Java 17
lists its [supported cipher suites](https://docs.oracle.com/en/java/javase/17/security/oracle-providers.html#GUID-7093246A-31A3-4304-AC5F-5FB6400405E2__SUNJSSE_CIPHER_SUITES).
to the defaults set by the JVM version in use. The documentation for Java 21
lists its [supported cipher suites](https://docs.oracle.com/en/java/javase/21/security/oracle-providers.html#GUID-7093246A-31A3-4304-AC5F-5FB6400405E2__SUNJSSE_CIPHER_SUITES).

Run the following two-line code on the same JVM from the same vendor as
configured on the coordinator to determine that JVM's default cipher list.
Expand Down Expand Up @@ -56,7 +56,7 @@ considered in conjunction with your organization's security managers. Using a
different suite may require downloading and installing a different SunJCE
implementation package. Some locales may have export restrictions on cipher
suites. See the discussion in Java documentation that begins with [Customizing
the Encryption Algorithm Providers](https://docs.oracle.com/en/java/javase/17/security/java-secure-socket-extension-jsse-reference-guide.html#GUID-316FB978-7588-442E-B829-B4973DB3B584).
the Encryption Algorithm Providers](https://docs.oracle.com/en/java/javase/21/security/java-secure-socket-extension-jsse-reference-guide.html#GUID-316FB978-7588-442E-B829-B4973DB3B584).

:::{note}
If you manage the coordinator's direct TLS implementatation, monitor the CPU
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@
</scm>

<properties>
<project.build.targetJdk>17</project.build.targetJdk>
<project.build.targetJdk>21</project.build.targetJdk>

<air.check.skip-spotbugs>true</air.check.skip-spotbugs>
<air.check.skip-pmd>true</air.check.skip-pmd>
<air.check.skip-jacoco>true</air.check.skip-jacoco>
<air.java.version>17.0.8</air.java.version>
<air.java.version>21.0.1</air.java.version>
<air.javadoc.lint>-missing</air.javadoc.lint>
<air.main.basedir>${project.basedir}</air.main.basedir>
<air.modernizer.java-version>8</air.modernizer.java-version>
Expand Down

0 comments on commit 09ef5b5

Please sign in to comment.