This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 7176a87f Restore java.home when testToFindJavadoc fails
7176a87f is described below

commit 7176a87f45892248e35666ddc673ebdc389da1a1
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Oct 28 22:31:42 2026 +0000

    Restore java.home when testToFindJavadoc fails
    
    The test points java.home at a missing directory so that the javadoc
    executable is found through JAVA_HOME. Without JAVA_HOME it failed and
    left java.home broken, which failed 16 further tests in the same JVM.
    It now restores java.home in a finally block and is skipped when
    JAVA_HOME is not set.
---
 .../org/apache/maven/plugins/javadoc/JavadocReportTest.java  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java 
b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
index 9798de60..d3f2e5ef 100644
--- a/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
+++ b/src/test/java/org/apache/maven/plugins/javadoc/JavadocReportTest.java
@@ -635,12 +635,16 @@ class JavadocReportTest {
     @Basedir("/unit/javaHome-test")
     @Test
     void testToFindJavadoc(JavadocReport mojo) throws Exception {
+        String javaHome = System.getenv("JAVA_HOME");
+        assumeThat(javaHome).as("JAVA_HOME environment variable").isNotBlank();
+
         String oldJreHome = System.getProperty("java.home");
         System.setProperty("java.home", "foo/bar");
-
-        mojo.execute();
-
-        System.setProperty("java.home", oldJreHome);
+        try {
+            mojo.execute();
+        } finally {
+            System.setProperty("java.home", oldJreHome);
+        }
     }
 
     /**

Reply via email to