Closed sbesson closed 4 months ago
As discussed separately with @sbesson, 1.16 and later quietly removed Java 8 support. https://github.com/jenkinsci/lib-file-leak-detector/pull/98 and https://github.com/jenkinsci/lib-file-leak-detector/pull/99 in particular appear to be the relevant changes.
I can't imagine we can drop Java 8 support quite yet, so probably we can't upgrade file-leak-detector for now.
Since file-leak-detector 1.15 with Java 21 results in a runtime error instead of a compile error, I tried just turning off file-leak-detector based on the detected Java version. Something like this seems to work with file-leak-detector 1.15 and Java 21 locally:
diff --git a/components/test-suite/build.xml b/components/test-suite/build.xml
index 0633b4cefc..abd56ba1c7 100644
--- a/components/test-suite/build.xml
+++ b/components/test-suite/build.xml
@@ -6,7 +6,7 @@ Download Apache Ant from http://ant.apache.org/.
Type "ant -p" for a list of targets.
-->
-<project name="tests" default="jar" basedir=".">
+<project name="tests" default="jar" basedir="." xmlns:if="ant:if">
<description>Build file for Bio-Formats testing framework project</description>
<property name="root.dir" location="../.."/>
<import file="${root.dir}/ant/java.xml"/>
@@ -236,6 +236,12 @@ Type "ant -p" for a list of targets.
<target name="test-automated" depends="compile-tests"
description="run automated tests in group 'automated'">
+ <condition property="compatibleJavaVersion">
+ <not>
+ <equals arg1="${ant.java.version}" arg2="21"/>
+ </not>
+ </condition>
+
<testng groups="automated" testname="Automated tests"
listeners="loci.tests.testng.OrderingListener"
suitename="Bio-Formats software test suite"
@@ -265,7 +271,7 @@ Type "ant -p" for a list of targets.
<jvmarg value="-Duser.language=${user.language}"/>
<jvmarg value="-Duser.country=${user.country}"/>
<jvmarg value="-Dlogback.configurationFile=${logback.configurationFile}"/>
- <jvmarg value="-javaagent:${dep.org.kohsuke:file-leak-detector:jar:jar-with-dependencies}=strong"/>
+ <jvmarg if:set="compatibleJavaVersion" value="-javaagent:${dep.org.kohsuke:file-leak-detector:jar:jar-with-dependencies}=strong"/>
</testng>
<fail if="failedTest"/>
</target>
That obviously means we're not checking for leaking file handles in Java 21, but maybe that's OK given that we test with 3 other versions?
I wouldn't be opposed to trying to replace file-leak-detector with something else, but I don't know of a reasonable alternative to consider.
Thanks @melissalinkert for the detailed investigation and agreed on all the points above. Do you want to close this PR and open a separate one with your conditional logic skipping the file leak detection on JDK 21 for evaluation of the nightly CI builds?
Sounds good - see https://github.com/ome/bioformats/pull/4159.
With the current infrastructure, the file-leak-detector fails with
This tries to upgrade the version of the file leak detector library to
1.18
which has allegedly JDK 21 support