diff --git a/constraints/build.gradle b/constraints/build.gradle index f197a5ca9d..8a219a80a4 100644 --- a/constraints/build.gradle +++ b/constraints/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/contrib/build.gradle b/contrib/build.gradle index 9b895af315..ebb6146fb6 100644 --- a/contrib/build.gradle +++ b/contrib/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar() diff --git a/db-tests/build.gradle b/db-tests/build.gradle index dfcad31365..a04992a271 100644 --- a/db-tests/build.gradle +++ b/db-tests/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md index 097ecb905a..ae61ea143d 100644 --- a/docs/DEVELOPER.md +++ b/docs/DEVELOPER.md @@ -33,7 +33,7 @@ Before you can run Aerie you must install and configure the following products o Make sure you update your `JAVA_HOME` environment variable. For example with [Zsh](https://www.zsh.org/) you can set your `.zshrc` to: ```sh - export JAVA_HOME="/Library/Java/JavaVirtualMachines/temurin-19.jdk/Contents/Home" + export JAVA_HOME="/Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home" ``` - [PostgreSQL](https://www.postgresql.org) which is used for testing the database. You do not need this normally since Aerie runs Postgres in a Docker container for development, and you only need it for the [psql](https://www.postgresql.org/docs/current/app-psql.html) command-line tool. **Do not run the Postgres service locally** or it will clash with the Aerie Postgres Docker container. If you're on OSX you can use brew: diff --git a/e2e-tests/build.gradle b/e2e-tests/build.gradle index 2541e13618..9d1eb39b29 100644 --- a/e2e-tests/build.gradle +++ b/e2e-tests/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/examples/banananation/build.gradle b/examples/banananation/build.gradle index 8fd2f09ec8..402c81ca9e 100644 --- a/examples/banananation/build.gradle +++ b/examples/banananation/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/examples/config-with-defaults/build.gradle b/examples/config-with-defaults/build.gradle index 7425e3309d..2fa0e7e215 100644 --- a/examples/config-with-defaults/build.gradle +++ b/examples/config-with-defaults/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/examples/config-without-defaults/build.gradle b/examples/config-without-defaults/build.gradle index 7425e3309d..2fa0e7e215 100644 --- a/examples/config-without-defaults/build.gradle +++ b/examples/config-without-defaults/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/examples/foo-missionmodel/build.gradle b/examples/foo-missionmodel/build.gradle index 7425e3309d..2fa0e7e215 100644 --- a/examples/foo-missionmodel/build.gradle +++ b/examples/foo-missionmodel/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/examples/minimal-mission-model/build.gradle b/examples/minimal-mission-model/build.gradle index 7425e3309d..2fa0e7e215 100644 --- a/examples/minimal-mission-model/build.gradle +++ b/examples/minimal-mission-model/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/examples/streamline-demo/build.gradle b/examples/streamline-demo/build.gradle index 24ed559c1a..b0679446c5 100644 --- a/examples/streamline-demo/build.gradle +++ b/examples/streamline-demo/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 41d9927a4d..943f0cbfa7 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 070cb702f0..509c4a29b4 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787337..65dcd68d65 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd32c4..93e3f59f13 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +25,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/merlin-driver/build.gradle b/merlin-driver/build.gradle index 4d80d8ee87..76cbca76bb 100644 --- a/merlin-driver/build.gradle +++ b/merlin-driver/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar() diff --git a/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java b/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java index 6f77878ec7..efbddb54f2 100644 --- a/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java +++ b/merlin-driver/src/main/java/gov/nasa/jpl/aerie/merlin/driver/engine/SimulationEngine.java @@ -73,29 +73,7 @@ public final class SimulationEngine implements AutoCloseable { private final Map> taskChildren = new HashMap<>(); /** A thread pool that modeled tasks can use to keep track of their state between steps. */ - private final ExecutorService executor = getLoomOrFallback(); - - private static ExecutorService getLoomOrFallback() { - // Try to use Loom's lightweight virtual threads, if possible. Otherwise, just use a thread pool. - // This approach is inspired by that of Javalin 5. - // https://github.com/javalin/javalin/blob/97e9e23ebe8f57aa353bc7a45feb560ad61e50a0/javalin/src/main/java/io/javalin/util/ConcurrencyUtil.kt#L48-L51 - try { - // Use reflection to avoid needing `--enable-preview` at compile-time. - // If the runtime JVM is run with `--enable-preview`, this should succeed. - return (ExecutorService) Executors.class.getMethod("newVirtualThreadPerTaskExecutor").invoke(null); - } catch (final ReflectiveOperationException ex) { - return Executors.newCachedThreadPool($ -> { - final var t = new Thread($); - // TODO: Make threads non-daemons. - // We're marking these as daemons right now solely to ensure that the JVM shuts down cleanly in lieu of - // proper model lifecycle management. - // In fact, daemon threads can mask bad memory leaks: a hanging thread is almost indistinguishable - // from a dead thread. - t.setDaemon(true); - return t; - }); - } - } + private final ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor(); /** Schedule a new task to be performed at the given time. */ public TaskId scheduleTask(final Duration startTime, final TaskFactory state) { diff --git a/merlin-framework-junit/build.gradle b/merlin-framework-junit/build.gradle index 2a8a142c25..52819c1b97 100644 --- a/merlin-framework-junit/build.gradle +++ b/merlin-framework-junit/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar() diff --git a/merlin-framework-processor/build.gradle b/merlin-framework-processor/build.gradle index 4413f39136..2ccadfde82 100644 --- a/merlin-framework-processor/build.gradle +++ b/merlin-framework-processor/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/merlin-framework/build.gradle b/merlin-framework/build.gradle index d025f5b35a..a52dde0379 100644 --- a/merlin-framework/build.gradle +++ b/merlin-framework/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar() diff --git a/merlin-sdk/build.gradle b/merlin-sdk/build.gradle index f1433b7dad..908b26fad7 100644 --- a/merlin-sdk/build.gradle +++ b/merlin-sdk/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar() diff --git a/merlin-server/Dockerfile b/merlin-server/Dockerfile index cb0aa2652b..f578fe1aef 100644 --- a/merlin-server/Dockerfile +++ b/merlin-server/Dockerfile @@ -4,7 +4,7 @@ COPY build/distributions/*.tar /usr/src/app/server.tar RUN mkdir /usr/src/app/extracted RUN cd /usr/src/app && tar --strip-components 1 -xf server.tar -C extracted -FROM eclipse-temurin:19-jre-jammy +FROM eclipse-temurin:21-jre-jammy ENV NODE_VERSION=18.13.0 ENV NVM_DIR=/usr/src/.nvm diff --git a/merlin-server/build.gradle b/merlin-server/build.gradle index be7eb521c3..5158d10ba2 100644 --- a/merlin-server/build.gradle +++ b/merlin-server/build.gradle @@ -7,7 +7,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/merlin-worker/Dockerfile b/merlin-worker/Dockerfile index b6232f1305..a8b1d7072b 100644 --- a/merlin-worker/Dockerfile +++ b/merlin-worker/Dockerfile @@ -4,7 +4,7 @@ COPY build/distributions/*.tar /usr/src/app/server.tar RUN mkdir /usr/src/app/extracted RUN cd /usr/src/app && tar --strip-components 1 -xf server.tar -C extracted -FROM eclipse-temurin:19-jre-jammy +FROM eclipse-temurin:21-jre-jammy COPY --from=extractor /usr/src/app/extracted /usr/src/app diff --git a/merlin-worker/build.gradle b/merlin-worker/build.gradle index bf65678a2e..0e8824914d 100644 --- a/merlin-worker/build.gradle +++ b/merlin-worker/build.gradle @@ -5,7 +5,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar() diff --git a/parsing-utilities/build.gradle b/parsing-utilities/build.gradle index 8050e8e8fc..3eaa311b8b 100644 --- a/parsing-utilities/build.gradle +++ b/parsing-utilities/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/permissions/build.gradle b/permissions/build.gradle index 019f5248bb..bc7cb46a1c 100644 --- a/permissions/build.gradle +++ b/permissions/build.gradle @@ -4,7 +4,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/scheduler-driver/build.gradle b/scheduler-driver/build.gradle index c5d5ad7fd1..fef5cca0f9 100644 --- a/scheduler-driver/build.gradle +++ b/scheduler-driver/build.gradle @@ -6,7 +6,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/ResumableSimulationTest.java b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/ResumableSimulationTest.java index 0f2bd23508..4f40990a76 100644 --- a/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/ResumableSimulationTest.java +++ b/scheduler-driver/src/test/java/gov/nasa/jpl/aerie/scheduler/simulation/ResumableSimulationTest.java @@ -2,7 +2,6 @@ import gov.nasa.jpl.aerie.merlin.driver.ActivityDirectiveId; import gov.nasa.jpl.aerie.merlin.driver.SerializedActivity; -import gov.nasa.jpl.aerie.merlin.driver.engine.SimulationEngine; import gov.nasa.jpl.aerie.merlin.protocol.types.Duration; import gov.nasa.jpl.aerie.scheduler.SchedulingInterruptedException; import gov.nasa.jpl.aerie.scheduler.SimulationUtility; @@ -12,7 +11,6 @@ import java.time.Instant; import java.util.ArrayList; import java.util.Map; -import java.util.concurrent.ThreadPoolExecutor; import static gov.nasa.jpl.aerie.merlin.protocol.types.Duration.SECONDS; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -93,40 +91,6 @@ public void testStopsAtEndOfPlanningHorizon() throws SchedulingInterruptedExcept assert(resumableSimulationDriver.getSimulationResults(Instant.now()).unfinishedActivities.size() == 1); } - @Test - public void testThreadsReleased() throws SchedulingInterruptedException { - final var activity = new TestSimulatedActivity( - Duration.of(0, SECONDS), - new SerializedActivity("BasicActivity", Map.of()), - new ActivityDirectiveId(1)); - final var fooMissionModel = SimulationUtility.getFooMissionModel(); - resumableSimulationDriver = new ResumableSimulationDriver<>(fooMissionModel, tenHours, ()-> false); - try (final var executor = unsafeGetExecutor(resumableSimulationDriver)) { - for (var i = 0; i < 20000; i++) { - resumableSimulationDriver.initSimulation(); - resumableSimulationDriver.clearActivitiesInserted(); - resumableSimulationDriver.simulateActivity(activity.start, activity.activity, null, true, activity.id); - assertTrue( - executor.getActiveCount() < 100, - "Threads are not being cleaned up properly - this test shouldn't need more than 2 threads, but it used at least 100"); - } - } - } - - private static ThreadPoolExecutor unsafeGetExecutor(final ResumableSimulationDriver driver) { - try { - final var engineField = ResumableSimulationDriver.class.getDeclaredField("engine"); - engineField.setAccessible(true); - - final var executorField = SimulationEngine.class.getDeclaredField("executor"); - executorField.setAccessible(true); - - return (ThreadPoolExecutor) executorField.get(engineField.get(driver)); - } catch (final ReflectiveOperationException ex) { - throw new RuntimeException(ex); - } - } - private ArrayList getActivities(){ final var acts = new ArrayList(); var act1 = new TestSimulatedActivity( diff --git a/scheduler-server/Dockerfile b/scheduler-server/Dockerfile index 57cfb8d17f..855fac1d8c 100644 --- a/scheduler-server/Dockerfile +++ b/scheduler-server/Dockerfile @@ -4,7 +4,7 @@ COPY build/distributions/*.tar /usr/src/app/server.tar RUN mkdir /usr/src/app/extracted RUN cd /usr/src/app && tar --strip-components 1 -xf server.tar -C extracted -FROM eclipse-temurin:19-jre-jammy +FROM eclipse-temurin:21-jre-jammy COPY --from=extractor /usr/src/app/extracted /usr/src/app diff --git a/scheduler-server/build.gradle b/scheduler-server/build.gradle index 8c2381b95f..d36f28b0cf 100644 --- a/scheduler-server/build.gradle +++ b/scheduler-server/build.gradle @@ -9,7 +9,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } } diff --git a/scheduler-worker/Dockerfile b/scheduler-worker/Dockerfile index 2c08ecf773..3ba21b38d6 100644 --- a/scheduler-worker/Dockerfile +++ b/scheduler-worker/Dockerfile @@ -4,7 +4,7 @@ COPY build/distributions/*.tar /usr/src/app/server.tar RUN mkdir /usr/src/app/extracted RUN cd /usr/src/app && tar --strip-components 1 -xf server.tar -C extracted -FROM eclipse-temurin:19-jre-jammy +FROM eclipse-temurin:21-jre-jammy ENV NODE_VERSION=18.13.0 ENV NVM_DIR=/usr/src/.nvm diff --git a/scheduler-worker/build.gradle b/scheduler-worker/build.gradle index 882a6ec2f7..ef32b3ce53 100644 --- a/scheduler-worker/build.gradle +++ b/scheduler-worker/build.gradle @@ -8,7 +8,7 @@ plugins { java { toolchain { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(21) } withJavadocJar()