Skip to content

Commit 5dc5cc8

Browse files
berndthll
andauthored
Update to Java 21 (#22908)
* Remove maven.compiler.* properties from plugin archetype They are already defined in org.graylog:graylog-parent * Maven: update java compiler version from 17 to 21 * Update java in Github workflows * Fix deprecated usage of URL constructor * Fix deprecated usage of Thread#id * Catch IllegalArgumentException when URLs are not absolute * Remove PMD plugin for lack of java 21 support * Update to Java 21 * Inherig compiler source/target settings from parent * Use Java 21 in test containers * Fix URL deprecation error for Java 21 * Setup Mockito Java Agent for surefire See "Explicitly setting up instrumentation for inline mocking (Java 21+)" at https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3 * Switch dependency plugin to test phase and fix argLine * Get dependency properties in test-compile phase * Add changelog entry and adjust UPGRADING.md --------- Co-authored-by: Othello Maurer <[email protected]>
1 parent 33d2117 commit 5dc5cc8

File tree

19 files changed

+74
-45
lines changed

19 files changed

+74
-45
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest-4-cores-public
1414
strategy:
1515
matrix:
16-
java-version: [ 17 ]
16+
java-version: [ 21 ]
1717
steps:
1818
- uses: actions/checkout@v4
1919
- name: Set up JDK ${{ matrix.java-version }}

.github/workflows/fix-linter-hints.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
java-version: [ 17 ]
14+
java-version: [ 21 ]
1515

1616
steps:
1717
- name: Freeing up more disk space

.github/workflows/reviewbot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up JDK
2121
uses: actions/setup-java@v3
2222
with:
23-
java-version: 17
23+
java-version: 21
2424
distribution: temurin
2525
cache: maven
2626
- name: Compile with Maven / Install dependencies

UPGRADING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Upgrading to Graylog 7.0.x
33

44
## Breaking Changes
55

6+
### Java 21
7+
8+
Graylog now requires Java 21 to run. Earlier versions are no longer supported.
9+
10+
Our operating system packages and container images are shipping with the
11+
correct Java version.
12+
613
### Kafka Inputs
714

815
The `kafka-clients` library was updated to 4.x which removes support for Kafka
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type = "c"
2+
message = "Switch to Java 21."
3+
4+
issues = ["20015"]
5+
pulls = ["graylog2-server#22908", "graylog-plugin-enterprise#11084", "graylog-project-internal#178"]

data-node/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
<properties>
4242
<mainClass>org.graylog.datanode.bootstrap.Main</mainClass>
4343

44-
<maven.compiler.source>17</maven.compiler.source>
45-
<maven.compiler.target>17</maven.compiler.target>
4644
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4745
<opensearch.version>2.15.0</opensearch.version>
4846
<opensearch.mac.jdk.version>21.0.7</opensearch.mac.jdk.version>

data-node/src/test/java/org/graylog/datanode/testinfra/DatanodeDevContainerBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private static ImageFromDockerfile createImage() {
235235

236236
return image.withDockerfileFromBuilder(builder ->
237237
{
238-
final DockerfileBuilder fileBuilder = builder.from("eclipse-temurin:17-jre-jammy")
238+
final DockerfileBuilder fileBuilder = builder.from("eclipse-temurin:21-jre-jammy")
239239
.workDir(IMAGE_WORKING_DIR)
240240
.run("mkdir -p opensearch/config")
241241
.run("mkdir -p opensearch/data")

full-backend-tests/src/test/java/org/graylog/searchbackend/datanode/ClientCertResourceIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import java.io.IOException;
5555
import java.io.StringReader;
5656
import java.net.HttpURLConnection;
57+
import java.net.URI;
5758
import java.net.URL;
5859
import java.security.KeyStore;
5960
import java.security.KeyStoreException;
@@ -122,7 +123,7 @@ void generateClientCert() throws Exception {
122123
createKeystore(privateKey, certificate, caCertificate),
123124
createTruststore(caCertificate));
124125

125-
final URL url = new URL("https://" + this.api.backend().searchServerInstance().getHttpHostAddress());
126+
final URL url = new URI("https://" + this.api.backend().searchServerInstance().getHttpHostAddress()).toURL();
126127

127128
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
128129
if (connection instanceof HttpsURLConnection) {
@@ -183,7 +184,7 @@ private static PrivateKey decodePrivateKey(String pemEncodedCert, String private
183184
Object parsed = pemParser.readObject();
184185
if (parsed instanceof PEMKeyPair keyPair) {
185186
return converter.getPrivateKey(keyPair.getPrivateKeyInfo());
186-
} else if(parsed instanceof PKCS8EncryptedPrivateKeyInfo keyPair) {
187+
} else if (parsed instanceof PKCS8EncryptedPrivateKeyInfo keyPair) {
187188
return decryptPrivateKey(privateKeyPassword, keyPair, converter);
188189
} else {
189190
throw new IllegalArgumentException("Couldn't parse private key from provided string, unknown type");

graylog-plugin-archetype/src/main/resources/archetype-resources/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454

5555
<properties>
5656
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
57-
<maven.compiler.source>17</maven.compiler.source>
58-
<maven.compiler.target>17</maven.compiler.target>
5957

6058
<!-- Plugins will not be deployed by default - set to `false` if you actually want to deploy it -->
6159
<maven.deploy.skip>true</maven.deploy.skip>

graylog-project-parent/pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,28 @@
549549
</plugins>
550550
</pluginManagement>
551551
<plugins>
552+
<plugin>
553+
<groupId>org.apache.maven.plugins</groupId>
554+
<artifactId>maven-dependency-plugin</artifactId>
555+
<executions>
556+
<execution>
557+
<phase>test-compile</phase>
558+
<goals>
559+
<!-- Required to get Mockito's JAR path for the surefire argLine. -->
560+
<goal>properties</goal>
561+
</goals>
562+
</execution>
563+
</executions>
564+
</plugin>
552565
<plugin>
553566
<groupId>org.apache.maven.plugins</groupId>
554567
<artifactId>maven-surefire-plugin</artifactId>
555568
<configuration>
556569
<forkCount>1</forkCount>
557570
<reuseForks>true</reuseForks>
558-
<argLine>-Dio.netty.leakDetectionLevel=paranoid -Djava.awt.headless=true</argLine>
571+
<!-- See: "Explicitly setting up instrumentation for inline mocking (Java 21+)" at
572+
https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3 -->
573+
<argLine>-javaagent:${org.mockito:mockito-core:jar} -Dio.netty.leakDetectionLevel=paranoid -Djava.awt.headless=true</argLine>
559574
<excludes>
560575
<exclude>**/*IntegrationTest.java</exclude>
561576
<exclude>**/*IT.java</exclude>

0 commit comments

Comments
 (0)