Skip to content

Commit 078d369

Browse files
codepitbullcaoccao
andauthored
Chore/java 21 (#1163)
* Upgrade to JDK 21 * Update docker image to 21 --------- Co-authored-by: Sam Cao <[email protected]>
1 parent 96cde9d commit 078d369

File tree

24 files changed

+131
-212
lines changed

24 files changed

+131
-212
lines changed

.github/workflows/check-backend.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
3030
with:
3131
distribution: 'adopt'
32-
java-version: '17'
32+
java-version: '21'
3333

3434
- uses: burrunan/gradle-cache-action@663fbad34e03c8f12b27f4999ac46e3d90f87eca # v3.0.1
3535
name: Build container

.github/workflows/etherip-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4
2222
with:
2323
distribution: 'adopt'
24-
java-version: '17'
24+
java-version: '21'
2525
- uses: whelk-io/maven-settings-xml-action@9dc09b23833fa9aa7f27b63db287951856f3433d # v3.0.0
2626
with:
2727
servers: >

.github/workflows/snyk-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
distribution: 'temurin'
2424
java-version: |
25-
17
25+
21
2626
2727
- uses: hivemq/hivemq-checkout-composite-action@db2d49f686c47a1eca28b7722bc3425c0d0e5101 # v1
2828
with:

.github/workflows/snyk-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
distribution: 'temurin'
2929
java-version: |
30-
17
30+
21
3131
3232
- uses: hivemq/hivemq-checkout-composite-action@db2d49f686c47a1eca28b7722bc3425c0d0e5101 # v1
3333
with:

.github/workflows/snyk-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
distribution: 'temurin'
1717
java-version: |
18-
17
18+
21
1919
2020
- uses: hivemq/hivemq-checkout-composite-action@db2d49f686c47a1eca28b7722bc3425c0d0e5101 # v1
2121
with:

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ oci {
199199
imageName.set("hivemq/hivemq-edge")
200200
allPlatforms {
201201
dependencies {
202-
runtime("library:eclipse-temurin:sha256!3aa7f6dc20dcf61b7ca765cae9a425439933bf0367923c2d9ba80bc60cfa9680") // eclipse-temurin:17.0.15_6-jre-noble
202+
runtime("library:eclipse-temurin:sha256!748920dd9a6261e117da7bcaeaafa109cedd487645f7ea04135f4e3cb73ec079") // eclipse-temurin:21.0.8_9-jre-noble
203203
}
204204
config {
205205
user = "10000"

edge-plugins/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ group = "com.hivemq"
66

77
java {
88
toolchain {
9-
languageVersion.set(JavaLanguageVersion.of(17))
9+
languageVersion.set(JavaLanguageVersion.of(21))
1010
}
1111
}
1212

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ postgresql = "42.7.3"
4949
shrinkwrap = "1.2.6"
5050
slf4j = "2.0.17"
5151
spotBugs = "4.9.4"
52-
stefanbirkner-systemrules = "1.19.0"
5352
swagger-annotations = "2.2.34"
5453
swagger-jaxrs = "1.6.16"
54+
systemstubs = "2.1.8"
5555
victools = "4.38.0"
5656
wiremock = "3.0.1"
5757
zeroallocationhashing = "0.27ea0"
@@ -147,9 +147,9 @@ shrinkwrap-api = { module = "org.jboss.shrinkwrap:shrinkwrap-api", version.ref =
147147
shrinkwrap-impl = { module = "org.jboss.shrinkwrap:shrinkwrap-impl-base", version.ref = "shrinkwrap" }
148148
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
149149
slf4j-jultoslf4j = { module = "org.slf4j:jul-to-slf4j", version.ref = "slf4j" }
150-
stefanbirkner-systemrules = { module = "com.github.stefanbirkner:system-rules", version.ref = "stefanbirkner-systemrules" }
151150
swagger-annotations = { module = "io.swagger.core.v3:swagger-annotations", version.ref = "swagger-annotations" }
152151
swagger-jaxrs = { module = "io.swagger:swagger-jaxrs", version.ref = "swagger-jaxrs" }
152+
systemstubs = { module = "uk.org.webcompere:system-stubs-jupiter", version.ref = "systemstubs" }
153153
victools-jsonschema-generator = { module = "com.github.victools:jsonschema-generator", version.ref = "victools" }
154154
victools-jsonschema-jackson = { module = "com.github.victools:jsonschema-module-jackson", version.ref = "victools" }
155155
wiremock-jre8-standalone = { module = "com.github.tomakehurst:wiremock-jre8-standalone", version.ref = "wiremock" }

hivemq-edge/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ metadata {
9494

9595
java {
9696
toolchain {
97-
languageVersion.set(JavaLanguageVersion.of(17))
97+
languageVersion.set(JavaLanguageVersion.of(21))
9898
}
9999
withJavadocJar()
100100
withSourcesJar()
@@ -226,9 +226,7 @@ dependencies {
226226
testImplementation(libs.javassist)
227227
testImplementation(libs.awaitility)
228228
testImplementation(libs.assertj)
229-
testImplementation(libs.stefanbirkner.systemrules) {
230-
exclude("junit", "junit-dep")
231-
}
229+
testImplementation(libs.systemstubs)
232230
}
233231

234232
tasks.test {

hivemq-edge/src/main/java/com/hivemq/bootstrap/HiveMQExceptionHandlerBootstrap.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,32 @@
1818
import com.google.common.annotations.VisibleForTesting;
1919
import com.google.common.base.Throwables;
2020
import com.hivemq.exceptions.UnrecoverableException;
21+
import com.hivemq.extension.sdk.api.annotations.NotNull;
2122
import org.slf4j.Logger;
2223
import org.slf4j.LoggerFactory;
2324

25+
import java.util.concurrent.Callable;
26+
import java.util.concurrent.atomic.AtomicReference;
27+
2428
/**
2529
* @author Dominik Obermaier
2630
*/
2731
public class HiveMQExceptionHandlerBootstrap {
2832

2933
private static final Logger log = LoggerFactory.getLogger(HiveMQExceptionHandlerBootstrap.class);
3034

35+
private static final AtomicReference<Runnable> terminator = new AtomicReference<>(() -> System.exit(1));
36+
3137
/**
3238
* Adds an uncaught Exception Handler for UnrecoverableExceptions.
3339
* Logs the error and quits HiveMQ
3440
*/
3541
public static void addUnrecoverableExceptionHandler() {
36-
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
37-
@Override
38-
public void uncaughtException(final Thread t, final Throwable e) {
42+
Thread.setDefaultUncaughtExceptionHandler(HiveMQExceptionHandlerBootstrap::handleUncaughtException);
43+
}
3944

40-
handleUncaughtException(t, e);
41-
}
42-
});
45+
public static void setTerminator(@NotNull final Runnable runnable) {
46+
terminator.set(runnable);
4347
}
4448

4549
@VisibleForTesting
@@ -48,16 +52,14 @@ static void handleUncaughtException(final Thread t, final Throwable e) {
4852
if (((UnrecoverableException) e).isShowException()) {
4953
log.error("An unrecoverable Exception occurred. Exiting HiveMQ", t, e);
5054
}
51-
System.exit(1);
55+
terminator.get().run();
5256
}
5357
final Throwable rootCause = Throwables.getRootCause(e);
5458
if (rootCause instanceof UnrecoverableException) {
5559
final boolean showException = ((UnrecoverableException) rootCause).isShowException();
5660
if (showException) {
5761
log.error("Cause: ", e);
5862
}
59-
} else if (rootCause instanceof ThreadDeath) {
60-
// NOOP: this happens when tests stop the remaining threads via thread.stop();
6163
} else {
6264
log.error("Uncaught Error:", e);
6365
}

0 commit comments

Comments
 (0)